xref: /MusicFree/src/entry/index.tsx (revision 4060c00a75883036bbd315fb25c90065209312b3)
1*4060c00aS猫头猫import React from 'react';
2bf6e62f2S猫头猫import {NavigationContainer} from '@react-navigation/native';
3bf6e62f2S猫头猫import {createNativeStackNavigator} from '@react-navigation/native-stack';
4bf6e62f2S猫头猫import bootstrap from './bootstrap';
503f1f70cS猫头猫import {RootStackParamList, routes} from './router';
6bf6e62f2S猫头猫import {Provider as PaperProvider} from 'react-native-paper';
7bf6e62f2S猫头猫import {GestureHandlerRootView} from 'react-native-gesture-handler';
8bf6e62f2S猫头猫import Dialogs from '@/components/dialogs';
9bf6e62f2S猫头猫import Toast from 'react-native-toast-message';
10bf6e62f2S猫头猫import Panels from '@/components/panels';
1108a8e62cS猫头猫import {CustomTheme, DefaultTheme} from './theme';
12e22d5e4fS猫头猫import Config from '@/core/config';
13d1f226e6S猫头猫import Share from '@/components/share';
1419dc08ecS猫头猫import PageBackground from '@/components/base/pageBackground';
151c06c799S猫头猫import {SafeAreaProvider} from 'react-native-safe-area-context';
16bf6e62f2S猫头猫
17bf6e62f2S猫头猫/**
18bf6e62f2S猫头猫 * 字体颜色
19bf6e62f2S猫头猫 */
20bf6e62f2S猫头猫
21bf6e62f2S猫头猫bootstrap();
2203f1f70cS猫头猫const Stack = createNativeStackNavigator<RootStackParamList>();
23bf6e62f2S猫头猫
24bf6e62f2S猫头猫export default function Pages() {
25e22d5e4fS猫头猫    const themeName = Config.useConfig('setting.theme.mode') ?? 'dark';
26e22d5e4fS猫头猫    const themeColors = Config.useConfig('setting.theme.colors') ?? {};
27c7676810S猫头猫    const theme = themeName.includes('dark') ? CustomTheme : DefaultTheme;
28c7676810S猫头猫    const isCustom = themeName.includes('custom') ? true : false;
29c7676810S猫头猫    const mergedTheme = isCustom
30c7676810S猫头猫        ? {
310d39db21S猫头猫              ...theme,
320d39db21S猫头猫              colors: {
330d39db21S猫头猫                  ...theme.colors,
340d39db21S猫头猫                  ...themeColors,
350d39db21S猫头猫              },
36c7676810S猫头猫          }
37c7676810S猫头猫        : theme;
38bf6e62f2S猫头猫
39bf6e62f2S猫头猫    return (
40bf6e62f2S猫头猫        <GestureHandlerRootView style={{flex: 1}}>
410d39db21S猫头猫            <PaperProvider theme={mergedTheme}>
421c06c799S猫头猫                <SafeAreaProvider>
430d39db21S猫头猫                    <NavigationContainer theme={mergedTheme}>
44*4060c00aS猫头猫                        <PageBackground />
45bf6e62f2S猫头猫                        <Stack.Navigator
46bf6e62f2S猫头猫                            initialRouteName={routes[0].path}
47bf6e62f2S猫头猫                            screenOptions={{
48bf6e62f2S猫头猫                                statusBarColor: 'transparent',
49bf6e62f2S猫头猫                                statusBarTranslucent: true,
50bf6e62f2S猫头猫                                headerShown: false,
51bf6e62f2S猫头猫                                animation: 'slide_from_right',
52bf6e62f2S猫头猫                                animationDuration: 200,
53bf6e62f2S猫头猫                            }}>
54bf6e62f2S猫头猫                            {routes.map(route => (
55bf6e62f2S猫头猫                                <Stack.Screen
56bf6e62f2S猫头猫                                    key={route.path}
57bf6e62f2S猫头猫                                    name={route.path}
58*4060c00aS猫头猫                                    component={route.component}
59*4060c00aS猫头猫                                />
60bf6e62f2S猫头猫                            ))}
61bf6e62f2S猫头猫                        </Stack.Navigator>
62bf6e62f2S猫头猫
63*4060c00aS猫头猫                        <Panels />
64*4060c00aS猫头猫                        <Dialogs />
65*4060c00aS猫头猫                        <Share />
66*4060c00aS猫头猫                        <Toast />
67bf6e62f2S猫头猫                    </NavigationContainer>
681c06c799S猫头猫                </SafeAreaProvider>
69bf6e62f2S猫头猫            </PaperProvider>
70bf6e62f2S猫头猫        </GestureHandlerRootView>
71bf6e62f2S猫头猫    );
72bf6e62f2S猫头猫}
73