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