1import React from 'react'; 2import {NavigationContainer} from '@react-navigation/native'; 3import {createNativeStackNavigator} from '@react-navigation/native-stack'; 4import bootstrap from './bootstrap'; 5import {routes} from './router'; 6import {Provider as PaperProvider} from 'react-native-paper'; 7import {GestureHandlerRootView} from 'react-native-gesture-handler'; 8import Dialogs from '@/components/dialogs'; 9import Toast from 'react-native-toast-message'; 10import Panels from '@/components/panels'; 11import {CustomTheme, DefaultTheme} from './theme'; 12import Config from '@/core/config'; 13import PageBackground from '@/components/base/pageBackground'; 14import {SafeAreaProvider} from 'react-native-safe-area-context'; 15import toastConfig from '@/components/base/toast'; 16import useBootstrap from './useBootstrap'; 17import Debug from '@/components/debug'; 18import {ImageViewComponent} from '@/components/imageViewer'; 19 20/** 21 * 字体颜色 22 */ 23 24bootstrap(); 25const Stack = createNativeStackNavigator<any>(); 26 27export default function Pages() { 28 const themeName = Config.useConfig('setting.theme.mode') ?? 'dark'; 29 const themeColors = Config.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 42 useBootstrap(); 43 44 return ( 45 <GestureHandlerRootView style={{flex: 1}}> 46 <PaperProvider theme={mergedTheme}> 47 <SafeAreaProvider> 48 <NavigationContainer theme={mergedTheme}> 49 <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: 100, 58 }}> 59 {routes.map(route => ( 60 <Stack.Screen 61 key={route.path} 62 name={route.path} 63 component={route.component} 64 /> 65 ))} 66 </Stack.Navigator> 67 68 <Panels /> 69 <Dialogs /> 70 <ImageViewComponent /> 71 <Toast config={toastConfig} /> 72 <Debug /> 73 </NavigationContainer> 74 </SafeAreaProvider> 75 </PaperProvider> 76 </GestureHandlerRootView> 77 ); 78} 79