-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
115 lines (105 loc) · 2.74 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import React from 'react';
import {
adaptNavigationTheme,
Provider as PaperProvider,
MD3DarkTheme,
MD3LightTheme,
} from 'react-native-paper';
import {RecoilRoot} from 'recoil';
import {StatusBar, useColorScheme} from 'react-native';
import Icons from 'react-native-vector-icons/Ionicons';
import {
DarkTheme,
DefaultTheme,
NavigationContainer,
} from '@react-navigation/native';
import LocalizedStrings from 'react-native-localization';
import {useMaterial3Theme} from '@pchmn/expo-material3-theme';
import {createMaterialBottomTabNavigator} from '@react-navigation/material-bottom-tabs';
import IndexPage from './src/pages/index';
import {TagsProvider} from './src/utils/tags';
import SettingsPage from './src/pages/settings';
const Tab = createMaterialBottomTabNavigator();
const {LightTheme: NavLightTheme, DarkTheme: NavDarkTheme} =
adaptNavigationTheme({
reactNavigationLight: DefaultTheme,
reactNavigationDark: DarkTheme,
});
const ImageIcon = (p: any) => {
return p.focused ? (
<Icons name="image" color={p.color} size={26} />
) : (
<Icons name="image-outline" color={p.color} size={26} />
);
};
const SettingsIcon = (p: any) => {
return p.focused ? (
<Icons name="settings" color={p.color} size={26} />
) : (
<Icons name="settings-outline" color={p.color} size={26} />
);
};
export default function App(): JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const {theme: m3Theme} = useMaterial3Theme({
fallbackSourceColor: '#009ba1',
});
const darkTheme = {
...NavDarkTheme,
...MD3DarkTheme,
colors: {...NavDarkTheme.colors, ...m3Theme.dark},
};
const lightTheme = {
...NavLightTheme,
...MD3LightTheme,
colors: {...NavLightTheme.colors, ...m3Theme.light},
};
const theme = isDarkMode ? darkTheme : lightTheme;
const barStyle = isDarkMode ? 'light-content' : 'dark-content';
return (
<RecoilRoot>
<TagsProvider>
<PaperProvider theme={theme}>
<NavigationContainer theme={theme}>
<StatusBar
barStyle={barStyle}
backgroundColor={theme.colors.surface}
/>
<Tab.Navigator
shifting
sceneAnimationEnabled
initialRouteName="Index"
>
<Tab.Screen
name="Index"
component={IndexPage}
options={{
tabBarLabel: strings.index,
tabBarIcon: ImageIcon,
}}
/>
<Tab.Screen
name="Settings"
component={SettingsPage}
options={{
tabBarLabel: strings.settings,
tabBarIcon: SettingsIcon,
}}
/>
</Tab.Navigator>
</NavigationContainer>
</PaperProvider>
</TagsProvider>
</RecoilRoot>
);
}
const strings = new LocalizedStrings({
en: {
index: 'Artwork',
settings: 'Setting',
},
zh: {
index: '作品',
settings: '设置',
},
});