@@ -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"
@@ -195,12 +201,8 @@ export default class PickerScreen extends Component {
195
201
customPickerProps = { { migrateDialog : true , dialogProps : { bottom : true , width : '100%' , height : '45%' } } }
196
202
showSearch
197
203
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
-
204
+ items = { dialogOptions }
205
+ />
204
206
< Text marginB-10 text70 $textDefault >
205
207
Custom Picker:
206
208
</ Text >
@@ -221,12 +223,8 @@ export default class PickerScreen extends Component {
221
223
</ View >
222
224
) ;
223
225
} }
224
- >
225
- { _ . map ( filters , filter => (
226
- < Picker . Item key = { filter . value } value = { filter . value } label = { filter . label } />
227
- ) ) }
228
- </ Picker >
229
-
226
+ items = { filters }
227
+ />
230
228
< Text marginT-20 marginB-10 text70 $textDefault >
231
229
Custom Picker Items:
232
230
</ Text >
@@ -236,7 +234,6 @@ export default class PickerScreen extends Component {
236
234
onChange = { contact => {
237
235
this . setState ( { contact} ) ;
238
236
} }
239
- // getItemValue={contact => contact?.value}
240
237
renderPicker = { ( contactValue ?: number ) => {
241
238
const contact = contacts [ contactValue ! ] ?? undefined ;
242
239
return (
@@ -256,78 +253,36 @@ export default class PickerScreen extends Component {
256
253
</ View >
257
254
) ;
258
255
} }
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
-
256
+ items = { contacts }
257
+ />
294
258
< Button
295
259
label = "Open Picker Manually"
296
260
link
297
261
style = { { alignSelf : 'flex-start' } }
298
262
onPress = { ( ) => this . picker . current ?. openExpandable ?.( ) }
299
263
/>
300
-
301
264
< Text text60 marginT-s5 >
302
265
Different Field Types
303
266
</ Text >
304
267
< Text text80 marginB-s5 >
305
268
(Form/Filter/Settings)
306
269
</ Text >
307
-
308
270
< Picker
309
271
value = { this . state . filter }
310
272
onChange = { value => this . setState ( { filter : value } ) }
311
273
placeholder = "Filter posts"
312
274
fieldType = { Picker . fieldTypes . filter }
313
275
marginB-s3
314
- >
315
- { filters . map ( filter => (
316
- < Picker . Item key = { filter . value } { ...filter } />
317
- ) ) }
318
- </ Picker >
319
-
276
+ items = { filters }
277
+ />
320
278
< Picker
321
279
value = { this . state . scheme }
322
280
onChange = { value => this . setState ( { scheme : value } ) }
323
281
label = "Color Scheme"
324
282
placeholder = "Filter posts"
325
283
fieldType = { Picker . fieldTypes . settings }
326
- >
327
- { schemes . map ( scheme => (
328
- < Picker . Item key = { scheme . value } { ...scheme } />
329
- ) ) }
330
- </ Picker >
284
+ items = { schemes }
285
+ />
331
286
</ View >
332
287
</ ScrollView >
333
288
) ;
0 commit comments