xref: /MusicFree/src/entry/index.tsx (revision bf6e62f27bf21a011995d7561e0093fae1a2d72e)
1*bf6e62f2S猫头猫import React from 'react';
2*bf6e62f2S猫头猫import {Image, StyleSheet} from 'react-native';
3*bf6e62f2S猫头猫
4*bf6e62f2S猫头猫import {NavigationContainer} from '@react-navigation/native';
5*bf6e62f2S猫头猫import {createNativeStackNavigator} from '@react-navigation/native-stack';
6*bf6e62f2S猫头猫import bootstrap from './bootstrap';
7*bf6e62f2S猫头猫import {routes} from './router';
8*bf6e62f2S猫头猫import {useAtomValue} from 'jotai';
9*bf6e62f2S猫头猫import {loadableThemeStateAtom} from '@/store/themeState';
10*bf6e62f2S猫头猫import {Provider as PaperProvider} from 'react-native-paper';
11*bf6e62f2S猫头猫import {GestureHandlerRootView} from 'react-native-gesture-handler';
12*bf6e62f2S猫头猫import Dialogs from '@/components/dialogs';
13*bf6e62f2S猫头猫import Toast from 'react-native-toast-message';
14*bf6e62f2S猫头猫import Panels from '@/components/panels';
15*bf6e62f2S猫头猫import {CustomTheme, DarkTheme, DefaultTheme} from './theme';
16*bf6e62f2S猫头猫import { useConfig } from '@/common/localConfigManager';
17*bf6e62f2S猫头猫
18*bf6e62f2S猫头猫// todo: load config
19*bf6e62f2S猫头猫/**
20*bf6e62f2S猫头猫 * 字体颜色
21*bf6e62f2S猫头猫 */
22*bf6e62f2S猫头猫
23*bf6e62f2S猫头猫bootstrap();
24*bf6e62f2S猫头猫const Stack = createNativeStackNavigator();
25*bf6e62f2S猫头猫
26*bf6e62f2S猫头猫export default function Pages() {
27*bf6e62f2S猫头猫  const config = useConfig();
28*bf6e62f2S猫头猫  console.log('updated');
29*bf6e62f2S猫头猫
30*bf6e62f2S猫头猫  return (
31*bf6e62f2S猫头猫    <GestureHandlerRootView style={{flex: 1}}>
32*bf6e62f2S猫头猫      <PaperProvider theme={CustomTheme}>
33*bf6e62f2S猫头猫        <NavigationContainer theme={CustomTheme}>
34*bf6e62f2S猫头猫          {config && (
35*bf6e62f2S猫头猫            <Image
36*bf6e62f2S猫头猫              style={style.blur}
37*bf6e62f2S猫头猫              blurRadius={15}
38*bf6e62f2S猫头猫              source={
39*bf6e62f2S猫头猫                config?.setting?.background
40*bf6e62f2S猫头猫                  ? {
41*bf6e62f2S猫头猫                      uri: config.setting.background,
42*bf6e62f2S猫头猫                    }
43*bf6e62f2S猫头猫                  : require('@/assets/imgs/background.jpg')
44*bf6e62f2S猫头猫              }></Image>
45*bf6e62f2S猫头猫          )}
46*bf6e62f2S猫头猫
47*bf6e62f2S猫头猫          <Stack.Navigator
48*bf6e62f2S猫头猫            initialRouteName={routes[0].path}
49*bf6e62f2S猫头猫            screenOptions={{
50*bf6e62f2S猫头猫              statusBarColor: 'transparent',
51*bf6e62f2S猫头猫              statusBarTranslucent: true,
52*bf6e62f2S猫头猫              headerShown: false,
53*bf6e62f2S猫头猫              animation: 'slide_from_right',
54*bf6e62f2S猫头猫              animationDuration: 200,
55*bf6e62f2S猫头猫            }}>
56*bf6e62f2S猫头猫            {routes.map(route => (
57*bf6e62f2S猫头猫              <Stack.Screen
58*bf6e62f2S猫头猫                key={route.path}
59*bf6e62f2S猫头猫                name={route.path}
60*bf6e62f2S猫头猫                component={route.component}></Stack.Screen>
61*bf6e62f2S猫头猫            ))}
62*bf6e62f2S猫头猫          </Stack.Navigator>
63*bf6e62f2S猫头猫
64*bf6e62f2S猫头猫          <Panels></Panels>
65*bf6e62f2S猫头猫          <Dialogs></Dialogs>
66*bf6e62f2S猫头猫          <Toast></Toast>
67*bf6e62f2S猫头猫        </NavigationContainer>
68*bf6e62f2S猫头猫      </PaperProvider>
69*bf6e62f2S猫头猫    </GestureHandlerRootView>
70*bf6e62f2S猫头猫  );
71*bf6e62f2S猫头猫}
72*bf6e62f2S猫头猫
73*bf6e62f2S猫头猫const style = StyleSheet.create({
74*bf6e62f2S猫头猫  blur: {
75*bf6e62f2S猫头猫    width: '100%',
76*bf6e62f2S猫头猫    height: '100%',
77*bf6e62f2S猫头猫    position: 'absolute',
78*bf6e62f2S猫头猫    top: 0,
79*bf6e62f2S猫头猫    left: 0,
80*bf6e62f2S猫头猫    right: 0,
81*bf6e62f2S猫头猫    bottom: 0,
82*bf6e62f2S猫头猫  },
83*bf6e62f2S猫头猫});
84