1- import React , { JSX , useState } from 'react' ;
2- import { StyleSheet , Text , View , useColorScheme } from 'react-native' ;
3- import DropDownPicker , { ItemType } from 'react-native-dropdown-picker' ;
4- import JavascriptClassExample from './example-src-files/javascript-class-example' ;
5- import JavascriptFunctionExample from './example-src-files/javascript-function-example' ;
6- import TypescriptClassExample from './example-src-files/typescript-class-example' ;
7- import TypescriptFunctionExample from './example-src-files/typescript-function-example' ;
1+ import React , { JSX } from 'react' ;
2+ import { StyleSheet , View , useColorScheme } from 'react-native' ;
83import { GestureHandlerRootView } from 'react-native-gesture-handler' ;
4+ import DropDownPickerExample from './example-src-files/example' ;
95
106enum ExampleComponent {
117 JavaScriptClassSingleValue ,
@@ -21,90 +17,25 @@ enum ExampleComponent {
2117const styles = StyleSheet . create ( {
2218 page : {
2319 flex : 1 ,
24- justifyContent : 'center' ,
25- alignItems : 'center' ,
26- width : '100%' ,
27- height : '100%' ,
2820 } ,
2921 container : {
3022 flexDirection : 'column' ,
3123 margin : 'auto' ,
32- marginTop : 20 ,
24+ marginTop : 64 ,
25+ marginBottom : 64 ,
3326 padding : 3 ,
34- maxWidth : 400 ,
27+ maxWidth : 600 ,
28+ minWidth : 400
3529 } ,
36- } ) ;
37-
38- const EXAMPLE_COMPONENT_ITEMS : Array < ItemType < ExampleComponent > > = [
39- {
40- label : 'JavaScript; class component; single-item' ,
41- value : ExampleComponent . JavaScriptClassSingleValue ,
42- } ,
43- {
44- label : 'JavaScript; class component; multiple-item' ,
45- value : ExampleComponent . JavaScriptClassMultiValue ,
46- } ,
47- {
48- label : 'JavaScript; function component; single-item' ,
49- value : ExampleComponent . JavaScriptFunctionSingleValue ,
50- } ,
51- {
52- label : 'JavaScript; function component; multiple-item' ,
53- value : ExampleComponent . JavaScriptFunctionMultiValue ,
54- } ,
55- {
56- label : 'TypeScript; class component; single-item' ,
57- value : ExampleComponent . TypeScriptClassSingleValue ,
58- } ,
59- {
60- label : 'TypeScript; class component; multiple-item' ,
61- value : ExampleComponent . TypeScriptClassMultiValue ,
62- } ,
63- {
64- label : 'TypeScript; function component; single-item' ,
65- value : ExampleComponent . TypeScriptFunctionSingleValue ,
66- } ,
67- {
68- label : 'TypeScript; function component; multiple-item' ,
69- value : ExampleComponent . TypeScriptFunctionMultiValue ,
70- } ,
71- ] ;
72-
73- const getExample = ( egComponent : ExampleComponent ) : JSX . Element => {
74- switch ( egComponent ) {
75- case ExampleComponent . JavaScriptClassSingleValue :
76- return < JavascriptClassExample multiple = { false } /> ;
77- case ExampleComponent . JavaScriptClassMultiValue :
78- return < JavascriptClassExample multiple /> ;
79- case ExampleComponent . JavaScriptFunctionSingleValue :
80- return < JavascriptFunctionExample multiple = { false } /> ;
81- case ExampleComponent . JavaScriptFunctionMultiValue :
82- return < JavascriptFunctionExample multiple /> ;
83- case ExampleComponent . TypeScriptClassSingleValue :
84- return < TypescriptClassExample multiple = { false } /> ;
85- case ExampleComponent . TypeScriptClassMultiValue :
86- return < TypescriptClassExample multiple /> ;
87- case ExampleComponent . TypeScriptFunctionSingleValue :
88- return < TypescriptFunctionExample multiple = { false } /> ;
89- case ExampleComponent . TypeScriptFunctionMultiValue :
90- return < TypescriptFunctionExample multiple /> ;
91- default :
92- throw new Error (
93- "couldn't match example component in getExample() in App.tsx. egComponent was: " ,
94- egComponent ,
95- ) ;
30+ examplesContainer : {
31+ display : 'flex' ,
32+ flexDirection : 'column' ,
33+ justifyContent : 'flex-start' ,
34+ gap : 32
9635 }
97- } ;
36+ } ) ;
9837
9938export default function App ( ) : JSX . Element {
100- const [ currentExample , setCurrentExample ] = useState < ExampleComponent > (
101- ExampleComponent . JavaScriptClassSingleValue
102- ) ;
103- const [ examplePickerOpen , setOpen ] = useState < boolean > ( false ) ;
104- const [ exampleComponents ] = useState < Array < ItemType < ExampleComponent > > > (
105- EXAMPLE_COMPONENT_ITEMS
106- ) ;
107-
10839 const colorScheme = useColorScheme ( ) ;
10940 const backgroundColor = colorScheme === 'dark' ? '#222' : '#fff' ;
11041
@@ -115,28 +46,37 @@ export default function App(): JSX.Element {
11546 backgroundColor,
11647 } } >
11748 < View style = { styles . container } >
118- < View style = { { marginBottom : 32 } } >
119- < View style = { { marginBottom : 32 } } >
120- < Text > Choose example:</ Text >
121- </ View >
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+ />
12267
123- < View style = { { marginBottom : 32 } } >
124- < DropDownPicker
125- setValue = { setCurrentExample }
126- value = { currentExample }
127- items = { exampleComponents }
128- open = { examplePickerOpen }
129- setOpen = { setOpen }
68+ < DropDownPickerExample
69+ title = "Autoscroll Example"
70+ description = "This is the default dropdown picker - with autoscroll"
71+ dropdownProps = { { autoScroll : true } }
13072 />
131- </ View >
132- </ View >
13373
134- < View style = { { marginBottom : 32 } } >
135- < View style = { { marginBottom : 32 } } >
136- < Text > Example:</ Text >
137- </ View >
13874
139- { getExample ( currentExample ) }
75+ < DropDownPickerExample
76+ title = "Searchable Example"
77+ description = "This is the default dropdown picker - with search"
78+ dropdownProps = { { searchable : true } }
79+ />
14080 </ View >
14181 </ View >
14282 </ View >
0 commit comments