xref: /MusicFree/src/entry/index.tsx (revision 6cfecf1cdd150fc94c5ad42fede7d65068b9ea40)
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 {DarkTheme, 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';
19import globalStyle from '@/constants/globalStyle';
20
21/**
22 * 字体颜色
23 */
24
25bootstrap();
26const Stack = createNativeStackNavigator<any>();
27
28export default function Pages() {
29    const themeName = Config.useConfig('setting.theme.mode') ?? 'dark';
30    const themeColors = Config.useConfig('setting.theme.colors') ?? {};
31    const theme = true ? DarkTheme : DefaultTheme;
32    const isCustom = themeName.includes('custom') ? true : false;
33    const mergedTheme = isCustom
34        ? {
35              ...theme,
36              colors: {
37                  ...theme.colors,
38                  ...themeColors,
39              },
40          }
41        : theme;
42
43    useBootstrap();
44
45    return (
46        <GestureHandlerRootView style={globalStyle.flex1}>
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                    <PortalHost />
74                </NavigationContainer>
75            </SafeAreaProvider>
76        </GestureHandlerRootView>
77    );
78}
79