feat: add auth
This commit is contained in:
@@ -4,6 +4,7 @@ import { StatusBar } from 'expo-status-bar';
|
||||
import 'react-native-reanimated';
|
||||
|
||||
import { useColorScheme } from '@/hooks/use-color-scheme';
|
||||
import { authClient } from '@/lib/auth-client';
|
||||
|
||||
export const unstable_settings = {
|
||||
anchor: '(tabs)',
|
||||
@@ -11,12 +12,17 @@ export const unstable_settings = {
|
||||
|
||||
export default function RootLayout() {
|
||||
const colorScheme = useColorScheme();
|
||||
const { data, isPending } = authClient.useSession();
|
||||
|
||||
return (
|
||||
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
|
||||
<Stack>
|
||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="modal" options={{ presentation: 'modal', title: 'Modal' }} />
|
||||
<Stack.Protected guard={!isPending && !!data}>
|
||||
<Stack.Screen name="index" />
|
||||
</Stack.Protected>
|
||||
<Stack.Protected guard={!isPending && !data}>
|
||||
<Stack.Screen name="auth" />
|
||||
</Stack.Protected>
|
||||
</Stack>
|
||||
<StatusBar style="auto" />
|
||||
</ThemeProvider>
|
||||
|
||||
Reference in New Issue
Block a user