41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { useEffect } from 'react';
|
|
import { Stack } from 'expo-router';
|
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
import { StatusBar } from 'expo-status-bar';
|
|
import * as Updates from 'expo-updates';
|
|
import { useBootAuth } from '../hooks/useAuth';
|
|
import { Colors } from '../constants/theme';
|
|
|
|
export default function RootLayout() {
|
|
useBootAuth();
|
|
useOTAUpdates();
|
|
|
|
return (
|
|
<GestureHandlerRootView style={{ flex: 1, backgroundColor: Colors.bg }}>
|
|
<StatusBar style="light" />
|
|
<Stack screenOptions={{ headerShown: false, contentStyle: { backgroundColor: Colors.bg } }}>
|
|
<Stack.Screen name="(tabs)" />
|
|
<Stack.Screen name="auth" options={{ presentation: 'fullScreenModal' }} />
|
|
<Stack.Screen name="auth/callback" options={{ presentation: 'fullScreenModal' }} />
|
|
</Stack>
|
|
</GestureHandlerRootView>
|
|
);
|
|
}
|
|
|
|
function useOTAUpdates() {
|
|
useEffect(() => {
|
|
if (__DEV__) return;
|
|
(async () => {
|
|
try {
|
|
const check = await Updates.checkForUpdateAsync();
|
|
if (check.isAvailable) {
|
|
await Updates.fetchUpdateAsync();
|
|
await Updates.reloadAsync();
|
|
}
|
|
// eslint-disable-next-line no-empty
|
|
} catch {
|
|
// silent fail
|
|
}
|
|
})();
|
|
}, []);
|
|
}
|