summaryrefslogtreecommitdiff
path: root/app/(auth)/_layout.tsx
blob: e18b629c252908723535767b61d22e5e5fb4136d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Redirect, Stack } from "expo-router";
import { useAuth } from "../../lib/auth";
import { colors } from "../../lib/theme";
import { LoadingScreen } from "../../lib/ui";

export default function AuthLayout() {
  const { isLoading, isAuthenticated } = useAuth();

  if (isLoading) {
    return <LoadingScreen />;
  }

  if (isAuthenticated) {
    return <Redirect href="/(tabs)" />;
  }

  return (
    <Stack
      screenOptions={{
        headerShown: false,
        contentStyle: { backgroundColor: colors.background },
      }}
    >
      <Stack.Screen name="welcome" />
      <Stack.Screen name="signin" />
      <Stack.Screen name="signup" />
    </Stack>
  );
}