import {useGlobalContext} from "@/lib/globalProvider";
import {ActivityIndicator, SafeAreaView} from "react-native";
import React from "react";
import {Redirect, Slot} from "expo-router";

export default function AppLayout() {
    const { loading, isLoggedIn} = useGlobalContext();

    if (loading) {
        return (
            <SafeAreaView className={"bg-white h-full flex justify-center items-center"}>
                <ActivityIndicator className={"text-blue-500"} size={"large"}/>
            </SafeAreaView>
        )

    }
    if(!isLoggedIn) return <Redirect href={"/signin"}/>
    return <Slot/>
}