Skip to content

Commit af920fc

Browse files
committed
minor fix with how we render custom native picker
1 parent a83407b commit af920fc

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

demo/src/screens/componentScreens/PickerScreen.js

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
33
import {ScrollView, Image} from 'react-native';
4-
import {View, Colors, Dialog, Text, Stepper, Typography, Picker, Avatar, Assets, TagsInput, PanningProvider} from 'react-native-ui-lib'; //eslint-disable-line
4+
import {
5+
View,
6+
Colors,
7+
Dialog,
8+
Text,
9+
Picker,
10+
Avatar,
11+
Assets,
12+
PanningProvider
13+
} from 'react-native-ui-lib'; //eslint-disable-line
514
import contacts from '../../data/conversations';
615
import tagIcon from '../../assets/icons/tags.png';
716
import dropdown from '../../assets/icons/chevronDown.png';
@@ -11,13 +20,13 @@ const options = [
1120
{label: 'Java', value: 'java'},
1221
{label: 'Python', value: 'python'},
1322
{label: 'C++', value: 'c++', disabled: true},
14-
{label: 'Perl', value: 'perl'},
23+
{label: 'Perl', value: 'perl'}
1524
];
1625
const filters = [
1726
{label: 'All', value: 0},
1827
{label: 'Draft', value: 1},
1928
{label: 'Published', value: 2},
20-
{label: 'Scheduled', value: 3},
29+
{label: 'Scheduled', value: 3}
2130
];
2231

2332
export default class PickerScreen extends Component {
@@ -35,7 +44,7 @@ export default class PickerScreen extends Component {
3544
contact: contacts[0],
3645
tags: [{label: 'Amit'}, {label: 'Ethan'}],
3746
tags2: ['Tags', 'Input'],
38-
tags3: ['Non', 'Removable', 'Tags'],
47+
tags3: ['Non', 'Removable', 'Tags']
3948
};
4049
}
4150

@@ -74,9 +83,7 @@ export default class PickerScreen extends Component {
7483
return (
7584
<ScrollView keyboardShouldPersistTaps="always">
7685
<View flex padding-20>
77-
<Text text40>
78-
Picker
79-
</Text>
86+
<Text text40>Picker</Text>
8087
<Picker
8188
placeholder="Favorite Language"
8289
floatingPlaceholder
@@ -91,7 +98,7 @@ export default class PickerScreen extends Component {
9198
// onSearchChange={value => console.warn('value', value)}
9299
>
93100
{_.map(options, option => (
94-
<Picker.Item key={option.value} value={option} disabled={option.disabled} />
101+
<Picker.Item key={option.value} value={option} disabled={option.disabled}/>
95102
))}
96103
</Picker>
97104

@@ -105,7 +112,7 @@ export default class PickerScreen extends Component {
105112
hideUnderline
106113
>
107114
{_.map(options, option => (
108-
<Picker.Item key={option.value} value={option} disabled={option.disabled} />
115+
<Picker.Item key={option.value} value={option} disabled={option.disabled}/>
109116
))}
110117
</Picker>
111118
</View>
@@ -118,7 +125,14 @@ export default class PickerScreen extends Component {
118125
onChange={nativePickerValue => this.setState({nativePickerValue})}
119126
rightIconSource={dropdown}
120127
containerStyle={{marginTop: 20}}
121-
// renderNativePicker={(props) => {
128+
// renderPicker={() => {
129+
// return (
130+
// <View>
131+
// <Text>Open Native Picker!</Text>
132+
// </View>
133+
// );
134+
// }}
135+
// renderNativePicker={props => {
122136
// return (
123137
// <View flex bg-red50>
124138
// <Text>CUSTOM NATIVE PICKER</Text>
@@ -136,7 +150,7 @@ export default class PickerScreen extends Component {
136150
cancelLabelStyle={{color: Colors.violet30}}
137151
>
138152
{_.map(options, option => (
139-
<Picker.Item key={option.value} value={option.value} label={option.label} disabled={option.disabled} />
153+
<Picker.Item key={option.value} value={option.value} label={option.label} disabled={option.disabled}/>
140154
))}
141155
</Picker>
142156

@@ -151,7 +165,7 @@ export default class PickerScreen extends Component {
151165
renderCustomModal={this.renderDialog}
152166
>
153167
{_.map(options, option => (
154-
<Picker.Item key={option.value} value={option} label={option.label} disabled={option.disabled} />
168+
<Picker.Item key={option.value} value={option} label={option.label} disabled={option.disabled}/>
155169
))}
156170
</Picker>
157171
</View>
@@ -165,7 +179,7 @@ export default class PickerScreen extends Component {
165179
renderPicker={({label}) => {
166180
return (
167181
<View row center>
168-
<Image style={{marginRight: 1, height: 16, resizeMode: 'contain'}} source={tagIcon} />
182+
<Image style={{marginRight: 1, height: 16, resizeMode: 'contain'}} source={tagIcon}/>
169183
<Text dark10 text80>
170184
{label} Posts
171185
</Text>
@@ -174,7 +188,7 @@ export default class PickerScreen extends Component {
174188
}}
175189
>
176190
{_.map(filters, filter => (
177-
<Picker.Item key={filter.value} value={filter} />
191+
<Picker.Item key={filter.value} value={filter}/>
178192
))}
179193
</Picker>
180194

@@ -188,7 +202,7 @@ export default class PickerScreen extends Component {
188202
renderPicker={contact => {
189203
return (
190204
<View row center>
191-
<Avatar size={30} imageSource={{uri: contact.thumbnail}} />
205+
<Avatar size={30} imageSource={{uri: contact.thumbnail}}/>
192206
<Text text70 marginL-10>
193207
{contact.name}
194208
</Text>
@@ -205,20 +219,20 @@ export default class PickerScreen extends Component {
205219
style={{
206220
height: 56,
207221
borderBottomWidth: 1,
208-
borderColor: Colors.dark80,
222+
borderColor: Colors.dark80
209223
}}
210224
paddingH-15
211225
row
212226
centerV
213227
spread
214228
>
215229
<View row centerV>
216-
<Avatar size={35} imageSource={{uri: item.thumbnail}} />
230+
<Avatar size={35} imageSource={{uri: item.thumbnail}}/>
217231
<Text marginL-10 text70 dark10>
218232
{item.name}
219233
</Text>
220234
</View>
221-
{props.isSelected && <Image source={Assets.icons.check} />}
235+
{props.isSelected && <Image source={Assets.icons.check}/>}
222236
</View>
223237
)}
224238
getItemLabel={item => item.name}

src/components/picker/NativePicker.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import TextField from '../inputs/TextField';
55
import {WheelPicker} from '../../nativeComponents';
66
import PickerDialog from './PickerDialog';
77
import TouchableOpacity from '../touchableOpacity';
8-
import View from '../view';
98
import {Colors} from '../../style';
109

1110
class NativePicker extends BaseComponent {
@@ -80,12 +79,12 @@ class NativePicker extends BaseComponent {
8079
if (_.isFunction(renderPicker)) {
8180
const {selectedValue} = this.state;
8281
return (
83-
<View left>
82+
<>
8483
<TouchableOpacity {...customPickerProps} link onPress={() => this.toggleDialog(true)} testID={testID}>
8584
{renderPicker(selectedValue)}
8685
</TouchableOpacity>
8786
{this.renderPickerDialog()}
88-
</View>
87+
</>
8988
);
9089
}
9190

0 commit comments

Comments
 (0)