aboutsummaryrefslogtreecommitdiff
path: root/src/app/(app)/_layout.tsx
blob: 6099274a117b8b73b88c083dbe131d64fb2f72b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { Colors } from "@/constants/theme";
import { useAuth } from "@/contexts/AuthContext";
import { Redirect, Slot } from "expo-router";
import { ActivityIndicator, View } from "react-native";

export default function AppLayout() {
    const { user, isLoading } = useAuth();

    if (isLoading) {
        return (
            <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: Colors.background }}>
                <ActivityIndicator size="large" color={Colors.primary} />
            </View>
        );
    }

    if (!user)
        return <Redirect href="/login" />;

    return <Slot />;
}