-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
54 lines (46 loc) · 1.47 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
import React, {useEffect} from 'react';
import {AppState, Platform, StyleSheet} from 'react-native';
import type {AppStateStatus} from 'react-native';
import {focusManager, onlineManager} from '@tanstack/react-query';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {NavigationContainer} from '@react-navigation/native';
import SplashScreen from 'react-native-splash-screen';
import NetInfo from '@react-native-community/netinfo';
import MyStack from 'routes/MyStack';
import OnBoarding from 'routes/OnBoarding';
import {useStore} from 'store';
function App(): React.JSX.Element {
const logout = useStore(state => state.logout);
useEffect(() => {
setTimeout(() => {
SplashScreen.hide();
}, 2500);
}, []);
const onAppStateChange = (status: AppStateStatus) => {
if (Platform.OS !== 'web') {
focusManager.setFocused(status === 'active');
}
};
useEffect(() => {
const subscription = AppState.addEventListener('change', onAppStateChange);
return () => subscription.remove();
}, []);
onlineManager.setEventListener(setOnline => {
return NetInfo.addEventListener(state => {
setOnline(!!state.isConnected);
});
});
return (
<GestureHandlerRootView style={styles.container}>
<NavigationContainer>
{logout ? <OnBoarding /> : <MyStack />}
</NavigationContainer>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default App;