- Create VoiceCallContext for global voice call state management - Add FloatingCallBubble component with drag support - Add minimize button to voice call screen - Show bubble when call is minimized, tap to return to call - Button shows active call state with green color 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
79 lines
2.6 KiB
TypeScript
79 lines
2.6 KiB
TypeScript
// WebRTC globals are now registered in useLiveKitRoom hook
|
|
// before any LiveKit classes are loaded.
|
|
|
|
import { useEffect } from 'react';
|
|
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';
|
|
import { Stack, router, useSegments } from 'expo-router';
|
|
import { StatusBar } from 'expo-status-bar';
|
|
import * as SplashScreen from 'expo-splash-screen';
|
|
import 'react-native-reanimated';
|
|
import { KeyboardProvider } from 'react-native-keyboard-controller';
|
|
|
|
import { useColorScheme } from '@/hooks/use-color-scheme';
|
|
import { AuthProvider, useAuth } from '@/contexts/AuthContext';
|
|
import { BeneficiaryProvider } from '@/contexts/BeneficiaryContext';
|
|
import { VoiceTranscriptProvider } from '@/contexts/VoiceTranscriptContext';
|
|
import { VoiceCallProvider } from '@/contexts/VoiceCallContext';
|
|
import { LoadingSpinner } from '@/components/ui/LoadingSpinner';
|
|
import { FloatingCallBubble } from '@/components/FloatingCallBubble';
|
|
|
|
// Prevent auto-hiding splash screen
|
|
SplashScreen.preventAutoHideAsync();
|
|
|
|
function RootLayoutNav() {
|
|
const colorScheme = useColorScheme();
|
|
const { isAuthenticated, isLoading } = useAuth();
|
|
const segments = useSegments();
|
|
|
|
useEffect(() => {
|
|
if (isLoading) return;
|
|
|
|
// Hide splash screen once we know auth state
|
|
SplashScreen.hideAsync();
|
|
|
|
const inAuthGroup = segments[0] === '(auth)';
|
|
|
|
if (!isAuthenticated && !inAuthGroup) {
|
|
// Redirect to login if not authenticated
|
|
router.replace('/(auth)/login');
|
|
} else if (isAuthenticated && inAuthGroup) {
|
|
// Redirect to main app if authenticated
|
|
router.replace('/(tabs)');
|
|
}
|
|
}, [isAuthenticated, isLoading, segments]);
|
|
|
|
if (isLoading) {
|
|
return <LoadingSpinner fullScreen message="Loading..." />;
|
|
}
|
|
|
|
return (
|
|
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
|
|
<Stack screenOptions={{ headerShown: false }}>
|
|
<Stack.Screen name="(auth)" />
|
|
<Stack.Screen name="(tabs)" />
|
|
<Stack.Screen name="modal" options={{ presentation: 'modal', title: 'Modal' }} />
|
|
<Stack.Screen name="terms" options={{ presentation: 'modal' }} />
|
|
<Stack.Screen name="privacy" options={{ presentation: 'modal' }} />
|
|
</Stack>
|
|
<FloatingCallBubble />
|
|
<StatusBar style="auto" />
|
|
</ThemeProvider>
|
|
);
|
|
}
|
|
|
|
export default function RootLayout() {
|
|
return (
|
|
<KeyboardProvider>
|
|
<AuthProvider>
|
|
<BeneficiaryProvider>
|
|
<VoiceTranscriptProvider>
|
|
<VoiceCallProvider>
|
|
<RootLayoutNav />
|
|
</VoiceCallProvider>
|
|
</VoiceTranscriptProvider>
|
|
</BeneficiaryProvider>
|
|
</AuthProvider>
|
|
</KeyboardProvider>
|
|
);
|
|
}
|