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, DarkTheme, DefaultTheme} from './theme'; 14import {useConfig} from '@/common/localConfigManager'; 15import Share from '@/components/share'; 16import PageBackground from '@/components/pageBackground'; 17import RNBootSplash from 'react-native-bootsplash'; 18import logManager from '@/common/logManager'; 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 === 'dark' ? CustomTheme : DefaultTheme; 31 const mergedTheme = { 32 ...theme, 33 colors: { 34 ...theme.colors, 35 ...themeColors, 36 }, 37 }; 38 useEffect(() => { 39 if (__DEV__) { 40 RNBootSplash.hide({fade: true}); 41 logManager.error('TEST'); 42 } 43 }, []); 44 45 return ( 46 <GestureHandlerRootView style={{flex: 1}}> 47 <PaperProvider theme={mergedTheme}> 48 <NavigationContainer theme={mergedTheme}> 49 <PageBackground></PageBackground> 50 <Stack.Navigator 51 initialRouteName={routes[0].path} 52 screenOptions={{ 53 statusBarColor: 'transparent', 54 statusBarTranslucent: true, 55 headerShown: false, 56 animation: 'slide_from_right', 57 animationDuration: 200, 58 }}> 59 {routes.map(route => ( 60 <Stack.Screen 61 key={route.path} 62 name={route.path} 63 component={route.component}></Stack.Screen> 64 ))} 65 </Stack.Navigator> 66 67 <Panels></Panels> 68 <Dialogs></Dialogs> 69 <Share></Share> 70 <Toast></Toast> 71 </NavigationContainer> 72 </PaperProvider> 73 </GestureHandlerRootView> 74 ); 75} 76 77const style = StyleSheet.create({ 78 blur: { 79 width: '100%', 80 height: '100%', 81 position: 'absolute', 82 top: 0, 83 left: 0, 84 right: 0, 85 bottom: 0, 86 }, 87}); 88