traintrape-moi/client/app/_layout.tsx

46 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-12-01 11:29:47 +00:00
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native'
import { Stack, useNavigationContainerRef } from 'expo-router'
import { StatusBar } from 'expo-status-bar'
2024-12-09 20:00:15 +00:00
import { Provider as StoreProvider } from 'react-redux'
import { MD3DarkTheme, MD3LightTheme, PaperProvider } from 'react-native-paper'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { useReactNavigationDevTools } from '@dev-plugins/react-navigation'
import { useReactQueryDevTools } from '@dev-plugins/react-query'
import { useColorScheme } from '@/hooks/useColorScheme'
import store from '@/utils/store'
import { useStartBackgroundFetchServiceEffect } from '@/utils/background'
import { useStartGeolocationServiceEffect } from '@/utils/geolocation'
import LoginProvider from '@/components/LoginProvider'
2024-12-01 11:29:47 +00:00
const queryClient = new QueryClient()
2024-12-01 11:29:47 +00:00
export default function RootLayout() {
useStartGeolocationServiceEffect()
useStartBackgroundFetchServiceEffect()
2024-12-01 11:29:47 +00:00
const colorScheme = useColorScheme()
2024-12-06 18:00:51 +00:00
const navigationRef = useNavigationContainerRef()
useReactNavigationDevTools(navigationRef)
useReactQueryDevTools(queryClient)
return (
2024-12-09 20:00:15 +00:00
<StoreProvider store={store}>
<QueryClientProvider client={queryClient}>
<LoginProvider loginRedirect={'/login'}>
<PaperProvider theme={colorScheme === 'dark' ? MD3DarkTheme : MD3LightTheme}>
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
<Stack>
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen name="login" options={{ headerShown: false }} />
<Stack.Screen name="+not-found" />
</Stack>
<StatusBar style="auto" />
</ThemeProvider>
</PaperProvider>
</LoginProvider>
</QueryClientProvider>
2024-12-09 20:00:15 +00:00
</StoreProvider>
)
2024-12-01 11:29:47 +00:00
}