-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
97 lines (80 loc) · 2.7 KB
/
App.tsx
File metadata and controls
97 lines (80 loc) · 2.7 KB
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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import { NavigationContainer } from '@react-navigation/native';
import React, { useEffect } from 'react';
import { View, useColorScheme } from 'react-native';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import { onStartUp } from './app/global/common';
import {
darkTheme,
lightTheme,
} from './app/global/constants';
import AppManager from './app/global/helpers/AppManager';
import InternetReachabilityManager from './app/global/helpers/InternetReachabilityManager';
import { AppNavigation } from './app/navigation';
import store, { stateSelector } from './app/store/Store';
import { SetInternetConnectAction } from './app/store/actions/SetInternetConnectAction';
import { SetThemeSettingAction } from './app/store/actions/SetThemeSettingAction';
import persist from './app/store/persist';
import ToastView from './app/components/ToastView';
function App(): JSX.Element {
onStartUp('Dev');
const _ = InternetReachabilityManager.addEventListener(state => {
const isConnected = state.isConnected || false;
if (store.getState().LoginReducer.isInternetConnect != isConnected) {
store.dispatch(SetInternetConnectAction(isConnected));
}
});
const Navigation = () => {
const themeState = stateSelector(
state => state.UtitltyScreensReducer.theme,
);
const getTheme = () => {
if (themeState === 'light') {
return lightTheme;
} else {
return darkTheme;
}
};
useEffect(()=>{
AppManager.onMigrationNeeded(onExecuteMigration);
}, [false])
const onExecuteMigration = () => { };
const ThemeHandlingView = () => {
const systemTheme = useColorScheme() || 'dark';
useEffect(()=>{
const isThemeSystemDefault = store.getState().UtitltyScreensReducer.isThemeSystemDefault;
if (isThemeSystemDefault) {
const theme = store.getState().UtitltyScreensReducer.theme;
if (theme == 'dark' && systemTheme == 'light' || theme == 'light' && systemTheme == 'dark') {
store.dispatch(SetThemeSettingAction({
isSystemDefault: true,
theme: systemTheme
}));
}
}
}, [systemTheme]);
return (<View/>);
}
return (
<NavigationContainer theme={getTheme()}>
<AppNavigation />
<ToastView />
<ThemeHandlingView />
</NavigationContainer>
);
};
return (
<PersistGate loading={true} persistor={persist().persistor}>
<Provider store={persist().store}>
<Navigation />
</Provider>
</PersistGate>
);
}
export default App;