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 {GestureHandlerRootView} from 'react-native-gesture-handler'; 7import Dialogs from '@/components/dialogs'; 8import Toast from 'react-native-toast-message'; 9import Panels from '@/components/panels'; 10import {CustomTheme, DefaultTheme} from './theme'; 11import Config from '@/core/config'; 12import PageBackground from '@/components/base/pageBackground'; 13import {SafeAreaProvider} from 'react-native-safe-area-context'; 14import toastConfig from '@/components/base/toast'; 15import useBootstrap from './useBootstrap'; 16import Debug from '@/components/debug'; 17import {ImageViewComponent} from '@/components/imageViewer'; 18import {PortalHost} from '@/components/base/portal'; 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 <SafeAreaProvider> 47 <NavigationContainer theme={mergedTheme}> 48 <PageBackground /> 49 <Stack.Navigator 50 initialRouteName={routes[0].path} 51 screenOptions={{ 52 statusBarColor: 'transparent', 53 statusBarTranslucent: true, 54 headerShown: false, 55 animation: 'slide_from_right', 56 animationDuration: 100, 57 }}> 58 {routes.map(route => ( 59 <Stack.Screen 60 key={route.path} 61 name={route.path} 62 component={route.component} 63 /> 64 ))} 65 </Stack.Navigator> 66 67 <Panels /> 68 <Dialogs /> 69 <ImageViewComponent /> 70 <Toast config={toastConfig} /> 71 <Debug /> 72 <PortalHost /> 73 </NavigationContainer> 74 </SafeAreaProvider> 75 </GestureHandlerRootView> 76 ); 77} 78