xref: /MusicFree/src/entry/index.tsx (revision e7fa3837138cc7f9a5fa0fb610c27f442edfacc2)
14060c00aS猫头猫import React from 'react';
2bf6e62f2S猫头猫import {NavigationContainer} from '@react-navigation/native';
3bf6e62f2S猫头猫import {createNativeStackNavigator} from '@react-navigation/native-stack';
4bf6e62f2S猫头猫import bootstrap from './bootstrap';
5*e7fa3837S猫头猫import {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';
162a3194f5S猫头猫import toastConfig from '@/components/base/toast';
17cf2d630eS猫头猫import useBootstrap from './useBootstrap';
18bf6e62f2S猫头猫
19bf6e62f2S猫头猫/**
20bf6e62f2S猫头猫 * 字体颜色
21bf6e62f2S猫头猫 */
22bf6e62f2S猫头猫
23bf6e62f2S猫头猫bootstrap();
24*e7fa3837S猫头猫const Stack = createNativeStackNavigator<any>();
25bf6e62f2S猫头猫
26bf6e62f2S猫头猫export default function Pages() {
27e22d5e4fS猫头猫    const themeName = Config.useConfig('setting.theme.mode') ?? 'dark';
28e22d5e4fS猫头猫    const themeColors = Config.useConfig('setting.theme.colors') ?? {};
29c7676810S猫头猫    const theme = themeName.includes('dark') ? CustomTheme : DefaultTheme;
30c7676810S猫头猫    const isCustom = themeName.includes('custom') ? true : false;
31c7676810S猫头猫    const mergedTheme = isCustom
32c7676810S猫头猫        ? {
330d39db21S猫头猫              ...theme,
340d39db21S猫头猫              colors: {
350d39db21S猫头猫                  ...theme.colors,
360d39db21S猫头猫                  ...themeColors,
370d39db21S猫头猫              },
38c7676810S猫头猫          }
39c7676810S猫头猫        : theme;
40bf6e62f2S猫头猫
41cf2d630eS猫头猫    useBootstrap();
42cf2d630eS猫头猫
43bf6e62f2S猫头猫    return (
44bf6e62f2S猫头猫        <GestureHandlerRootView style={{flex: 1}}>
450d39db21S猫头猫            <PaperProvider theme={mergedTheme}>
461c06c799S猫头猫                <SafeAreaProvider>
470d39db21S猫头猫                    <NavigationContainer theme={mergedTheme}>
484060c00aS猫头猫                        <PageBackground />
49bf6e62f2S猫头猫                        <Stack.Navigator
50bf6e62f2S猫头猫                            initialRouteName={routes[0].path}
51bf6e62f2S猫头猫                            screenOptions={{
52bf6e62f2S猫头猫                                statusBarColor: 'transparent',
53bf6e62f2S猫头猫                                statusBarTranslucent: true,
54bf6e62f2S猫头猫                                headerShown: false,
55bf6e62f2S猫头猫                                animation: 'slide_from_right',
56bf6e62f2S猫头猫                                animationDuration: 200,
57bf6e62f2S猫头猫                            }}>
58bf6e62f2S猫头猫                            {routes.map(route => (
59bf6e62f2S猫头猫                                <Stack.Screen
60bf6e62f2S猫头猫                                    key={route.path}
61bf6e62f2S猫头猫                                    name={route.path}
624060c00aS猫头猫                                    component={route.component}
634060c00aS猫头猫                                />
64bf6e62f2S猫头猫                            ))}
65bf6e62f2S猫头猫                        </Stack.Navigator>
66bf6e62f2S猫头猫
674060c00aS猫头猫                        <Panels />
684060c00aS猫头猫                        <Dialogs />
694060c00aS猫头猫                        <Share />
702a3194f5S猫头猫                        <Toast config={toastConfig} />
71bf6e62f2S猫头猫                    </NavigationContainer>
721c06c799S猫头猫                </SafeAreaProvider>
73bf6e62f2S猫头猫            </PaperProvider>
74bf6e62f2S猫头猫        </GestureHandlerRootView>
75bf6e62f2S猫头猫    );
76bf6e62f2S猫头猫}
77