xref: /MusicFree/src/entry/index.tsx (revision e22d5e4f85cc635e62cd81a872a6b85f645cb2fb)
1e3c48069S猫头猫import React, {useEffect} from 'react';
2bf6e62f2S猫头猫import {Image, StyleSheet} from 'react-native';
3bf6e62f2S猫头猫
4bf6e62f2S猫头猫import {NavigationContainer} from '@react-navigation/native';
5bf6e62f2S猫头猫import {createNativeStackNavigator} from '@react-navigation/native-stack';
6bf6e62f2S猫头猫import bootstrap from './bootstrap';
703f1f70cS猫头猫import {RootStackParamList, routes} from './router';
8bf6e62f2S猫头猫import {Provider as PaperProvider} from 'react-native-paper';
9bf6e62f2S猫头猫import {GestureHandlerRootView} from 'react-native-gesture-handler';
10bf6e62f2S猫头猫import Dialogs from '@/components/dialogs';
11bf6e62f2S猫头猫import Toast from 'react-native-toast-message';
12bf6e62f2S猫头猫import Panels from '@/components/panels';
1308a8e62cS猫头猫import {CustomTheme, DefaultTheme} from './theme';
14*e22d5e4fS猫头猫import Config from '@/core/config';
15d1f226e6S猫头猫import Share from '@/components/share';
1619dc08ecS猫头猫import PageBackground from '@/components/base/pageBackground';
171c06c799S猫头猫import {SafeAreaProvider} from 'react-native-safe-area-context';
18bf6e62f2S猫头猫
19bf6e62f2S猫头猫/**
20bf6e62f2S猫头猫 * 字体颜色
21bf6e62f2S猫头猫 */
22bf6e62f2S猫头猫
23bf6e62f2S猫头猫bootstrap();
2403f1f70cS猫头猫const Stack = createNativeStackNavigator<RootStackParamList>();
25bf6e62f2S猫头猫
26bf6e62f2S猫头猫export default function Pages() {
27*e22d5e4fS猫头猫  const themeName = Config.useConfig('setting.theme.mode') ?? 'dark';
28*e22d5e4fS猫头猫  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猫头猫
41bf6e62f2S猫头猫  return (
42bf6e62f2S猫头猫    <GestureHandlerRootView style={{flex: 1}}>
430d39db21S猫头猫      <PaperProvider theme={mergedTheme}>
441c06c799S猫头猫        <SafeAreaProvider>
450d39db21S猫头猫          <NavigationContainer theme={mergedTheme}>
4665fc5a50S猫头猫            <PageBackground></PageBackground>
47bf6e62f2S猫头猫            <Stack.Navigator
48bf6e62f2S猫头猫              initialRouteName={routes[0].path}
49bf6e62f2S猫头猫              screenOptions={{
50bf6e62f2S猫头猫                statusBarColor: 'transparent',
51bf6e62f2S猫头猫                statusBarTranslucent: true,
52bf6e62f2S猫头猫                headerShown: false,
53bf6e62f2S猫头猫                animation: 'slide_from_right',
54bf6e62f2S猫头猫                animationDuration: 200,
55bf6e62f2S猫头猫              }}>
56bf6e62f2S猫头猫              {routes.map(route => (
57bf6e62f2S猫头猫                <Stack.Screen
58bf6e62f2S猫头猫                  key={route.path}
59bf6e62f2S猫头猫                  name={route.path}
60bf6e62f2S猫头猫                  component={route.component}></Stack.Screen>
61bf6e62f2S猫头猫              ))}
62bf6e62f2S猫头猫            </Stack.Navigator>
63bf6e62f2S猫头猫
64bf6e62f2S猫头猫            <Panels></Panels>
65bf6e62f2S猫头猫            <Dialogs></Dialogs>
66d1f226e6S猫头猫            <Share></Share>
67bf6e62f2S猫头猫            <Toast></Toast>
68bf6e62f2S猫头猫          </NavigationContainer>
691c06c799S猫头猫        </SafeAreaProvider>
70bf6e62f2S猫头猫      </PaperProvider>
71bf6e62f2S猫头猫    </GestureHandlerRootView>
72bf6e62f2S猫头猫  );
73bf6e62f2S猫头猫}
74bf6e62f2S猫头猫
75bf6e62f2S猫头猫const style = StyleSheet.create({
76bf6e62f2S猫头猫  blur: {
77bf6e62f2S猫头猫    width: '100%',
78bf6e62f2S猫头猫    height: '100%',
79bf6e62f2S猫头猫    position: 'absolute',
80bf6e62f2S猫头猫    top: 0,
81bf6e62f2S猫头猫    left: 0,
82bf6e62f2S猫头猫    right: 0,
83bf6e62f2S猫头猫    bottom: 0,
84bf6e62f2S猫头猫  },
85bf6e62f2S猫头猫});
86