import { DarkTheme, Stack, ThemeProvider } from "expo-router"; import { StatusBar } from "expo-status-bar"; import { useEffect, useMemo, useState } from "react"; import { View } from "react-native"; import { GestureHandlerRootView } from "react-native-gesture-handler"; import { KeyboardProvider } from "react-native-keyboard-controller"; import { ComputerUpdateProgress } from "../components/computer-update-progress"; import { currentApiBase, loadApiBase, loadSessionToken, selectedSpaceId } from "../lib/api"; import { loadAppearancePreference, mobileTokens } from "../lib/appearance"; import { bootstrapI18n, useI18n } from "../lib/i18n"; import { configureForegroundNotifications, resumeLiveNotifications, } from "../lib/live-notifications"; import { native, useResolvedAppearance } from "../lib/native"; configureForegroundNotifications(); export default function Layout() { const { t } = useI18n(); const [ready, setReady] = useState(false); const resolved = useResolvedAppearance(); const navigationTheme = useMemo(() => { const tokens = mobileTokens(); return { ...DarkTheme, dark: resolved === "dark", colors: { ...DarkTheme.colors, background: tokens.background, card: tokens.background, text: tokens.foreground, border: tokens.border, primary: tokens.primary, notification: tokens.foreground, }, }; }, [resolved]); useEffect(() => { void Promise.all([ Promise.all([loadApiBase(), loadAppearancePreference()]) .then(async () => resumeLiveNotifications( currentApiBase(), await loadSessionToken(), selectedSpaceId() ?? "", ), ) .catch(() => undefined), bootstrapI18n(), ]).finally(() => setReady(true)); }, []); return ( {ready ? ( ) : ( )} ); }