/**
* Root Layout
*
* Main app layout with authentication flow control
*/
import { useEffect } from 'react';
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import * as SplashScreen from 'expo-splash-screen';
import { useAuthStore } from '@/stores';
// Keep splash screen visible while loading
SplashScreen.preventAutoHideAsync();
export default function RootLayout() {
const { isLoading, isAuthenticated, loadStoredAuth } = useAuthStore();
useEffect(() => {
// Load stored authentication on app start
loadStoredAuth();
}, []);
useEffect(() => {
// Hide splash screen when loading is complete
if (!isLoading) {
SplashScreen.hideAsync();
}
}, [isLoading]);
// Show nothing while loading (splash screen is visible)
if (isLoading) {
return null;
}
return (
<>
{!isAuthenticated ? (
// Auth screens
) : (
// Main app screens
)}
>
);
}