1import React, {useEffect} from 'react'; 2import {Image, StyleSheet} from 'react-native'; 3 4import {NavigationContainer} from '@react-navigation/native'; 5import {createNativeStackNavigator} from '@react-navigation/native-stack'; 6import bootstrap from './bootstrap'; 7import {routes} from './router'; 8import {Provider as PaperProvider} from 'react-native-paper'; 9import {GestureHandlerRootView} from 'react-native-gesture-handler'; 10import Dialogs from '@/components/dialogs'; 11import Toast from 'react-native-toast-message'; 12import Panels from '@/components/panels'; 13import {CustomTheme, DefaultTheme} from './theme'; 14import {useConfig} from '@/common/localConfigManager'; 15import Share from '@/components/share'; 16import RNBootSplash from 'react-native-bootsplash'; 17import PageBackground from '@/components/base/pageBackground'; 18import {SafeAreaProvider} from 'react-native-safe-area-context'; 19 20/** 21 * 字体颜色 22 */ 23 24bootstrap(); 25const Stack = createNativeStackNavigator(); 26 27export default function Pages() { 28 const themeName = useConfig('setting.theme.mode') ?? 'dark'; 29 const themeColors = useConfig('setting.theme.colors') ?? {}; 30 const theme = themeName.includes('dark') ? CustomTheme : DefaultTheme; 31 const isCustom = themeName.includes('custom') ? true : false; 32 const mergedTheme = isCustom 33 ? { 34 ...theme, 35 colors: { 36 ...theme.colors, 37 ...themeColors, 38 }, 39 } 40 : theme; 41 useEffect(() => { 42 if (__DEV__) { 43 RNBootSplash.hide({fade: true}); 44 } 45 }, []); 46 47 return ( 48 <GestureHandlerRootView style={{flex: 1}}> 49 <PaperProvider theme={mergedTheme}> 50 <SafeAreaProvider> 51 <NavigationContainer theme={mergedTheme}> 52 <PageBackground></PageBackground> 53 <Stack.Navigator 54 initialRouteName={routes[0].path} 55 screenOptions={{ 56 statusBarColor: 'transparent', 57 statusBarTranslucent: true, 58 headerShown: false, 59 animation: 'slide_from_right', 60 animationDuration: 200, 61 }}> 62 {routes.map(route => ( 63 <Stack.Screen 64 key={route.path} 65 name={route.path} 66 component={route.component}></Stack.Screen> 67 ))} 68 </Stack.Navigator> 69 70 <Panels></Panels> 71 <Dialogs></Dialogs> 72 <Share></Share> 73 <Toast></Toast> 74 </NavigationContainer> 75 </SafeAreaProvider> 76 </PaperProvider> 77 </GestureHandlerRootView> 78 ); 79} 80 81const style = StyleSheet.create({ 82 blur: { 83 width: '100%', 84 height: '100%', 85 position: 'absolute', 86 top: 0, 87 left: 0, 88 right: 0, 89 bottom: 0, 90 }, 91}); 92