-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathApp.tsx
More file actions
78 lines (59 loc) · 2.09 KB
/
Copy pathApp.tsx
File metadata and controls
78 lines (59 loc) · 2.09 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
import 'react-native-gesture-handler';
import React, {
ReactElement,
useCallback,
useContext,
useEffect,
useState,
} from 'react';
import {StatusBar, useColorScheme, NativeModules, Platform} from 'react-native';
import Toast, {ToastConfig} from 'react-native-toast-message';
import {toastConfig} from './components/toast';
import {AppStorageContext} from './class/storageContext';
import {SafeAreaProvider} from 'react-native-safe-area-context';
import i18n from './i18n';
import Privacy from 'react-native-privacy-snapshot';
import RootNavigator from './Navigation';
import OnboardingNavigator from './navigation/onboarding/OnboardingNavigator';
import Color from './constants/Color';
const App = () => {
const [isReady, setIsReady] = useState<boolean>(false);
const {appLanguage, isWalletInitialized} = useContext(AppStorageContext);
const ColorScheme = Color(useColorScheme());
const RootScreen = useCallback((): ReactElement => {
if (!isReady) {
return <></>;
}
if (!isWalletInitialized) {
return <OnboardingNavigator />;
}
return <RootNavigator />;
}, [isReady, isWalletInitialized]);
useEffect(() => {
// Enable privacy blur for IOS; blur screen when screen inactive
Privacy?.enabled(true);
if (Platform.OS === 'android') {
setTimeout(NativeModules.SplashScreenModule.hide, 100);
}
// Set app ready
setIsReady(true);
}, []);
useEffect(() => {
// Load language when app language change
i18n.changeLanguage(appLanguage.code);
}, [appLanguage]);
return (
<SafeAreaProvider
style={{backgroundColor: ColorScheme.Background.Primary}}>
<StatusBar
barStyle={
ColorScheme.isDarkMode ? 'light-content' : 'dark-content'
}
backgroundColor={ColorScheme.Background.Primary}
/>
<RootScreen />
<Toast config={toastConfig as ToastConfig} />
</SafeAreaProvider>
);
};
export default App;