@@ -83,6 +83,15 @@ const dialogOptions = [
8383 { label : 'Option 8' , value : 6 }
8484] ;
8585
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+
8695export default class PickerScreen extends Component {
8796 picker = React . createRef < PickerMethods > ( ) ;
8897 state = {
@@ -96,6 +105,7 @@ export default class PickerScreen extends Component {
96105 dialogPickerValue : 'java' ,
97106 customModalValues : [ ] ,
98107 filter : undefined ,
108+ statOption : [ ] ,
99109 scheme : undefined ,
100110 contact : 0
101111 } ;
@@ -122,6 +132,15 @@ export default class PickerScreen extends Component {
122132 ) ;
123133 } ;
124134
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+
125144 render ( ) {
126145 return (
127146 < ScrollView keyboardShouldPersistTaps = "always" >
@@ -195,7 +214,32 @@ export default class PickerScreen extends Component {
195214 searchPlaceholder = { 'Search a language' }
196215 items = { dialogOptions }
197216 />
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+
199243 < Text marginB-10 text70 $textDefault >
200244 Custom Picker:
201245 </ Text >
0 commit comments