sso-poc-marn/app/_layout.tsx

72 lines
2 KiB
TypeScript
Raw Permalink Normal View History

import FontAwesome from '@expo/vector-icons/FontAwesome';
2024-05-14 13:43:07 +02:00
import {DarkTheme, DefaultTheme, ThemeProvider} from '@react-navigation/native';
import {useFonts} from 'expo-font';
import {Stack} from 'expo-router';
import * as SplashScreen from 'expo-splash-screen';
2024-05-14 13:43:07 +02:00
import {useEffect} from 'react';
2024-05-14 13:43:07 +02:00
import {useColorScheme} from '@/components/useColorScheme';
import {View} from "react-native";
export {
2024-05-14 13:43:07 +02:00
// Catch any errors thrown by the Layout component.
ErrorBoundary,
} from 'expo-router';
export const unstable_settings = {
2024-05-14 13:43:07 +02:00
// Ensure that reloading on `/modal` keeps a back button present.
initialRouteName: 'index',
};
// Prevent the splash screen from auto-hiding before asset loading is complete.
SplashScreen.preventAutoHideAsync();
export default function RootLayout() {
2024-05-14 13:43:07 +02:00
const [loaded, error] = useFonts({
SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),
...FontAwesome.font,
});
// Expo Router uses Error Boundaries to catch errors in the navigation tree.
useEffect(() => {
if (error) throw error;
}, [error]);
2024-05-14 13:43:07 +02:00
useEffect(() => {
if (loaded) {
SplashScreen.hideAsync();
}
}, [loaded]);
2024-05-14 13:43:07 +02:00
if (!loaded) {
return null;
}
return <RootLayoutNav/>;
}
function RootLayoutNav() {
2024-05-14 13:43:07 +02:00
const colorScheme = useColorScheme();
return (
<View style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}}>
<View style={{
flex: 1,
width: '100%',
}}>
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
<Stack>
<Stack.Screen name="index" options={{headerShown: false}}/>
<Stack.Screen name="ssoCallback" options={{headerShown: false}}/>
<Stack.Screen name="ssoLogout" options={{headerShown: false}}/>
</Stack>
</ThemeProvider>
</View>
</View>
);
}