xref: /MusicFree/src/entry/index.tsx (revision fe40489c82ad666eb99ef7194b31d68bd0efef63)
1import React, {useEffect} from 'react';
2import {Image, StyleSheet} from 'react-native';
3
4import {NavigationContainer} from '@react-navigation/native';
5import {createNativeStackNavigator} from '@react-navigation/native-stack';
6import bootstrap from './bootstrap';
7import {routes} from './router';
8import {Provider as PaperProvider} from 'react-native-paper';
9import {GestureHandlerRootView} from 'react-native-gesture-handler';
10import Dialogs from '@/components/dialogs';
11import Toast from 'react-native-toast-message';
12import Panels from '@/components/panels';
13import {CustomTheme, DefaultTheme} from './theme';
14import {useConfig} from '@/common/localConfigManager';
15import Share from '@/components/share';
16import RNBootSplash from 'react-native-bootsplash';
17import logManager from '@/common/logManager';
18import PageBackground from '@/components/base/pageBackground';
19import {SafeAreaProvider} from 'react-native-safe-area-context';
20
21/**
22 * 字体颜色
23 */
24
25bootstrap();
26const Stack = createNativeStackNavigator();
27
28export default function Pages() {
29  const themeName = useConfig('setting.theme.mode') ?? 'dark';
30  const themeColors = useConfig('setting.theme.colors') ?? {};
31  const theme = themeName.includes('dark') ? CustomTheme : 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  useEffect(() => {
43    if (__DEV__) {
44      RNBootSplash.hide({fade: true});
45      logManager.error('TEST');
46    }
47    logManager.error('TEST111');
48  }, []);
49
50  return (
51    <GestureHandlerRootView style={{flex: 1}}>
52      <PaperProvider theme={mergedTheme}>
53        <SafeAreaProvider>
54          <NavigationContainer theme={mergedTheme}>
55            <PageBackground></PageBackground>
56            <Stack.Navigator
57              initialRouteName={routes[0].path}
58              screenOptions={{
59                statusBarColor: 'transparent',
60                statusBarTranslucent: true,
61                headerShown: false,
62                animation: 'slide_from_right',
63                animationDuration: 200,
64              }}>
65              {routes.map(route => (
66                <Stack.Screen
67                  key={route.path}
68                  name={route.path}
69                  component={route.component}></Stack.Screen>
70              ))}
71            </Stack.Navigator>
72
73            <Panels></Panels>
74            <Dialogs></Dialogs>
75            <Share></Share>
76            <Toast></Toast>
77          </NavigationContainer>
78        </SafeAreaProvider>
79      </PaperProvider>
80    </GestureHandlerRootView>
81  );
82}
83
84const style = StyleSheet.create({
85  blur: {
86    width: '100%',
87    height: '100%',
88    position: 'absolute',
89    top: 0,
90    left: 0,
91    right: 0,
92    bottom: 0,
93  },
94});
95