import { Poppins_400Regular, Poppins_500Medium, Poppins_600SemiBold, useFonts } from '@expo-google-fonts/poppins'; import { DarkTheme, Stack, ThemeProvider } from 'expo-router'; import * as SplashScreen from 'expo-splash-screen'; import { StatusBar } from 'expo-status-bar'; import { useEffect } from 'react'; import { AppState, StyleSheet, View } from 'react-native'; import useSWR, { SWRConfig } from 'swr'; import type { ConnectionDTO } from '@musicshare/shared'; import { Body, Button, Title } from '@/components/ui'; import { api } from '@/lib/api'; import { appleMusicAvailable, useAppleMusicLive } from '@/lib/appleMusic'; import { syncDevice } from '@/lib/nowPlayingReader'; import { syncPush } from '@/lib/push'; import { SessionProvider, useSession } from '@/lib/session'; import { startUpdater } from '@/lib/updates'; import { colors, space } from '@/lib/theme'; SplashScreen.preventAutoHideAsync(); const theme = { ...DarkTheme, colors: { ...DarkTheme.colors, background: colors.bg, card: colors.bg, text: colors.text, primary: colors.accent, border: colors.border }, }; export default function RootLayout() { return ( ); } function AppNavigator() { const { status, me, retry } = useSession(); const signedIn = status === 'signedIn'; const onboarded = Boolean(me?.onboardedAt); const [fontsLoaded, fontError] = useFonts({ Poppins_400Regular, Poppins_500Medium, Poppins_600SemiBold }); const ready = status !== 'loading' && (fontsLoaded || Boolean(fontError)); useEffect(() => { if (ready) SplashScreen.hideAsync(); }, [ready]); // Look for a newer version of the app (our own APKs only; see lib/updates.ts). useEffect(() => { if (ready) startUpdater(); }, [ready]); // Keep the Android listener pointed at this account (no-op elsewhere). useEffect(() => { if (signedIn) syncDevice().catch(() => {}); if (signedIn) syncPush().catch(() => {}); }, [signedIn]); if (!ready) return null; if (status === 'offline') { return ( Can't reach musicshare Check your connection and try again.