mirror of
https://github.com/status-im/react-native.git
synced 2025-01-24 16:29:01 +00:00
Flowtype PickerIOS
Reviewed By: yungsters Differential Revision: D7985960 fbshipit-source-id: 9fbce5fafe47bee1d2a527c72f3ebef85d26f9f1
This commit is contained in:
parent
d796129895
commit
1c66cdc7e8
@ -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');
|
||||
@ -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],
|
||||
@ -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,
|
||||
@ -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
|
||||
@ -144,4 +166,4 @@ const RCTPickerIOS = requireNativeComponent(
|
||||
},
|
||||
);
|
||||
|
||||
module.exports = PickerIOS;
|
||||
module.exports = ((PickerIOS: any): Class<TypedPickerIOS>);
|
||||
|
Loading…
x
Reference in New Issue
Block a user