Files
react-native/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js
T
Tim Yung 3c41e7387d RN: Cleanup PickerAndroid
Summary:
Cleans up the implementation of `AndroidPicker` and the Flow types for the native components to almost work with `codegenNativeComponent`.

The remaining blocker is that the `items` prop is an array of objects: https://fburl.com/km8uj8x2

Reviewed By: rickhanlonii

Differential Revision: D15805611

fbshipit-source-id: 34bea83db8dbaaf6eb23b00e73e0c7ce292e8a32
2019-06-26 10:05:32 -07:00

50 lines
1.2 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/
'use strict';
import {requireNativeComponent} from 'react-native';
import type {DirectEvent, Int32, WithDefault} from '../../Types/CodegenTypes';
import type {TextStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {NativeComponent} from '../../Renderer/shims/ReactNative';
import type {ViewProps} from '../../Components/View/ViewPropTypes';
type PickerItem = $ReadOnly<{|
label: string,
color?: ?Int32,
|}>;
type PickerItemSelectEvent = $ReadOnly<{|
position: Int32,
|}>;
type NativeProps = $ReadOnly<{|
...ViewProps,
style?: ?TextStyleProp,
// Props
color?: ?ColorValue,
enabled?: ?WithDefault<boolean, true>,
items: $ReadOnlyArray<PickerItem>,
prompt?: ?WithDefault<string, ''>,
selected: WithDefault<Int32, 0>,
// Events
onSelect?: (event: DirectEvent<PickerItemSelectEvent>) => void,
|}>;
type ReactPicker = Class<NativeComponent<NativeProps>>;
module.exports = ((requireNativeComponent(
'AndroidDialogPicker',
): any): ReactPicker);