* docs(react-native): create the basic expo project * docs(react-native): cross-platform Apple social sign-in * docs(react-native): cross-platform Google social sign-in * docs(react-native): fix typos * docs(react-native): remove wrong entry in the `Connection` component * Correct typos * Prettier * Draft * Draft * docs(react-native): use kebab-case file naming convention in Expo guide - use kebab-case file naming convention in Expo guide - add trailing semicolon to align with the standard Expo template conventions * docs(react-native): use kebab-case file naming convention in Expo social auth example * docs(react-native): update the packages of the Expo social auth example * Fix * Draft * Changes * Correct log message --------- Co-authored-by: Chris Chinchilla <chris.ward@supabase.io> Co-authored-by: Chris Chinchilla <chris@chrischinchilla.com>
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';
|
|
import { useFonts } from 'expo-font';
|
|
import { Stack } from 'expo-router';
|
|
import { StatusBar } from 'expo-status-bar';
|
|
import 'react-native-reanimated';
|
|
|
|
import { SplashScreenController } from '@/components/splash-screen-controller';
|
|
|
|
import { useAuthContext } from '@/hooks/use-auth-context';
|
|
import { useColorScheme } from '@/hooks/use-color-scheme';
|
|
import AuthProvider from '@/providers/auth-provider';
|
|
|
|
// Separate RootNavigator so we can access the AuthContext
|
|
function RootNavigator() {
|
|
const { isLoggedIn } = useAuthContext();
|
|
|
|
return (
|
|
<Stack>
|
|
<Stack.Protected guard={isLoggedIn}>
|
|
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
|
</Stack.Protected>
|
|
<Stack.Protected guard={!isLoggedIn}>
|
|
<Stack.Screen name="login" options={{ headerShown: false }} />
|
|
</Stack.Protected>
|
|
<Stack.Screen name="+not-found" />
|
|
</Stack>
|
|
);
|
|
}
|
|
|
|
export default function RootLayout() {
|
|
const colorScheme = useColorScheme();
|
|
|
|
const [loaded] = useFonts({
|
|
SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),
|
|
});
|
|
|
|
if (!loaded) {
|
|
// Async font loading only occurs in development.
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
|
|
<AuthProvider>
|
|
<SplashScreenController />
|
|
<RootNavigator />
|
|
<StatusBar style="auto" />
|
|
</AuthProvider>
|
|
</ThemeProvider>
|
|
);
|
|
}
|
|
|