This repository has been archived on 2024-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
p61-project/app/_layout.tsx

77 lines
1.7 KiB
TypeScript
Raw Normal View History

2024-02-16 22:51:50 +01:00
import { Stack } from "expo-router"
import * as SplashScreen from "expo-splash-screen"
import {
MD3LightTheme as DefaultTheme,
PaperProvider,
} from "react-native-paper"
import { StatusBar } from "expo-status-bar"
import { useEffect } from "react"
2024-04-05 00:08:40 +02:00
import { GestureHandlerRootView } from "react-native-gesture-handler"
2024-02-16 22:51:50 +01:00
2024-03-16 00:36:44 +01:00
import { HabitsTrackerProvider } from "@/presentation/react/contexts/HabitsTracker"
import {
AuthenticationProvider,
useAuthentication,
} from "@/presentation/react/contexts/Authentication"
2024-02-16 22:51:50 +01:00
export { ErrorBoundary } from "expo-router"
export const unstableSettings = {
initialRouteName: "index",
}
SplashScreen.preventAutoHideAsync().catch((error) => {
console.error(error)
})
const StackLayout: React.FC = () => {
const { hasLoaded } = useAuthentication()
2024-02-16 22:51:50 +01:00
useEffect(() => {
if (!hasLoaded) {
2024-02-16 22:51:50 +01:00
SplashScreen.hideAsync().catch((error) => {
console.error(error)
})
}
}, [hasLoaded])
2024-02-16 22:51:50 +01:00
if (hasLoaded) {
return <></>
2024-02-16 22:51:50 +01:00
}
return (
<Stack
screenOptions={{
headerShown: false,
}}
2024-03-23 01:43:27 +01:00
/>
)
}
const RootLayout: React.FC = () => {
return (
<AuthenticationProvider>
<HabitsTrackerProvider>
<PaperProvider
theme={{
...DefaultTheme,
colors: {
...DefaultTheme.colors,
primary: "#f57c00",
secondary: "#fbc02d",
},
2024-03-15 22:48:28 +01:00
}}
>
2024-04-05 00:08:40 +02:00
<GestureHandlerRootView style={{ flex: 1 }}>
<StackLayout />
</GestureHandlerRootView>
<StatusBar style="dark" />
</PaperProvider>
</HabitsTrackerProvider>
</AuthenticationProvider>
2024-02-16 22:51:50 +01:00
)
}
export default RootLayout