11import React , { JSX } from 'react' ;
2- import { StyleSheet , View , useColorScheme } from 'react-native' ;
2+ import { StyleSheet , View , Text , FlatList , useColorScheme } from 'react-native' ;
33import { GestureHandlerRootView } from 'react-native-gesture-handler' ;
4- import DropDownPickerExample from './example-src-files/example' ;
5-
6- enum ExampleComponent {
7- JavaScriptClassSingleValue ,
8- JavaScriptClassMultiValue ,
9- JavaScriptFunctionSingleValue ,
10- JavaScriptFunctionMultiValue ,
11- TypeScriptClassSingleValue ,
12- TypeScriptClassMultiValue ,
13- TypeScriptFunctionSingleValue ,
14- TypeScriptFunctionMultiValue ,
15- }
4+ import DropDownPickerExample , { ExampleProps } from './example-src-files/example' ;
165
176const styles = StyleSheet . create ( {
187 page : {
@@ -32,67 +21,77 @@ const styles = StyleSheet.create({
3221 flexDirection : 'column' ,
3322 justifyContent : 'flex-start' ,
3423 gap : 32
24+ } ,
25+ exampleCard : {
26+ zIndex :0 ,
27+ borderRadius : 8 ,
28+ marginBottom : 48
3529 }
3630} ) ;
3731
32+ const EXAMPLES : ExampleProps [ ] = [ {
33+ title : "Default Example" ,
34+ description : "This is the default dropdown picker"
35+ } , {
36+ title : "Multiple Select" ,
37+ description : "Multiple select example" ,
38+ multiple : true
39+ } , {
40+ title : "Multiple Select Badge Mode" ,
41+ description : "Multiple select example - with badges" ,
42+ multiple : true ,
43+ dropdownProps : { mode : "BADGE" } ,
44+ } , {
45+ title : "Autoscroll Example" ,
46+ description : "This is the default dropdown picker - with autoscroll" ,
47+ dropdownProps : { autoScroll : true } ,
48+ } , {
49+ title : "Searchable Example" ,
50+ description : "This is the default dropdown picker - with search" ,
51+ dropdownProps : { searchable : true } ,
52+ } , {
53+ title : "Multiple Search Example" ,
54+ description : "This is the default dropdown picker - with search" ,
55+ multiple : true ,
56+ dropdownProps : { searchable : true } ,
57+ } , {
58+ title : "Multiple Search Clear on Select Example" ,
59+ description : "This is the default dropdown picker - with search" ,
60+ multiple : true ,
61+ dropdownProps : { searchable : true , clearSearchFieldOnSelect : true , mode : "BADGE" } ,
62+ } , {
63+ title : "Modal Example" ,
64+ description : "This is the default dropdown picker - with search" ,
65+ multiple : true ,
66+ dropdownProps : { listMode : "MODAL" }
67+ } ]
68+
3869export default function App ( ) : JSX . Element {
3970 const colorScheme = useColorScheme ( ) ;
4071 const backgroundColor = colorScheme === 'dark' ? '#222' : '#fff' ;
4172
73+ const renderItem = ( { item } : { item : ExampleProps } ) => (
74+ < View style = { styles . exampleCard } key = { item . title } >
75+ < DropDownPickerExample
76+ { ...item }
77+ />
78+ </ View >
79+ ) ;
80+
4281 return (
4382 < GestureHandlerRootView style = { { flex : 1 } } >
4483 < View style = { {
4584 ...styles . page ,
4685 backgroundColor,
4786 } } >
48- < View style = { styles . container } >
49- < View style = { styles . examplesContainer } >
50- < DropDownPickerExample
51- title = "Default Example"
52- description = "This is the default dropdown picker"
53- />
54-
55- < DropDownPickerExample
56- title = "Multiple Select"
57- description = "Multiple select example"
58- multiple
59- />
60-
61- < DropDownPickerExample
62- title = "Multiple Select Badge Mode"
63- description = "Multiple select example - with badges"
64- multiple
65- dropdownProps = { { mode : "BADGE" } }
66- />
67-
68- < DropDownPickerExample
69- title = "Autoscroll Example"
70- description = "This is the default dropdown picker - with autoscroll"
71- dropdownProps = { { autoScroll : true } }
72- />
73-
74-
75- < DropDownPickerExample
76- title = "Searchable Example"
77- description = "This is the default dropdown picker - with search"
78- dropdownProps = { { searchable : true } }
79- />
80-
81- < DropDownPickerExample
82- title = "Multiple Search Example"
83- description = "This is the default dropdown picker - with search"
84- multiple
85- dropdownProps = { { searchable : true } }
86- />
87-
88- < DropDownPickerExample
89- title = "Multiple Search Clear on Select Example"
90- description = "This is the default dropdown picker - with search"
91- multiple
92- dropdownProps = { { searchable : true , clearSearchFieldOnSelect : true , mode : "BADGE" } }
93- />
94- </ View >
95- </ View >
87+ < FlatList
88+ data = { EXAMPLES }
89+ style = { { zIndex : 0 } }
90+ keyExtractor = { ( example : ExampleProps ) => example . title }
91+ renderItem = { renderItem }
92+ contentContainerStyle = { styles . container }
93+ showsVerticalScrollIndicator = { false }
94+ />
9695 </ View >
9796 </ GestureHandlerRootView >
9897 ) ;
0 commit comments