summaryrefslogtreecommitdiffstats
path: root/src/app/(auth)/_layout.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/(auth)/_layout.tsx')
-rw-r--r--src/app/(auth)/_layout.tsx27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/app/(auth)/_layout.tsx b/src/app/(auth)/_layout.tsx
index e69de29..1fa69af 100644
--- a/src/app/(auth)/_layout.tsx
+++ b/src/app/(auth)/_layout.tsx
@@ -0,0 +1,27 @@
+import { Stack, Redirect } from 'expo-router';
+import { useAuthSession } from '@/providers/AuthProvider';
+import { ActivityIndicator, View } from 'react-native';
+
+export default function AuthLayout() {
+ const { user, loading } = useAuthSession();
+
+ if (loading) {
+ return (
+ <View
+ style={{
+ flex: 1,
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}
+ >
+ <ActivityIndicator size="large" />
+ </View>
+ );
+ }
+
+ if (user) {
+ return <Redirect href="/(protected)/home" />;
+ }
+
+ return <Stack screenOptions={{ headerShown: false }} />;
+}