|
1 | 1 | import React from 'react'; |
2 | | -import { |
3 | | - Text as RNText, |
4 | | - StyleSheet, |
5 | | - View, |
6 | | - TouchableOpacity, |
7 | | - ViewPropTypes, |
8 | | -} from 'react-native'; |
| 2 | +import { Text as RNText, StyleSheet, View, ViewPropTypes } from 'react-native'; |
| 3 | +import RNPickerSelect from 'react-native-picker-select'; |
9 | 4 | import PropTypes from 'prop-types'; |
10 | 5 | import { createStyles, maxWidth } from './media-query'; |
11 | 6 | import Text from './text'; |
@@ -112,35 +107,44 @@ NamedField.propTypes = { |
112 | 107 | // |
113 | 108 |
|
114 | 109 | const namedSelectStyles = StyleSheet.create({ |
115 | | - touchable: { |
| 110 | + wrapper: { |
116 | 111 | flexDirection: 'row', |
117 | 112 | alignItems: 'center', |
118 | | - marginRight: 15, |
119 | 113 | }, |
120 | | - name: { |
| 114 | +}); |
| 115 | + |
| 116 | +const pickerStyles = StyleSheet.create({ |
| 117 | + inputIOS: { |
| 118 | + fontFamily: 'OpenSans Regular', |
| 119 | + fontSize: font.sizeM, |
| 120 | + lineHeight: font.lineHeightM + 3, |
| 121 | + height: font.lineHeightM + 2 * 12, |
121 | 122 | color: color.blackText, |
| 123 | + opacity: 0.75, |
| 124 | + }, |
| 125 | + inputAndroid: { |
| 126 | + fontFamily: 'OpenSans Regular', |
122 | 127 | fontSize: font.sizeM, |
123 | | - lineHeight: font.lineHeightM + 2 * 12, |
124 | | - marginRight: 3, |
| 128 | + lineHeight: font.lineHeightM + 3, |
| 129 | + height: font.lineHeightM + 2 * 12, |
| 130 | + color: color.blackText, |
| 131 | + opacity: 0.75, |
| 132 | + padding: 0, |
125 | 133 | }, |
126 | 134 | }); |
127 | 135 |
|
128 | | -export const NamedFieldSelect = ({ onPress, name, children, style }) => ( |
| 136 | +export const NamedFieldSelect = ({ name, style, ...props }) => ( |
129 | 137 | <View style={[namedStyles.content, style]}> |
130 | | - <TouchableOpacity style={namedSelectStyles.touchable} onPress={onPress}> |
131 | | - <Text style={namedSelectStyles.name}>{name}</Text> |
132 | | - <ArrowDownIcon height={22} width={22} stroke="#4A4A4A" /> |
133 | | - </TouchableOpacity> |
134 | | - <Text style={namedStyles.text} numberOfLines={1}> |
135 | | - {children} |
136 | | - </Text> |
| 138 | + <Text style={namedStyles.name}>{name}</Text> |
| 139 | + <View style={namedSelectStyles.wrapper}> |
| 140 | + <RNPickerSelect placeholder={{}} style={pickerStyles} {...props} /> |
| 141 | + <ArrowDownIcon height={22} width={22} stroke="#969596" /> |
| 142 | + </View> |
137 | 143 | </View> |
138 | 144 | ); |
139 | 145 |
|
140 | 146 | NamedFieldSelect.propTypes = { |
141 | | - onPress: PropTypes.func.isRequired, |
142 | 147 | name: PropTypes.string, |
143 | | - children: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), |
144 | 148 | style: ViewPropTypes.style, |
145 | 149 | }; |
146 | 150 |
|
|
0 commit comments