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