-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
59 lines (46 loc) · 1.57 KB
/
App.tsx
File metadata and controls
59 lines (46 loc) · 1.57 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
import { useEffect, useMemo, useRef } from 'react';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import * as SplashScreen from 'expo-splash-screen';
import { StatusBar } from 'expo-status-bar';
import { observer } from 'mobx-react';
import './src/locales';
import { COLORS } from './src/constants/styles';
import { navio } from './src/navigation/navio';
import { navigationService } from './src/services';
import { userStore } from './src/store/userStore';
import { useAppTheme } from './src/theme';
SplashScreen.preventAutoHideAsync();
const AppWrapper = observer(() => {
const isThemeReady = useAppTheme();
const isUserStoreInitialized = userStore.isInitialized;
const isAuthenticated = userStore.isAuthenticated();
const navigationHandledRef = useRef(false);
const isAppReady = useMemo(
() => isThemeReady && isUserStoreInitialized,
[isThemeReady, isUserStoreInitialized]
);
useEffect(() => {
if (isAppReady && !navigationHandledRef.current) {
const handleNavigation = () => {
navigationHandledRef.current = true;
if (isAuthenticated) {
navigationService.navigateToMainTabs();
} else {
navigationService.navigateToAuthTabs();
}
SplashScreen.hideAsync();
};
requestAnimationFrame(handleNavigation);
}
}, [isAppReady, isAuthenticated]);
if (!isAppReady) {
return null;
}
return (
<SafeAreaProvider>
<StatusBar style='light' backgroundColor={COLORS.PRIMARY} />
<navio.App />
</SafeAreaProvider>
);
});
export default AppWrapper;