xref: /MusicFree/src/entry/index.tsx (revision 0d39db21c2f3b340b723d77ca311c5ce11dc2231)
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';
7bf6e62f2S猫头猫import {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';
13bf6e62f2S猫头猫import {CustomTheme, DarkTheme, DefaultTheme} from './theme';
14bf6e62f2S猫头猫import {useConfig} from '@/common/localConfigManager';
15d1f226e6S猫头猫import Share from '@/components/share';
1665fc5a50S猫头猫import PageBackground from '@/components/pageBackground';
17*0d39db21S猫头猫import RNBootSplash from 'react-native-bootsplash';
18*0d39db21S猫头猫import logManager from '@/common/logManager';
19bf6e62f2S猫头猫
20bf6e62f2S猫头猫/**
21bf6e62f2S猫头猫 * 字体颜色
22bf6e62f2S猫头猫 */
23bf6e62f2S猫头猫
24bf6e62f2S猫头猫bootstrap();
25bf6e62f2S猫头猫const Stack = createNativeStackNavigator();
26bf6e62f2S猫头猫
27bf6e62f2S猫头猫export default function Pages() {
28*0d39db21S猫头猫  const themeName = useConfig('setting.theme.mode') ?? 'dark';
29*0d39db21S猫头猫  const themeColors = useConfig('setting.theme.colors') ?? {};
30*0d39db21S猫头猫  const theme = themeName === 'dark' ? CustomTheme : DefaultTheme;
31*0d39db21S猫头猫  const mergedTheme = {
32*0d39db21S猫头猫    ...theme,
33*0d39db21S猫头猫    colors: {
34*0d39db21S猫头猫      ...theme.colors,
35*0d39db21S猫头猫      ...themeColors,
36*0d39db21S猫头猫    },
37*0d39db21S猫头猫  };
38e3c48069S猫头猫  useEffect(() => {
39e3c48069S猫头猫    if (__DEV__) {
40e3c48069S猫头猫      RNBootSplash.hide({fade: true});
41*0d39db21S猫头猫      logManager.error('TEST');
42e3c48069S猫头猫    }
43e3c48069S猫头猫  }, []);
44bf6e62f2S猫头猫
45bf6e62f2S猫头猫  return (
46bf6e62f2S猫头猫    <GestureHandlerRootView style={{flex: 1}}>
47*0d39db21S猫头猫      <PaperProvider theme={mergedTheme}>
48*0d39db21S猫头猫        <NavigationContainer theme={mergedTheme}>
4965fc5a50S猫头猫          <PageBackground></PageBackground>
50bf6e62f2S猫头猫          <Stack.Navigator
51bf6e62f2S猫头猫            initialRouteName={routes[0].path}
52bf6e62f2S猫头猫            screenOptions={{
53bf6e62f2S猫头猫              statusBarColor: 'transparent',
54bf6e62f2S猫头猫              statusBarTranslucent: true,
55bf6e62f2S猫头猫              headerShown: false,
56bf6e62f2S猫头猫              animation: 'slide_from_right',
57bf6e62f2S猫头猫              animationDuration: 200,
58bf6e62f2S猫头猫            }}>
59bf6e62f2S猫头猫            {routes.map(route => (
60bf6e62f2S猫头猫              <Stack.Screen
61bf6e62f2S猫头猫                key={route.path}
62bf6e62f2S猫头猫                name={route.path}
63bf6e62f2S猫头猫                component={route.component}></Stack.Screen>
64bf6e62f2S猫头猫            ))}
65bf6e62f2S猫头猫          </Stack.Navigator>
66bf6e62f2S猫头猫
67bf6e62f2S猫头猫          <Panels></Panels>
68bf6e62f2S猫头猫          <Dialogs></Dialogs>
69d1f226e6S猫头猫          <Share></Share>
70bf6e62f2S猫头猫          <Toast></Toast>
71bf6e62f2S猫头猫        </NavigationContainer>
72bf6e62f2S猫头猫      </PaperProvider>
73bf6e62f2S猫头猫    </GestureHandlerRootView>
74bf6e62f2S猫头猫  );
75bf6e62f2S猫头猫}
76bf6e62f2S猫头猫
77bf6e62f2S猫头猫const style = StyleSheet.create({
78bf6e62f2S猫头猫  blur: {
79bf6e62f2S猫头猫    width: '100%',
80bf6e62f2S猫头猫    height: '100%',
81bf6e62f2S猫头猫    position: 'absolute',
82bf6e62f2S猫头猫    top: 0,
83bf6e62f2S猫头猫    left: 0,
84bf6e62f2S猫头猫    right: 0,
85bf6e62f2S猫头猫    bottom: 0,
86bf6e62f2S猫头猫  },
87bf6e62f2S猫头猫});
88