xref: /MusicFree/src/entry/index.tsx (revision 1c06c79946b30f194df132a91b10963b5dd338bc)
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';
160d39db21S猫头猫import RNBootSplash from 'react-native-bootsplash';
170d39db21S猫头猫import logManager from '@/common/logManager';
18*1c06c799S猫头猫import PageBackground from '@/components/pageBackground';
19*1c06c799S猫头猫import {SafeAreaProvider} from 'react-native-safe-area-context';
20bf6e62f2S猫头猫
21bf6e62f2S猫头猫/**
22bf6e62f2S猫头猫 * 字体颜色
23bf6e62f2S猫头猫 */
24bf6e62f2S猫头猫
25bf6e62f2S猫头猫bootstrap();
26bf6e62f2S猫头猫const Stack = createNativeStackNavigator();
27bf6e62f2S猫头猫
28bf6e62f2S猫头猫export default function Pages() {
290d39db21S猫头猫  const themeName = useConfig('setting.theme.mode') ?? 'dark';
300d39db21S猫头猫  const themeColors = useConfig('setting.theme.colors') ?? {};
310d39db21S猫头猫  const theme = themeName === 'dark' ? CustomTheme : DefaultTheme;
320d39db21S猫头猫  const mergedTheme = {
330d39db21S猫头猫    ...theme,
340d39db21S猫头猫    colors: {
350d39db21S猫头猫      ...theme.colors,
360d39db21S猫头猫      ...themeColors,
370d39db21S猫头猫    },
380d39db21S猫头猫  };
39e3c48069S猫头猫  useEffect(() => {
40e3c48069S猫头猫    if (__DEV__) {
41e3c48069S猫头猫      RNBootSplash.hide({fade: true});
420d39db21S猫头猫      logManager.error('TEST');
43e3c48069S猫头猫    }
44e3c48069S猫头猫  }, []);
45bf6e62f2S猫头猫
46bf6e62f2S猫头猫  return (
47bf6e62f2S猫头猫    <GestureHandlerRootView style={{flex: 1}}>
480d39db21S猫头猫      <PaperProvider theme={mergedTheme}>
49*1c06c799S猫头猫        <SafeAreaProvider>
500d39db21S猫头猫          <NavigationContainer theme={mergedTheme}>
5165fc5a50S猫头猫            <PageBackground></PageBackground>
52bf6e62f2S猫头猫            <Stack.Navigator
53bf6e62f2S猫头猫              initialRouteName={routes[0].path}
54bf6e62f2S猫头猫              screenOptions={{
55bf6e62f2S猫头猫                statusBarColor: 'transparent',
56bf6e62f2S猫头猫                statusBarTranslucent: true,
57bf6e62f2S猫头猫                headerShown: false,
58bf6e62f2S猫头猫                animation: 'slide_from_right',
59bf6e62f2S猫头猫                animationDuration: 200,
60bf6e62f2S猫头猫              }}>
61bf6e62f2S猫头猫              {routes.map(route => (
62bf6e62f2S猫头猫                <Stack.Screen
63bf6e62f2S猫头猫                  key={route.path}
64bf6e62f2S猫头猫                  name={route.path}
65bf6e62f2S猫头猫                  component={route.component}></Stack.Screen>
66bf6e62f2S猫头猫              ))}
67bf6e62f2S猫头猫            </Stack.Navigator>
68bf6e62f2S猫头猫
69bf6e62f2S猫头猫            <Panels></Panels>
70bf6e62f2S猫头猫            <Dialogs></Dialogs>
71d1f226e6S猫头猫            <Share></Share>
72bf6e62f2S猫头猫            <Toast></Toast>
73bf6e62f2S猫头猫          </NavigationContainer>
74*1c06c799S猫头猫        </SafeAreaProvider>
75bf6e62f2S猫头猫      </PaperProvider>
76bf6e62f2S猫头猫    </GestureHandlerRootView>
77bf6e62f2S猫头猫  );
78bf6e62f2S猫头猫}
79bf6e62f2S猫头猫
80bf6e62f2S猫头猫const style = StyleSheet.create({
81bf6e62f2S猫头猫  blur: {
82bf6e62f2S猫头猫    width: '100%',
83bf6e62f2S猫头猫    height: '100%',
84bf6e62f2S猫头猫    position: 'absolute',
85bf6e62f2S猫头猫    top: 0,
86bf6e62f2S猫头猫    left: 0,
87bf6e62f2S猫头猫    right: 0,
88bf6e62f2S猫头猫    bottom: 0,
89bf6e62f2S猫头猫  },
90bf6e62f2S猫头猫});
91