xref: /MusicFree/src/entry/index.tsx (revision 4060c00a75883036bbd315fb25c90065209312b3)
1import React from 'react';
2import {NavigationContainer} from '@react-navigation/native';
3import {createNativeStackNavigator} from '@react-navigation/native-stack';
4import bootstrap from './bootstrap';
5import {RootStackParamList, 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 Share from '@/components/share';
14import PageBackground from '@/components/base/pageBackground';
15import {SafeAreaProvider} from 'react-native-safe-area-context';
16
17/**
18 * 字体颜色
19 */
20
21bootstrap();
22const Stack = createNativeStackNavigator<RootStackParamList>();
23
24export default function Pages() {
25    const themeName = Config.useConfig('setting.theme.mode') ?? 'dark';
26    const themeColors = Config.useConfig('setting.theme.colors') ?? {};
27    const theme = themeName.includes('dark') ? CustomTheme : DefaultTheme;
28    const isCustom = themeName.includes('custom') ? true : false;
29    const mergedTheme = isCustom
30        ? {
31              ...theme,
32              colors: {
33                  ...theme.colors,
34                  ...themeColors,
35              },
36          }
37        : theme;
38
39    return (
40        <GestureHandlerRootView style={{flex: 1}}>
41            <PaperProvider theme={mergedTheme}>
42                <SafeAreaProvider>
43                    <NavigationContainer theme={mergedTheme}>
44                        <PageBackground />
45                        <Stack.Navigator
46                            initialRouteName={routes[0].path}
47                            screenOptions={{
48                                statusBarColor: 'transparent',
49                                statusBarTranslucent: true,
50                                headerShown: false,
51                                animation: 'slide_from_right',
52                                animationDuration: 200,
53                            }}>
54                            {routes.map(route => (
55                                <Stack.Screen
56                                    key={route.path}
57                                    name={route.path}
58                                    component={route.component}
59                                />
60                            ))}
61                        </Stack.Navigator>
62
63                        <Panels />
64                        <Dialogs />
65                        <Share />
66                        <Toast />
67                    </NavigationContainer>
68                </SafeAreaProvider>
69            </PaperProvider>
70        </GestureHandlerRootView>
71    );
72}
73