Skip to content

Commit

Permalink
Flowtype PickerIOS
Browse files Browse the repository at this point in the history
Reviewed By: yungsters

Differential Revision: D7985960

fbshipit-source-id: 9fbce5fafe47bee1d2a527c72f3ebef85d26f9f1
  • Loading branch information
elicwhite authored and facebook-github-bot committed May 14, 2018
1 parent d796129 commit 1c66cdc
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions Libraries/Components/Picker/PickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

const NativeMethodsMixin = require('NativeMethodsMixin');
const React = require('React');
const ReactNative = require('ReactNative');
const PropTypes = require('prop-types');
const StyleSheet = require('StyleSheet');
const StyleSheetPropType = require('StyleSheetPropType');
Expand All @@ -26,6 +27,17 @@ const createReactClass = require('create-react-class');
const itemStylePropType = StyleSheetPropType(TextStylePropTypes);
const requireNativeComponent = require('requireNativeComponent');

import type {ColorValue} from 'StyleSheetTypes';
import type {ViewProps} from 'ViewPropTypes';

type Props = $ReadOnly<{|
...ViewProps,
color?: ?ColorValue,
label: string,
testID?: ?string,
value?: ?any,
|}>;

const PickerIOS = createReactClass({
displayName: 'PickerIOS',
mixins: [NativeMethodsMixin],
Expand Down Expand Up @@ -106,7 +118,13 @@ const PickerIOS = createReactClass({
},
});

PickerIOS.Item = class extends React.Component {
PickerIOS.Item = class extends React.Component<
$ReadOnly<{|
label: string,
value?: ?any,
color?: ?ColorValue,
|}>,
> {
static propTypes = {
value: PropTypes.any, // string or integer basically
label: PropTypes.string,
Expand All @@ -119,6 +137,10 @@ PickerIOS.Item = class extends React.Component {
}
};

class TypedPickerIOS extends ReactNative.NativeComponent<Props> {
static Item = PickerIOS.Item;
}

const styles = StyleSheet.create({
pickerIOS: {
// The picker will conform to whatever width is given, but we do
Expand All @@ -144,4 +166,4 @@ const RCTPickerIOS = requireNativeComponent(
},
);

module.exports = PickerIOS;
module.exports = ((PickerIOS: any): Class<TypedPickerIOS>);

0 comments on commit 1c66cdc

Please sign in to comment.