Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 33c9153

Browse files
committed
Integrate react-native-picker-select into NamedFieldSelect component
1 parent 0965f9a commit 33c9153

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

src/component/field.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
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';
94
import PropTypes from 'prop-types';
105
import { createStyles, maxWidth } from './media-query';
116
import Text from './text';
@@ -112,35 +107,44 @@ NamedField.propTypes = {
112107
//
113108

114109
const namedSelectStyles = StyleSheet.create({
115-
touchable: {
110+
wrapper: {
116111
flexDirection: 'row',
117112
alignItems: 'center',
118-
marginRight: 15,
119113
},
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,
121122
color: color.blackText,
123+
opacity: 0.75,
124+
},
125+
inputAndroid: {
126+
fontFamily: 'OpenSans Regular',
122127
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,
125133
},
126134
});
127135

128-
export const NamedFieldSelect = ({ onPress, name, children, style }) => (
136+
export const NamedFieldSelect = ({ name, style, ...props }) => (
129137
<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>
137143
</View>
138144
);
139145

140146
NamedFieldSelect.propTypes = {
141-
onPress: PropTypes.func.isRequired,
142147
name: PropTypes.string,
143-
children: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
144148
style: ViewPropTypes.style,
145149
};
146150

0 commit comments

Comments
 (0)