@@ -83,6 +83,15 @@ const dialogOptions = [
83
83
{ label : 'Option 8' , value : 6 }
84
84
] ;
85
85
86
+ const statusOptions = [
87
+ { label : 'Overview' , value : 'overview' } ,
88
+ { label : 'In Progress' , value : 'inProgress' } ,
89
+ { label : 'Completed' , value : 'completed' } ,
90
+ { label : 'Pending Review' , value : 'pendingReview' } ,
91
+ { label : 'Approved' , value : 'approved' } ,
92
+ { label : 'Rejected' , value : 'rejected' }
93
+ ] ;
94
+
86
95
export default class PickerScreen extends Component {
87
96
picker = React . createRef < PickerMethods > ( ) ;
88
97
state = {
@@ -96,6 +105,7 @@ export default class PickerScreen extends Component {
96
105
dialogPickerValue : 'java' ,
97
106
customModalValues : [ ] ,
98
107
filter : undefined ,
108
+ statOption : [ ] ,
99
109
scheme : undefined ,
100
110
contact : 0
101
111
} ;
@@ -122,6 +132,15 @@ export default class PickerScreen extends Component {
122
132
) ;
123
133
} ;
124
134
135
+ onTopElementPress = ( allOptionsSelected : boolean ) => {
136
+ if ( allOptionsSelected ) {
137
+ this . setState ( { statOption : [ ] } ) ;
138
+ } else {
139
+ const allValues = statusOptions . map ( option => option . value ) ;
140
+ this . setState ( { statOption : allValues } ) ;
141
+ }
142
+ } ;
143
+
125
144
render ( ) {
126
145
return (
127
146
< ScrollView keyboardShouldPersistTaps = "always" >
@@ -195,7 +214,32 @@ export default class PickerScreen extends Component {
195
214
searchPlaceholder = { 'Search a language' }
196
215
items = { dialogOptions }
197
216
/>
198
-
217
+
218
+ < Text text70 $textDefault >
219
+ Custom Top Element:
220
+ </ Text >
221
+ < Picker
222
+ placeholder = "Status"
223
+ floatingPlaceholder
224
+ value = { this . state . statOption }
225
+ onChange = { items => this . setState ( { statOption : items } ) }
226
+ topBarProps = { { title : 'Status' } }
227
+ mode = { Picker . modes . MULTI }
228
+ items = { statusOptions }
229
+ renderCustomTopElement = { value => {
230
+ const allOptionsSelected = Array . isArray ( value ) && value . length === statusOptions . length ;
231
+ return (
232
+ < View margin-s3 >
233
+ < Button
234
+ label = { allOptionsSelected ? 'Unselect All' : 'Select All' }
235
+ onPress = { ( ) => this . onTopElementPress ( allOptionsSelected ) }
236
+ size = "small"
237
+ />
238
+ </ View >
239
+ ) ;
240
+ } }
241
+ />
242
+
199
243
< Text marginB-10 text70 $textDefault >
200
244
Custom Picker:
201
245
</ Text >
0 commit comments