Files
JKVideo/app/_layout.tsx

89 lines
2.7 KiB
TypeScript
Raw Normal View History

2026-03-10 19:04:18 +08:00
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
2026-03-06 12:58:41 +08:00
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { Text, View } from 'react-native';
import { useEffect } from 'react';
import { useAuthStore } from '../store/authStore';
2026-03-17 22:18:05 +08:00
import { useDownloadStore } from '../store/downloadStore';
2026-03-19 16:34:56 +08:00
import { useSettingsStore } from '../store/settingsStore';
import { useTheme } from '../utils/theme';
2026-03-10 19:04:18 +08:00
import { MiniPlayer } from '../components/MiniPlayer';
import * as Sentry from '@sentry/react-native';
import { ErrorBoundary } from '@sentry/react-native';
Sentry.init({
dsn: process.env.EXPO_PUBLIC_SENTRY_DSN ?? '',
enabled: !__DEV__,
tracesSampleRate: 0.05,
environment: process.env.EXPO_PUBLIC_APP_ENV ?? 'production',
});
function RootLayout() {
const restore = useAuthStore(s => s.restore);
2026-03-17 22:18:05 +08:00
const loadDownloads = useDownloadStore(s => s.loadFromStorage);
2026-03-19 16:34:56 +08:00
const restoreSettings = useSettingsStore(s => s.restore);
const darkMode = useSettingsStore(s => s.darkMode);
useEffect(() => {
restore();
2026-03-17 22:18:05 +08:00
loadDownloads();
2026-03-19 16:34:56 +08:00
restoreSettings();
}, []);
return (
2026-03-06 12:58:41 +08:00
<SafeAreaProvider>
<StatusBar style={darkMode ? 'light' : 'dark'} />
2026-03-10 19:04:18 +08:00
<View style={{ flex: 1 }}>
<ErrorBoundary fallback={<Text style={{ padding: 32, textAlign: 'center' }}> App</Text>}>
<Stack screenOptions={{ headerShown: false }}>
<Stack.Screen name="index" />
<Stack.Screen
name="video"
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="live"
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="search"
options={{
animation: "slide_from_right",
gestureEnabled: true,
}}
/>
<Stack.Screen
name="downloads"
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
<Stack.Screen
name="settings"
options={{
animation: "slide_from_right",
gestureEnabled: true,
gestureDirection: "horizontal",
}}
/>
</Stack>
</ErrorBoundary>
2026-03-10 19:04:18 +08:00
<MiniPlayer />
</View>
2026-03-06 12:58:41 +08:00
</SafeAreaProvider>
);
}
export default Sentry.wrap(RootLayout);