xref: /MusicFree/src/entry/index.tsx (revision 19dc08ecf646164591cb30515347b693c01518c7)
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';
1308a8e62cS猫头猫import {CustomTheme, 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*19dc08ecS猫头猫import PageBackground from '@/components/base/pageBackground';
191c06c799S猫头猫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') ?? {};
31c7676810S猫头猫  const theme = themeName.includes('dark') ? CustomTheme : DefaultTheme;
32c7676810S猫头猫  const isCustom = themeName.includes('custom') ? true : false;
33c7676810S猫头猫  const mergedTheme = isCustom
34c7676810S猫头猫    ? {
350d39db21S猫头猫        ...theme,
360d39db21S猫头猫        colors: {
370d39db21S猫头猫          ...theme.colors,
380d39db21S猫头猫          ...themeColors,
390d39db21S猫头猫        },
40c7676810S猫头猫      }
41c7676810S猫头猫    : theme;
42e3c48069S猫头猫  useEffect(() => {
43e3c48069S猫头猫    if (__DEV__) {
44e3c48069S猫头猫      RNBootSplash.hide({fade: true});
450d39db21S猫头猫      logManager.error('TEST');
46e3c48069S猫头猫    }
47e3c48069S猫头猫  }, []);
48bf6e62f2S猫头猫
49bf6e62f2S猫头猫  return (
50bf6e62f2S猫头猫    <GestureHandlerRootView style={{flex: 1}}>
510d39db21S猫头猫      <PaperProvider theme={mergedTheme}>
521c06c799S猫头猫        <SafeAreaProvider>
530d39db21S猫头猫          <NavigationContainer theme={mergedTheme}>
5465fc5a50S猫头猫            <PageBackground></PageBackground>
55bf6e62f2S猫头猫            <Stack.Navigator
56bf6e62f2S猫头猫              initialRouteName={routes[0].path}
57bf6e62f2S猫头猫              screenOptions={{
58bf6e62f2S猫头猫                statusBarColor: 'transparent',
59bf6e62f2S猫头猫                statusBarTranslucent: true,
60bf6e62f2S猫头猫                headerShown: false,
61bf6e62f2S猫头猫                animation: 'slide_from_right',
62bf6e62f2S猫头猫                animationDuration: 200,
63bf6e62f2S猫头猫              }}>
64bf6e62f2S猫头猫              {routes.map(route => (
65bf6e62f2S猫头猫                <Stack.Screen
66bf6e62f2S猫头猫                  key={route.path}
67bf6e62f2S猫头猫                  name={route.path}
68bf6e62f2S猫头猫                  component={route.component}></Stack.Screen>
69bf6e62f2S猫头猫              ))}
70bf6e62f2S猫头猫            </Stack.Navigator>
71bf6e62f2S猫头猫
72bf6e62f2S猫头猫            <Panels></Panels>
73bf6e62f2S猫头猫            <Dialogs></Dialogs>
74d1f226e6S猫头猫            <Share></Share>
75bf6e62f2S猫头猫            <Toast></Toast>
76bf6e62f2S猫头猫          </NavigationContainer>
771c06c799S猫头猫        </SafeAreaProvider>
78bf6e62f2S猫头猫      </PaperProvider>
79bf6e62f2S猫头猫    </GestureHandlerRootView>
80bf6e62f2S猫头猫  );
81bf6e62f2S猫头猫}
82bf6e62f2S猫头猫
83bf6e62f2S猫头猫const style = StyleSheet.create({
84bf6e62f2S猫头猫  blur: {
85bf6e62f2S猫头猫    width: '100%',
86bf6e62f2S猫头猫    height: '100%',
87bf6e62f2S猫头猫    position: 'absolute',
88bf6e62f2S猫头猫    top: 0,
89bf6e62f2S猫头猫    left: 0,
90bf6e62f2S猫头猫    right: 0,
91bf6e62f2S猫头猫    bottom: 0,
92bf6e62f2S猫头猫  },
93bf6e62f2S猫头猫});
94