@@ -24,14 +24,39 @@ const tagIcon = require('../../assets/icons/tags.png');
24
24
const dropdown = require ( '../../assets/icons/chevronDown.png' ) ;
25
25
const dropdownIcon = < Icon source = { dropdown } tintColor = { Colors . $iconDefault } /> ;
26
26
27
- const contacts = _ . map ( contactsData , ( c , index ) => ( { ...c , value : index , label : c . name } ) ) ;
27
+ const renderContact = ( contactValue : any , props : any ) => {
28
+ const contact = contacts [ contactValue as number ] ;
29
+ return (
30
+ < View
31
+ style = { {
32
+ height : 56 ,
33
+ borderBottomWidth : 1 ,
34
+ borderColor : Colors . $backgroundNeutral
35
+ } }
36
+ paddingH-15
37
+ row
38
+ centerV
39
+ spread
40
+ >
41
+ < View row centerV >
42
+ < Avatar size = { 35 } source = { { uri : contact ?. thumbnail } } />
43
+ < Text marginL-10 text70 $textDefault >
44
+ { contact ?. name }
45
+ </ Text >
46
+ </ View >
47
+ { props . isSelected && < Icon source = { Assets . icons . check } tintColor = { Colors . $iconDefault } /> }
48
+ </ View >
49
+ ) ;
50
+ } ;
51
+
52
+ const contacts = _ . map ( contactsData , ( c , index ) => ( { ...c , value : index , label : c . name , renderItem : renderContact } ) ) ;
28
53
29
54
const options = [
30
- { label : 'JavaScript' , value : 'js' } ,
31
- { label : 'Java' , value : 'java' } ,
32
- { label : 'Python' , value : 'python' } ,
33
- { label : 'C++' , value : 'c++' , disabled : true } ,
34
- { label : 'Perl' , value : 'perl' }
55
+ { label : 'JavaScript' , value : 'js' , labelStyle : Typography . text65 } ,
56
+ { label : 'Java' , value : 'java' , labelStyle : Typography . text65 } ,
57
+ { label : 'Python' , value : 'python' , labelStyle : Typography . text65 } ,
58
+ { label : 'C++' , value : 'c++' , disabled : true , labelStyle : Typography . text65 } ,
59
+ { label : 'Perl' , value : 'perl' , labelStyle : Typography . text65 }
35
60
] ;
36
61
37
62
const filters = [
@@ -76,7 +101,6 @@ export default class PickerScreen extends Component {
76
101
77
102
renderDialog : PickerProps [ 'renderCustomModal' ] = ( modalProps : RenderCustomModalProps ) => {
78
103
const { visible, children, toggleModal, onDone} = modalProps ;
79
-
80
104
return (
81
105
< Incubator . Dialog
82
106
visible = { visible }
@@ -116,11 +140,8 @@ export default class PickerScreen extends Component {
116
140
searchPlaceholder = { 'Search a language' }
117
141
searchStyle = { { color : Colors . blue30 , placeholderTextColor : Colors . grey50 } }
118
142
// onSearchChange={value => console.warn('value', value)}
119
- >
120
- { _ . map ( longOptions , option => (
121
- < Picker . Item key = { option . value } value = { option . value } label = { option . label } disabled = { option . disabled } />
122
- ) ) }
123
- </ Picker >
143
+ items = { longOptions }
144
+ />
124
145
125
146
< Picker
126
147
placeholder = "Favorite Languages (up to 3)"
@@ -129,11 +150,8 @@ export default class PickerScreen extends Component {
129
150
mode = { Picker . modes . MULTI }
130
151
selectionLimit = { 3 }
131
152
trailingAccessory = { dropdownIcon }
132
- >
133
- { _ . map ( options , option => (
134
- < Picker . Item key = { option . value } value = { option . value } label = { option . label } disabled = { option . disabled } />
135
- ) ) }
136
- </ Picker >
153
+ items = { options }
154
+ />
137
155
138
156
< Picker
139
157
label = "Wheel Picker"
@@ -142,20 +160,8 @@ export default class PickerScreen extends Component {
142
160
value = { this . state . nativePickerValue }
143
161
onChange = { nativePickerValue => this . setState ( { nativePickerValue} ) }
144
162
trailingAccessory = { < Icon source = { dropdown } /> }
145
- // containerStyle={{marginTop: 20}}
146
- // renderPicker={() => {
147
- // return (
148
- // <View>
149
- // <Text>Open Native Picker!</Text>
150
- // </View>
151
- // );
152
- // }}
153
- // topBarProps={{doneLabel: 'YES', cancelLabel: 'NO'}}
154
- >
155
- { _ . map ( options , option => (
156
- < Picker . Item key = { option . value } value = { option . value } label = { option . label } disabled = { option . disabled } />
157
- ) ) }
158
- </ Picker >
163
+ items = { options }
164
+ />
159
165
160
166
< Picker
161
167
label = "Custom modal"
@@ -165,17 +171,8 @@ export default class PickerScreen extends Component {
165
171
mode = { Picker . modes . MULTI }
166
172
trailingAccessory = { dropdownIcon }
167
173
renderCustomModal = { this . renderDialog }
168
- >
169
- { _ . map ( options , option => (
170
- < Picker . Item
171
- key = { option . value }
172
- value = { option . value }
173
- label = { option . label }
174
- labelStyle = { Typography . text65 }
175
- disabled = { option . disabled }
176
- />
177
- ) ) }
178
- </ Picker >
174
+ items = { options }
175
+ />
179
176
180
177
< Picker
181
178
label = "Dialog Picker"
@@ -195,12 +192,8 @@ export default class PickerScreen extends Component {
195
192
customPickerProps = { { migrateDialog : true , dialogProps : { bottom : true , width : '100%' , height : '45%' } } }
196
193
showSearch
197
194
searchPlaceholder = { 'Search a language' }
198
- >
199
- { _ . map ( dialogOptions , option => (
200
- < Picker . Item key = { option . value } value = { option . value } label = { option . label } disabled = { option . disabled } />
201
- ) ) }
202
- </ Picker >
203
-
195
+ items = { dialogOptions }
196
+ />
204
197
< Text marginB-10 text70 $textDefault >
205
198
Custom Picker:
206
199
</ Text >
@@ -221,12 +214,8 @@ export default class PickerScreen extends Component {
221
214
</ View >
222
215
) ;
223
216
} }
224
- >
225
- { _ . map ( filters , filter => (
226
- < Picker . Item key = { filter . value } value = { filter . value } label = { filter . label } />
227
- ) ) }
228
- </ Picker >
229
-
217
+ items = { filters }
218
+ />
230
219
< Text marginT-20 marginB-10 text70 $textDefault >
231
220
Custom Picker Items:
232
221
</ Text >
@@ -236,7 +225,6 @@ export default class PickerScreen extends Component {
236
225
onChange = { contact => {
237
226
this . setState ( { contact} ) ;
238
227
} }
239
- // getItemValue={contact => contact?.value}
240
228
renderPicker = { ( contactValue ?: number ) => {
241
229
const contact = contacts [ contactValue ! ] ?? undefined ;
242
230
return (
@@ -256,78 +244,36 @@ export default class PickerScreen extends Component {
256
244
</ View >
257
245
) ;
258
246
} }
259
- >
260
- { _ . map ( contacts , contact => (
261
- < Picker . Item
262
- key = { contact . name }
263
- value = { contact . value }
264
- label = { contact . label }
265
- renderItem = { ( contactValue , props ) => {
266
- const contact = contacts [ contactValue as number ] ;
267
- return (
268
- < View
269
- style = { {
270
- height : 56 ,
271
- borderBottomWidth : 1 ,
272
- borderColor : Colors . $backgroundNeutral
273
- } }
274
- paddingH-15
275
- row
276
- centerV
277
- spread
278
- >
279
- < View row centerV >
280
- < Avatar size = { 35 } source = { { uri : contact ?. thumbnail } } />
281
- < Text marginL-10 text70 $textDefault >
282
- { contact ?. name }
283
- </ Text >
284
- </ View >
285
- { props . isSelected && < Icon source = { Assets . icons . check } tintColor = { Colors . $iconDefault } /> }
286
- </ View >
287
- ) ;
288
- } }
289
- getItemLabel = { contactValue => contacts [ contactValue as number ] ?. name }
290
- />
291
- ) ) }
292
- </ Picker >
293
-
247
+ items = { contacts }
248
+ />
294
249
< Button
295
250
label = "Open Picker Manually"
296
251
link
297
252
style = { { alignSelf : 'flex-start' } }
298
253
onPress = { ( ) => this . picker . current ?. openExpandable ?.( ) }
299
254
/>
300
-
301
255
< Text text60 marginT-s5 >
302
256
Different Field Types
303
257
</ Text >
304
258
< Text text80 marginB-s5 >
305
259
(Form/Filter/Settings)
306
260
</ Text >
307
-
308
261
< Picker
309
262
value = { this . state . filter }
310
263
onChange = { value => this . setState ( { filter : value } ) }
311
264
placeholder = "Filter posts"
312
265
fieldType = { Picker . fieldTypes . filter }
313
266
marginB-s3
314
- >
315
- { filters . map ( filter => (
316
- < Picker . Item key = { filter . value } { ...filter } />
317
- ) ) }
318
- </ Picker >
319
-
267
+ items = { filters }
268
+ />
320
269
< Picker
321
270
value = { this . state . scheme }
322
271
onChange = { value => this . setState ( { scheme : value } ) }
323
272
label = "Color Scheme"
324
273
placeholder = "Filter posts"
325
274
fieldType = { Picker . fieldTypes . settings }
326
- >
327
- { schemes . map ( scheme => (
328
- < Picker . Item key = { scheme . value } { ...scheme } />
329
- ) ) }
330
- </ Picker >
275
+ items = { schemes }
276
+ />
331
277
</ View >
332
278
</ ScrollView >
333
279
) ;
0 commit comments