-
Notifications
You must be signed in to change notification settings - Fork 2
/
_layout.tsx
82 lines (71 loc) · 2.21 KB
/
_layout.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import '../tamagui-web.css'
import { useEffect } from 'react'
import { StatusBar, useColorScheme } from 'react-native'
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native'
import { useFonts } from 'expo-font'
import { SplashScreen, Stack } from 'expo-router'
import { Provider } from './Provider'
import { useTheme } from 'tamagui'
export {
// Catch any errors thrown by the Layout component.
ErrorBoundary,
} from 'expo-router'
export const unstable_settings = {
// Ensure that reloading on `/modal` keeps a back button present.
initialRouteName: '(tabs)',
}
// Prevent the splash screen from auto-hiding before asset loading is complete.
SplashScreen.preventAutoHideAsync()
export default function RootLayout() {
const [interLoaded, interError] = useFonts({
Inter: require('@tamagui/font-inter/otf/Inter-Medium.otf'),
InterBold: require('@tamagui/font-inter/otf/Inter-Bold.otf'),
})
useEffect(() => {
if (interLoaded || interError) {
// Hide the splash screen after the fonts have loaded (or an error was returned) and the UI is ready.
SplashScreen.hideAsync()
}
}, [interLoaded, interError])
if (!interLoaded && !interError) {
return null
}
return (
<Providers>
<RootLayoutNav />
</Providers>
)
}
const Providers = ({ children }: { children: React.ReactNode }) => {
return <Provider>{children}</Provider>
}
function RootLayoutNav() {
const colorScheme = useColorScheme()
const theme = useTheme()
return (
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
<StatusBar barStyle={colorScheme === 'dark' ? 'light-content' : 'dark-content'} />
<Stack>
<Stack.Screen
name="(tabs)"
options={{
headerShown: false,
}}
/>
{/* <Stack.Screen
name="modal"
options={{
title: 'Tamagui + Expo',
presentation: 'modal',
animation: 'slide_from_right',
gestureEnabled: true,
gestureDirection: 'horizontal',
contentStyle: {
backgroundColor: theme.background.val,
},
}}
/> */}
</Stack>
</ThemeProvider>
)
}