import { Stack } from "expo-router"; import { Inter_400Regular, Inter_500Medium, Inter_600SemiBold, Inter_700Bold, } from "@expo-google-fonts/inter"; import { PlayfairDisplay_600SemiBold, PlayfairDisplay_700Bold, } from "@expo-google-fonts/playfair-display"; import { useFonts } from "expo-font"; import * as SplashScreen from "expo-splash-screen"; import { useEffect, type ReactNode } from "react"; import { View } from "react-native"; import { StatusBar } from "expo-status-bar"; import "react-native-reanimated"; import { SafeAreaProvider } from "react-native-safe-area-context"; import { BrandBackground } from "@/components/BrandBackground"; import { LoadingScreen } from "@/components/LoadingScreen"; import { SessionSync } from "@/components/SessionSync"; import { ShortcutLinkCapture } from "@/components/ShortcutLinkCapture"; import { AccountsProvider, useAccounts } from "@/contexts/AccountsContext"; import { AuthProvider, useSession } from "@/contexts/AuthContext"; import { ThemeProvider, useAppTheme } from "@/contexts/ThemeContext"; import { TRPCProvider } from "@/lib/trpc"; export { ErrorBoundary } from "expo-router"; SplashScreen.preventAutoHideAsync(); function AppServices({ children }: { children: ReactNode }) { const { apiUrl, authStoragePrefix, activeAccountId } = useAccounts(); const remountKey = `${activeAccountId ?? "guest"}:${apiUrl}`; return ( {children} ); } function ThemedChrome({ children }: { children: ReactNode }) { const { isDark } = useAppTheme(); return ( {children} ); } export default function RootLayout() { const [loaded, error] = useFonts({ SpaceMono: require("../assets/fonts/SpaceMono-Regular.ttf"), Inter_400Regular, Inter_500Medium, Inter_600SemiBold, Inter_700Bold, PlayfairDisplay_600SemiBold, PlayfairDisplay_700Bold, }); useEffect(() => { if (error) throw error; }, [error]); useEffect(() => { if (loaded) { SplashScreen.hideAsync(); } }, [loaded]); if (!loaded) { return null; } return ( ); } function RootNavigator() { const { data: session, isPending, error } = useSession(); if (isPending) { return ; } const isAuthenticated = Boolean(session?.user) && !error; return ( ); }