Skip to content

Commit 595e207

Browse files
authored
feat(picker): Add picker for android
1 parent 0e11348 commit 595e207

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/withPickerValues/PickerModal.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ class PickerModal extends PureComponent<PropsType> {
2121
};
2222

2323
renderPicker = () => {
24+
const { values, placeholder, value } = this.props;
25+
if (values && Platform.OS === 'ios') {
26+
values.unshift({ value: '', label: placeholder });
27+
}
2428
const picker = (
25-
<Picker onValueChange={this.onValueChange} selectedValue={this.props.value}>
26-
<Picker.Item value="" label={this.props.placeholder} />
27-
{this.props.values.map(item => <Picker.Item key={item.value} {...item} />)}
29+
<Picker onValueChange={this.onValueChange} selectedValue={value} prompt={placeholder}>
30+
{values.map(item => <Picker.Item key={item.value} {...item} />)}
2831
</Picker>
2932
);
3033

@@ -37,7 +40,9 @@ class PickerModal extends PureComponent<PropsType> {
3740
{picker}
3841
</KeyboardModal>
3942
) : (
40-
picker
43+
<View style={{ opacity: 0, position: 'absolute', top: 0, bottom: 0, right: 0, left: 0 }}>
44+
{picker}
45+
</View>
4146
);
4247
};
4348

0 commit comments

Comments
 (0)