-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
101 lines (94 loc) · 3.33 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
import 'packages/localization';
import AsyncStorage from '@react-native-async-storage/async-storage';
import React from 'react';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import SettingProvider from 'contexts/SettingProvider';
import { BaseProvider, ColorMode, IBaseConfig, StorageManager } from 'packages/core';
import { extendTheme } from 'packages/core/extendTheme';
import { theme as defaultTheme } from 'packages/uikit';
import { Drawer, Loading, Toast } from 'packages/uikit/components';
import { globalDrawerRef } from 'packages/uikit/components/Drawer';
import GestureRecognizer from 'packages/uikit/components/Drawer/GestureRecognizer';
import { globalLoadingRef } from 'packages/uikit/components/Loading';
import { onSwipeRight } from 'packages/utils/gestureHandle';
import RootStacks from 'stacks';
import store, { persistor } from 'stores';
import { myColors, MyColorsType } from 'themes/colors';
const myTheme = extendTheme({
colors: myColors,
fontConfig: {
Roboto: {
100: 'Roboto-Light',
200: 'Roboto-Light',
300: 'Roboto-Light',
400: {
normal: 'Roboto-Regular',
italic: 'Roboto-Italic',
},
500: 'Roboto-Medium',
600: 'Roboto-Medium',
700: {
normal: 'Roboto-Bold',
italic: 'Roboto-BoldItalic',
},
800: 'Roboto-Bold',
900: 'Roboto-Black',
},
},
fonts: {
...defaultTheme.fonts,
heading: 'Roboto',
body: 'Roboto',
mana: 'Roboto',
},
});
type MyThemeType = typeof myTheme;
// NOTE: The module name in package.json
declare module 'demo-react-native' {
interface ICustomTheme extends MyThemeType {}
interface ICustomColors extends MyColorsType {}
}
const config: IBaseConfig = {
dependencies: {
'liner-gradient': require('react-native-linear-gradient').default,
},
};
const MENU_TEST = [{ name: 'Home' }, { name: 'Profile' }, { name: 'Notification' }, { name: 'Setting' }];
// TODO: need wrap logic to file
const colorModeManager: StorageManager = {
get: async () => {
try {
const val = await AsyncStorage.getItem('@color-mode');
return val === 'dark' ? 'dark' : 'light';
} catch (e) {
return 'light';
}
},
set: async (value: ColorMode) => {
try {
await AsyncStorage.setItem('@color-mode', value);
} catch (e) {
console.log(e);
}
},
};
function App() {
return (
<BaseProvider config={config} colorModeManager={colorModeManager} theme={myTheme}>
<SettingProvider>
{/* <GestureRecognizer onSwipeRight={(state) => onSwipeRight(state)} style={{ flex: 1 }}> */}
<Provider store={store}>
<Drawer showMenu showAvatar ref={globalDrawerRef} menuData={MENU_TEST} />
<PersistGate loading={null} persistor={persistor}>
<RootStacks />
</PersistGate>
<Loading ref={globalLoadingRef} />
<Toast />
</Provider>
{/* </GestureRecognizer> */}
</SettingProvider>
</BaseProvider>
);
}
export default App;