2024-12-16 13:34:01 +00:00
|
|
|
import { useReactNavigationDevTools } from '@dev-plugins/react-navigation'
|
|
|
|
import { useReactQueryDevTools } from '@dev-plugins/react-query'
|
|
|
|
import AsyncStorage from '@react-native-async-storage/async-storage'
|
2024-12-01 11:29:47 +00:00
|
|
|
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
2024-12-16 13:34:01 +00:00
|
|
|
import { QueryClient } from '@tanstack/react-query'
|
|
|
|
import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
|
|
|
|
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'
|
2024-12-10 20:50:22 +00:00
|
|
|
import { Stack, useNavigationContainerRef } from 'expo-router'
|
2024-12-01 17:58:53 +00:00
|
|
|
import { StatusBar } from 'expo-status-bar'
|
2024-12-09 20:00:15 +00:00
|
|
|
import { MD3DarkTheme, MD3LightTheme, PaperProvider } from 'react-native-paper'
|
2024-12-16 13:34:01 +00:00
|
|
|
import { Provider as StoreProvider } from 'react-redux'
|
|
|
|
import GameProvider from '@/components/providers/GameProvider'
|
|
|
|
import GeolocationProvider from '@/components/providers/GeolocationProvider'
|
|
|
|
import LoginProvider from '@/components/providers/LoginProvider'
|
2024-12-10 20:50:22 +00:00
|
|
|
import { useColorScheme } from '@/hooks/useColorScheme'
|
2024-12-06 20:49:28 +00:00
|
|
|
import store from '@/utils/store'
|
2024-12-01 11:29:47 +00:00
|
|
|
|
2024-12-10 23:30:20 +00:00
|
|
|
const queryClient = new QueryClient({
|
|
|
|
defaultOptions: {
|
|
|
|
queries: {
|
|
|
|
gcTime: 24 * 60 * 60 * 1000, // 24h
|
|
|
|
staleTime: 2000,
|
|
|
|
retry: 5,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2024-12-10 20:50:22 +00:00
|
|
|
|
2024-12-01 11:29:47 +00:00
|
|
|
export default function RootLayout() {
|
|
|
|
const colorScheme = useColorScheme()
|
2024-12-06 18:00:51 +00:00
|
|
|
|
2024-12-10 20:50:22 +00:00
|
|
|
const navigationRef = useNavigationContainerRef()
|
|
|
|
useReactNavigationDevTools(navigationRef)
|
|
|
|
useReactQueryDevTools(queryClient)
|
|
|
|
|
2024-12-10 23:30:20 +00:00
|
|
|
const asyncStoragePersister = createAsyncStoragePersister({
|
|
|
|
storage: AsyncStorage,
|
|
|
|
})
|
|
|
|
|
2024-12-06 20:49:28 +00:00
|
|
|
return (
|
2024-12-09 20:00:15 +00:00
|
|
|
<StoreProvider store={store}>
|
2024-12-10 23:30:20 +00:00
|
|
|
<PersistQueryClientProvider
|
|
|
|
client={queryClient}
|
|
|
|
persistOptions={{ persister: asyncStoragePersister }}
|
|
|
|
onSuccess={() => queryClient.resumePausedMutations().then(() => queryClient.invalidateQueries())}>
|
2024-12-10 20:50:22 +00:00
|
|
|
<LoginProvider loginRedirect={'/login'}>
|
2024-12-11 00:30:21 +00:00
|
|
|
<GeolocationProvider>
|
2024-12-11 20:33:51 +00:00
|
|
|
<GameProvider>
|
2024-12-11 21:28:32 +00:00
|
|
|
<PaperProvider
|
2024-12-13 23:27:30 +00:00
|
|
|
theme={colorScheme === 'dark' ? MD3DarkTheme : MD3LightTheme} >
|
2024-12-11 20:33:51 +00:00
|
|
|
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
|
|
|
|
<Stack>
|
|
|
|
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
|
|
|
<Stack.Screen name="login" options={{ headerShown: false }} />
|
2024-12-14 10:55:11 +00:00
|
|
|
<Stack.Screen name="challenges-list" options={{ headerShown: false }} />
|
2024-12-11 20:33:51 +00:00
|
|
|
<Stack.Screen name="+not-found" />
|
|
|
|
</Stack>
|
|
|
|
<StatusBar style="auto" />
|
|
|
|
</ThemeProvider>
|
|
|
|
</PaperProvider>
|
|
|
|
</GameProvider>
|
2024-12-11 00:30:21 +00:00
|
|
|
</GeolocationProvider>
|
2024-12-10 20:50:22 +00:00
|
|
|
</LoginProvider>
|
2024-12-10 23:30:20 +00:00
|
|
|
</PersistQueryClientProvider>
|
2024-12-09 20:00:15 +00:00
|
|
|
</StoreProvider>
|
2024-12-06 20:49:28 +00:00
|
|
|
)
|
2024-12-01 11:29:47 +00:00
|
|
|
}
|