1
1
mirror of https://github.com/theoludwig/p61-project.git synced 2024-07-17 07:00:12 +02:00
p61-project/app/_layout.tsx

81 lines
1.8 KiB
TypeScript
Raw Permalink Normal View History

2024-02-16 22:51:50 +01:00
import { Stack } from "expo-router"
2024-04-12 23:13:38 +02:00
import { fas } from "@fortawesome/free-solid-svg-icons"
import { library } from "@fortawesome/fontawesome-svg-core"
2024-02-16 22:51:50 +01:00
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",
}
2024-04-12 23:13:38 +02:00
library.add(fas)
2024-02-16 22:51:50 +01:00
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