Guest User

Untitled

a guest
Jan 14th, 2019
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.91 KB | None | 0 0
  1. diff --git a/react-native/Libraries/Components/CheckBox/AndroidCheckBoxNativeComponent.js b/react-native/Libraries/Components/CheckBox/AndroidCheckBoxNativeComponent.js
  2. new file mode 100644
  3. --- /dev/null
  4. +++ b/react-native/Libraries/Components/CheckBox/AndroidCheckBoxNativeComponent.js
  5. @@ -0,0 +1,51 @@
  6. +/**
  7. + * Copyright (c) Facebook, Inc. and its affiliates.
  8. + *
  9. + * This source code is licensed under the MIT license found in the
  10. + * LICENSE file in the root directory of this source tree.
  11. + *
  12. + * @flow
  13. + * @format
  14. + */
  15. +'use strict';
  16. +
  17. +const requireNativeComponent = require('requireNativeComponent');
  18. +
  19. +import type {ViewProps} from 'ViewPropTypes';
  20. +import type {SyntheticEvent} from 'CoreEventTypes';
  21. +import type {NativeComponent} from 'ReactNative';
  22. +
  23. +type CheckBoxEvent = SyntheticEvent<
  24. +  $ReadOnly<{|
  25. +    target: number,
  26. +    value: boolean,
  27. +  |}>,
  28. +>;
  29. +
  30. +type NativeProps = $ReadOnly<{|
  31. +  ...ViewProps,
  32. +
  33. +  /**
  34. +   * Used in case the props change removes the component.
  35. +   */
  36. +  onChange?: ?(event: CheckBoxEvent) => mixed,
  37. +
  38. +  /**
  39. +   * Invoked with the new value when the value changes.
  40. +   */
  41. +  onValueChange?: ?(value: boolean) => mixed,
  42. +
  43. +  /**
  44. +   * Used to locate this view in end-to-end tests.
  45. +   */
  46. +  testID?: ?string,
  47. +
  48. +  on?: ?boolean,
  49. +  enabled?: boolean,
  50. +|}>;
  51. +
  52. +type CheckBoxNativeType = Class<NativeComponent<NativeProps>>;
  53. +
  54. +module.exports = ((requireNativeComponent(
  55. +  'AndroidCheckBox',
  56. +): any): CheckBoxNativeType);
  57. diff --git a/react-native/Libraries/Components/CheckBox/CheckBox.android.js b/react-native/Libraries/Components/CheckBox/CheckBox.android.js
  58. --- a/react-native/Libraries/Components/CheckBox/CheckBox.android.js
  59. +++ b/react-native/Libraries/Components/CheckBox/CheckBox.android.js
  60. @@ -9,6 +9,7 @@
  61.   */
  62.  'use strict';
  63.  
  64. +const AndroidCheckBoxNativeComponent = require('AndroidCheckBoxNativeComponent');
  65.  const React = require('React');
  66.  const StyleSheet = require('StyleSheet');
  67.  
  68. @@ -18,7 +19,6 @@
  69.  
  70.  import type {ViewProps} from 'ViewPropTypes';
  71.  import type {SyntheticEvent} from 'CoreEventTypes';
  72. -import type {NativeComponent} from 'ReactNative';
  73.  
  74.  type CheckBoxEvent = SyntheticEvent<
  75.    $ReadOnly<{|
  76. @@ -46,15 +46,6 @@
  77.    testID?: ?string,
  78.  |}>;
  79.  
  80. -type NativeProps = $ReadOnly<{|
  81. -  ...CommonProps,
  82. -
  83. -  on?: ?boolean,
  84. -  enabled?: boolean,
  85. -|}>;
  86. -
  87. -type CheckBoxNativeType = Class<NativeComponent<NativeProps>>;
  88. -
  89.  type Props = $ReadOnly<{|
  90.    ...CommonProps,
  91.  
  92. @@ -76,10 +67,6 @@
  93.    forwardedRef?: ?React.Ref<CheckBoxNativeType>,
  94.  |}>;
  95.  
  96. -const RCTCheckBox = ((requireNativeComponent(
  97. -  'AndroidCheckBox',
  98. -): any): CheckBoxNativeType);
  99. -
  100.  /**
  101.   * Renders a boolean input (Android only).
  102.   *
  103. @@ -169,7 +156,7 @@
  104.      };
  105.  
  106.      return (
  107. -      <RCTCheckBox
  108. +      <AndroidCheckBoxNativeComponent
  109.          {...nativeProps}
  110.          ref={this._setNativeRef}
  111.          onChange={this._onChange}
Advertisement
Add Comment
Please, Sign In to add comment