File tree Expand file tree Collapse file tree 3 files changed +99
-5
lines changed
Libraries/Components/Picker Expand file tree Collapse file tree 3 files changed +99
-5
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) Facebook, Inc. and its affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ *
7+ * @format
8+ * @flow
9+ */
10+
11+ 'use strict' ;
12+
13+ const requireNativeComponent = require ( 'requireNativeComponent' ) ;
14+
15+ import type { SyntheticEvent } from 'CoreEventTypes' ;
16+ import type { TextStyleProp } from 'StyleSheet' ;
17+ import type { NativeComponent } from 'ReactNative' ;
18+
19+ type PickerAndroidChangeEvent = SyntheticEvent <
20+ $ReadOnly < { |
21+ position : number ,
22+ | } > ,
23+ > ;
24+
25+ type Item = $ReadOnly < { |
26+ label : string ,
27+ value : ?( number | string ) ,
28+ color ?: ?number ,
29+ | } > ;
30+
31+ type NativeProps = $ReadOnly < { |
32+ enabled ?: ?boolean ,
33+ items : $ReadOnlyArray < Item > ,
34+ mode ?: ?( 'dialog' | 'dropdown' ) ,
35+ onSelect ?: ( event : PickerAndroidChangeEvent ) => void ,
36+ selected : number ,
37+ prompt ?: ?string ,
38+ testID ?: string ,
39+ style ?: ?TextStyleProp ,
40+ accessibilityLabel ?: ?string ,
41+ | } > ;
42+
43+ type DialogPickerNativeType = Class < NativeComponent < NativeProps >> ;
44+
45+ module . exports = ( ( requireNativeComponent (
46+ 'AndroidDialogPicker' ,
47+ ) : any ) : DialogPickerNativeType ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) Facebook, Inc. and its affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ *
7+ * @format
8+ * @flow
9+ */
10+
11+ 'use strict' ;
12+
13+ const requireNativeComponent = require ( 'requireNativeComponent' ) ;
14+
15+ import type { SyntheticEvent } from 'CoreEventTypes' ;
16+ import type { TextStyleProp } from 'StyleSheet' ;
17+ import type { NativeComponent } from 'ReactNative' ;
18+
19+ type PickerAndroidChangeEvent = SyntheticEvent <
20+ $ReadOnly < { |
21+ position : number ,
22+ | } > ,
23+ > ;
24+
25+ type Item = $ReadOnly < { |
26+ label : string ,
27+ value : ?( number | string ) ,
28+ color ?: ?number ,
29+ | } > ;
30+
31+ type NativeProps = $ReadOnly < { |
32+ enabled ?: ?boolean ,
33+ items : $ReadOnlyArray < Item > ,
34+ mode ?: ?( 'dialog' | 'dropdown' ) ,
35+ onSelect ?: ( event : PickerAndroidChangeEvent ) => void ,
36+ selected : number ,
37+ prompt ?: ?string ,
38+ testID ?: string ,
39+ style ?: ?TextStyleProp ,
40+ accessibilityLabel ?: ?string ,
41+ | } > ;
42+
43+ type DropdownPickerNativeType = Class < NativeComponent < NativeProps >> ;
44+
45+ module . exports = ( ( requireNativeComponent (
46+ 'AndroidDropdownPicker' ,
47+ ) : any ) : DropdownPickerNativeType ) ;
Original file line number Diff line number Diff line change 1010
1111'use strict' ;
1212
13+ const AndroidDropdownPickerNativeComponent = require ( 'AndroidDropdownPickerNativeComponent' ) ;
14+ const AndroidDialogPickerNativeComponent = require ( 'AndroidDialogPickerNativeComponent' ) ;
1315const React = require ( 'React' ) ;
1416const StyleSheet = require ( 'StyleSheet' ) ;
1517
1618const processColor = require ( 'processColor' ) ;
17- const requireNativeComponent = require ( 'requireNativeComponent' ) ;
18-
19- const DropdownPicker = requireNativeComponent ( 'AndroidDropdownPicker' ) ;
20- const DialogPicker = requireNativeComponent ( 'AndroidDialogPicker' ) ;
2119
2220const REF_PICKER = 'picker' ;
2321const MODE_DROPDOWN = 'dropdown' ;
@@ -103,7 +101,9 @@ class PickerAndroid extends React.Component<
103101
104102 render ( ) {
105103 const Picker =
106- this . props . mode === MODE_DROPDOWN ? DropdownPicker : DialogPicker ;
104+ this . props . mode === MODE_DROPDOWN
105+ ? AndroidDropdownPickerNativeComponent
106+ : AndroidDialogPickerNativeComponent ;
107107
108108 const nativeProps = {
109109 enabled : this . props . enabled ,
You can’t perform that action at this time.
0 commit comments