// Import global CSS file
import '../../global.css'
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet'
import { ThemeProvider } from '@react-navigation/native'
import { SplashScreen, Stack } from 'expo-router'
import React from 'react'
import { StyleSheet } from 'react-native'
import FlashMessage from 'react-native-flash-message'
import { GestureHandlerRootView } from 'react-native-gesture-handler'
import { KeyboardProvider } from 'react-native-keyboard-controller'
import { APIProvider } from '@/api'
import { hydrateAuth, loadSelectedTheme } from '@/core'
import { useThemeConfig } from '@/core/use-theme-config'
export { ErrorBoundary } from 'expo-router'
export const unstable_settings = {
initialRouteName: '(app)',
}
hydrateAuth()
loadSelectedTheme()
// Prevent the splash screen from auto-hiding before asset loading is complete.
SplashScreen.preventAutoHideAsync()
export default function RootLayout() {
return (
<Providers>
<Stack>
<Stack.Screen name="(app)" options={{ headerShown: false }} />
<Stack.Screen name="landing" options={{ headerShown: false }} />
<Stack.Screen name="register" options={{ headerShown: false }} />
<Stack.Screen name="login" options={{ headerShown: false }} />
</Stack>
</Providers>
)
}
function Providers({ children }: { children: React.ReactNode }) {
const theme = useThemeConfig()
return (
<GestureHandlerRootView style={styles.container} className={theme.dark ? `dark` : undefined}>
<KeyboardProvider>
<ThemeProvider value={theme}>
<APIProvider>
<BottomSheetModalProvider>
{children}
<FlashMessage position="top" />
</BottomSheetModalProvider>
</APIProvider>
</ThemeProvider>
</KeyboardProvider>
</GestureHandlerRootView>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
})