@@ -7,23 +7,20 @@ import {
77 useWindowDimensions ,
88 useColorScheme ,
99} from 'react-native'
10- import {
11- SafeAreaProvider ,
12- useSafeAreaInsets ,
13- } from 'react-native-safe-area-context'
10+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
1411import {
1512 Button ,
1613 Text ,
17- Provider as PaperProvider ,
1814 useTheme ,
1915 Paragraph ,
2016 List ,
2117 Divider ,
2218 Chip ,
19+ Provider as PaperProvider ,
2320 MD3DarkTheme ,
2421 MD3LightTheme ,
25- MD2LightTheme ,
2622 MD2DarkTheme ,
23+ MD2LightTheme ,
2724} from 'react-native-paper'
2825import {
2926 DatePickerModal ,
@@ -92,18 +89,14 @@ locales.forEach((locale) => {
9289 registerTranslation ( locale [ 0 ] , locale [ 1 ] )
9390} )
9491
95- function App ( {
96- materialYouEnabled,
97- setMaterialYouEnabled,
98- } : {
99- materialYouEnabled : boolean
100- setMaterialYouEnabled : ( v : boolean ) => void
101- } ) {
92+ export default function Example ( ) {
10293 /** Hooks. */
94+ const colorScheme = useColorScheme ( )
10395 const theme = useTheme ( )
10496 const insets = useSafeAreaInsets ( )
10597
10698 /** State variables. */
99+ const [ materialYouEnabled , setMaterialYouEnabled ] = useState ( true )
107100 const [ inputDate , setInputDate ] = useState < Date | undefined > ( undefined )
108101 const [ date , setDate ] = useState < Date | undefined > ( undefined )
109102 const [ dates , setDates ] = useState < Date [ ] | undefined > ( )
@@ -124,6 +117,8 @@ function App({
124117 const [ multiOpen , setMultiOpen ] = useState ( false )
125118
126119 /** Constants. */
120+ const m3Theme = colorScheme === 'dark' ? MD3DarkTheme : MD3LightTheme
121+ const m2Theme = colorScheme === 'dark' ? MD2DarkTheme : MD2LightTheme
127122 const maxFontSizeMultiplier = 1.5
128123 const dateFormatter = useMemo (
129124 ( ) =>
@@ -197,7 +192,7 @@ function App({
197192 const isLarge = dimensions . width > 600
198193
199194 return (
200- < >
195+ < PaperProvider theme = { materialYouEnabled ? m3Theme : m2Theme } >
201196 < StatusBar />
202197 < ScrollView
203198 style = { { backgroundColor : theme . colors . background } }
@@ -209,7 +204,10 @@ function App({
209204 < View style = { styles . contentContainer } >
210205 < View style = { isLarge && styles . surface } >
211206 < View style = { styles . row } >
212- < Image source = { require ( './schedule.png' ) } style = { styles . logo } />
207+ < Image
208+ source = { require ( '../assets/images/schedule.png' ) }
209+ style = { styles . logo }
210+ />
213211 < View style = { styles . column } >
214212 < Text
215213 maxFontSizeMultiplier = { maxFontSizeMultiplier }
@@ -453,7 +451,6 @@ function App({
453451 Pick multiple dates
454452 </ Button >
455453 </ View >
456-
457454 < View style = { styles . sectionContainer } >
458455 < View style = { styles . section } >
459456 < Text maxFontSizeMultiplier = { maxFontSizeMultiplier } >
@@ -570,25 +567,7 @@ function App({
570567 hours = { time . hours }
571568 minutes = { time . minutes }
572569 />
573- </ >
574- )
575- }
576-
577- export default function AppWithProviders ( ) {
578- const colorScheme = useColorScheme ( )
579- const [ materialYouEnabled , setMaterialYouEnabled ] = useState ( true )
580- const m3Theme = colorScheme === 'dark' ? MD3DarkTheme : MD3LightTheme
581- const m2Theme = colorScheme === 'dark' ? MD2DarkTheme : MD2LightTheme
582-
583- return (
584- < SafeAreaProvider >
585- < PaperProvider theme = { materialYouEnabled ? m3Theme : m2Theme } >
586- < App
587- materialYouEnabled = { materialYouEnabled }
588- setMaterialYouEnabled = { setMaterialYouEnabled }
589- />
590- </ PaperProvider >
591- </ SafeAreaProvider >
570+ </ PaperProvider >
592571 )
593572}
594573
0 commit comments