@@ -24,6 +24,7 @@ import {
2424 Chip ,
2525 MD3DarkTheme ,
2626 MD3LightTheme ,
27+ MD2LightTheme ,
2728} from 'react-native-paper'
2829import {
2930 DatePickerModal ,
@@ -55,6 +56,7 @@ import {
5556} from 'react-native-paper-dates'
5657import { useCallback , useState } from 'react'
5758
59+ const presentationStyles = [ 'overFullScreen' , 'pageSheet' ] as const
5860const locales : [ string , TranslationsType ] [ ] = [
5961 [ 'ar' , ar ] ,
6062 [ 'ca' , ca ] ,
@@ -83,7 +85,13 @@ locales.forEach((locale) => {
8385 registerTranslation ( locale [ 0 ] , locale [ 1 ] )
8486} )
8587
86- function App ( ) {
88+ function App ( {
89+ materialYouEnabled,
90+ setMaterialYouEnabled,
91+ } : {
92+ materialYouEnabled : boolean
93+ setMaterialYouEnabled : ( v : boolean ) => void
94+ } ) {
8795 /** Hooks. */
8896 const theme = useTheme ( )
8997 const insets = useSafeAreaInsets ( )
@@ -101,6 +109,8 @@ function App() {
101109 minutes : number | undefined
102110 } > ( { hours : undefined , minutes : undefined } )
103111 const [ locale , setLocale ] = useState ( 'en-GB' )
112+ const [ presentationStyle , setPresentationStyle ] =
113+ useState < ( typeof presentationStyles ) [ number ] > ( 'overFullScreen' )
104114 const [ timeOpen , setTimeOpen ] = useState ( false )
105115 const [ rangeOpen , setRangeOpen ] = useState ( false )
106116 const [ singleOpen , setSingleOpen ] = useState ( false )
@@ -182,16 +192,16 @@ function App() {
182192 return (
183193 < >
184194 < StatusBar
185- barStyle = "light-content"
186- backgroundColor = { theme . colors . primary }
195+ // barStyle="light-content"
196+ // backgroundColor={theme.colors.primary}
187197 translucent = { true }
188198 />
189199 < ScrollView
190200 style = { { backgroundColor : theme . colors . background } }
191201 contentContainerStyle = { [
192202 styles . contentContainer ,
193203 styles . paddingSixteen ,
194- { marginTop : insets . top } ,
204+ { paddingTop : insets . top + 24 , paddingBottom : insets . bottom } ,
195205 ] }
196206 >
197207 < View style = { isLarge && styles . surface } >
@@ -269,7 +279,58 @@ function App() {
269279 View documentation
270280 </ Button >
271281 </ View >
282+ < Divider style = { styles . marginVerticalEight } />
283+ < Text
284+ maxFontSizeMultiplier = { maxFontSizeMultiplier }
285+ style = { [ styles . marginVerticalEight , styles . bold ] }
286+ >
287+ Material theme
288+ </ Text >
289+ < View style = { styles . chipContainer } >
290+ < Chip
291+ compact
292+ selected = { materialYouEnabled }
293+ onPress = { ( ) => setMaterialYouEnabled ( true ) }
294+ style = { styles . chip }
295+ >
296+ Material You
297+ </ Chip >
298+ < Chip
299+ compact
300+ selected = { ! materialYouEnabled }
301+ onPress = { ( ) => setMaterialYouEnabled ( false ) }
302+ style = { styles . chip }
303+ >
304+ Material Design 2
305+ </ Chip >
306+ </ View >
272307
308+ < Divider style = { styles . marginVerticalEight } />
309+ < Text
310+ maxFontSizeMultiplier = { maxFontSizeMultiplier }
311+ style = { [ styles . marginVerticalEight , styles . bold ] }
312+ >
313+ Presentation Style (iOS only)
314+ </ Text >
315+ < View style = { styles . chipContainer } >
316+ { presentationStyles . map ( ( option ) => {
317+ return (
318+ < Chip
319+ compact
320+ key = { option }
321+ selected = { presentationStyle === option }
322+ onPress = { ( ) =>
323+ setPresentationStyle (
324+ option as ( typeof presentationStyles ) [ number ]
325+ )
326+ }
327+ style = { styles . chip }
328+ >
329+ { option }
330+ </ Chip >
331+ )
332+ } ) }
333+ </ View >
273334 < Divider style = { styles . marginVerticalEight } />
274335 < Text
275336 maxFontSizeMultiplier = { maxFontSizeMultiplier }
@@ -468,6 +529,7 @@ function App() {
468529 startDate = { range . startDate }
469530 endDate = { range . endDate }
470531 onConfirm = { onChangeRange }
532+ presentationStyle = { presentationStyle }
471533 />
472534 < DatePickerModal
473535 locale = { locale }
@@ -480,6 +542,7 @@ function App() {
480542 startDate : pastDate ,
481543 disabledDates : [ futureDate ] ,
482544 } }
545+ presentationStyle = { presentationStyle }
483546 />
484547 < DatePickerModal
485548 locale = { locale }
@@ -489,6 +552,7 @@ function App() {
489552 dates = { dates }
490553 validRange = { { startDate : new Date ( ) } }
491554 onConfirm = { onChangeMulti }
555+ presentationStyle = { presentationStyle }
492556 />
493557 < TimePickerModal
494558 locale = { locale }
@@ -504,12 +568,16 @@ function App() {
504568
505569export default function AppWithProviders ( ) {
506570 const colorScheme = useColorScheme ( )
571+ const [ materialYouEnabled , setMaterialYouEnabled ] = React . useState ( true )
572+ const m3Theme = colorScheme === 'dark' ? MD3DarkTheme : MD3LightTheme
573+ const m2Theme = colorScheme === 'dark' ? MD2LightTheme : MD2LightTheme
507574 return (
508575 < SafeAreaProvider >
509- < PaperProvider
510- theme = { colorScheme === 'dark' ? MD3DarkTheme : MD3LightTheme }
511- >
512- < App />
576+ < PaperProvider theme = { materialYouEnabled ? m3Theme : m2Theme } >
577+ < App
578+ materialYouEnabled = { materialYouEnabled }
579+ setMaterialYouEnabled = { setMaterialYouEnabled }
580+ />
513581 </ PaperProvider >
514582 </ SafeAreaProvider >
515583 )
0 commit comments