11import * as React from 'react' ;
2- import { ScrollView , View } from 'react-native' ;
2+ import { StyleSheet , ScrollView , View } from 'react-native' ;
33import {
44 Title ,
55 Button ,
@@ -12,7 +12,10 @@ import {
1212} from 'react-native-paper' ;
1313import { DatePickerModal } from '../../src' ;
1414import { Platform } from 'react-native' ;
15- import TimePicker from '../../src/Time/TimePicker' ;
15+
16+ import TimePickerModal from '../../src/Time/TimePickerModal' ;
17+ import DatePickerInput from '../../src/Date/DatePickerInput' ;
18+ import DateRangeInput from '../../src/Date/DateRangeInput' ;
1619
1720function App ( {
1821 onToggleDarkMode,
@@ -22,8 +25,12 @@ function App({
2225 dark : boolean ;
2326} ) {
2427 const theme = useTheme ( ) ;
28+ const [ timeOpen , setTimeOpen ] = React . useState ( false ) ;
2529 const [ rangeOpen , setRangeOpen ] = React . useState ( false ) ;
2630 const [ singleOpen , setSingleOpen ] = React . useState ( false ) ;
31+ const onDismissTime = React . useCallback ( ( ) => {
32+ setTimeOpen ( false ) ;
33+ } , [ setTimeOpen ] ) ;
2734 const onDismissRange = React . useCallback ( ( ) => {
2835 setRangeOpen ( false ) ;
2936 } , [ setRangeOpen ] ) ;
@@ -43,82 +50,51 @@ function App({
4350 return (
4451 < ScrollView
4552 scrollEnabled = { false }
46- style = { {
47- backgroundColor : theme . colors . background ,
48- flex : 1 ,
49- } }
53+ style = { [
54+ styles . root ,
55+ {
56+ backgroundColor : theme . colors . background ,
57+ } ,
58+ ] }
5059 contentInsetAdjustmentBehavior = "always"
5160 >
52- < View
53- style = { {
54- width : '100%' ,
55- maxWidth : 450 ,
56- backgroundColor : theme . colors . surface ,
57- shadowColor : '#000' ,
58- shadowOffset : {
59- width : 0 ,
60- height : 2 ,
61- } ,
62- shadowOpacity : 0.25 ,
63- shadowRadius : 3.84 ,
64- elevation : 5 ,
65- padding : 24 ,
66- alignSelf : 'center' ,
67- flex : 1 ,
68- } }
69- >
61+ < View style = { [ styles . content , { backgroundColor : theme . colors . surface } ] } >
7062 < Title > Examples</ Title >
71- < View style = { { flexDirection : 'row' , marginTop : 24 } } >
63+ < View style = { styles . switchContainer } >
7264 < Text > Dark mode</ Text >
73- < View style = { { flex : 1 } } />
65+ < View style = { styles . switchSpace } />
7466 < Switch value = { dark } onValueChange = { onToggleDarkMode } />
7567 </ View >
76- < View
77- style = { {
78- backgroundColor : theme . colors . primary ,
79- width : 50 ,
80- height : 50 ,
81- } }
82- />
83- < View
84- style = { {
85- backgroundColor : theme . colors . accent ,
86- width : 50 ,
87- height : 50 ,
88- } }
89- />
90- < View
91- style = { {
92- backgroundColor : theme . colors . background ,
93- width : 50 ,
94- height : 50 ,
95- } }
96- />
97- < View
98- style = { {
99- backgroundColor : theme . colors . surface ,
100- width : 50 ,
101- height : 50 ,
102- } }
103- />
10468
105- < View style = { { flexDirection : 'row' , marginTop : 24 } } >
69+ < View style = { styles . buttons } >
10670 < Button
10771 onPress = { ( ) => setRangeOpen ( true ) }
10872 uppercase = { false }
10973 mode = "outlined"
11074 >
11175 Pick range
11276 </ Button >
113- < View style = { { width : 6 } } />
77+ < View style = { styles . buttonSeparator } />
11478 < Button
11579 onPress = { ( ) => setSingleOpen ( true ) }
11680 uppercase = { false }
11781 mode = "outlined"
11882 >
11983 Pick single date
12084 </ Button >
85+ < View style = { styles . buttonSeparator } />
86+ < Button
87+ onPress = { ( ) => setTimeOpen ( true ) }
88+ uppercase = { false }
89+ mode = "outlined"
90+ >
91+ Pick time
92+ </ Button >
12193 </ View >
94+ < View style = { { height : 12 } } />
95+ < DatePickerInput />
96+ < View style = { { height : 12 } } />
97+ < DateRangeInput />
12298
12399 < DatePickerModal
124100 mode = "range"
@@ -142,9 +118,7 @@ function App({
142118 label = { 'Select date' } // optional
143119 />
144120
145- < View style = { { alignItems : 'center' , marginTop : 24 } } >
146- < TimePicker />
147- </ View >
121+ < TimePickerModal visible = { timeOpen } onDismiss = { onDismissTime } />
148122 </ View >
149123 </ ScrollView >
150124 ) ;
@@ -172,3 +146,27 @@ export default function AppWithProviders() {
172146 </ PaperProvider >
173147 ) ;
174148}
149+
150+ const styles = StyleSheet . create ( {
151+ root : { flex : 1 } ,
152+ content : {
153+ width : '100%' ,
154+ maxWidth : 450 ,
155+
156+ shadowColor : '#000' ,
157+ shadowOffset : {
158+ width : 0 ,
159+ height : 2 ,
160+ } ,
161+ shadowOpacity : 0.25 ,
162+ shadowRadius : 3.84 ,
163+ elevation : 5 ,
164+ padding : 24 ,
165+ alignSelf : 'center' ,
166+ flex : 1 ,
167+ } ,
168+ switchContainer : { flexDirection : 'row' , marginTop : 24 } ,
169+ switchSpace : { flex : 1 } ,
170+ buttons : { flexDirection : 'row' , marginTop : 24 } ,
171+ buttonSeparator : { width : 6 } ,
172+ } ) ;
0 commit comments