-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
57 lines (47 loc) · 1.62 KB
/
App.js
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
import React, { useCallback, useEffect, useState } from 'react';
import AppNavigator from './AppNavigator';
import { useFonts } from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import { MenuProvider } from 'react-native-popup-menu';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import { store, persistor } from './app/Redux/Store';
//login signup as a stack must be returned here and a user state
export default function App() {
const [isAppReady, setAppReady] = useState(false);
useEffect(() => {
async function prepare() {
await SplashScreen.preventAutoHideAsync();
// Simulate a longer loading time
await new Promise(resolve => setTimeout(resolve, 2000)); // 2 seconds delay
}
prepare();
}, []);
const [fontsLoaded] = useFonts({
'Lato-Regular': require('./assets/fonts/Lato-Regular.ttf'),
'Lato-Bold': require('./assets/fonts/Lato-Bold.ttf'),
'Lato-BoldItalic': require('./assets/fonts/Lato-BoldItalic.ttf'),
});
useEffect(() => {
if (fontsLoaded) {
const hideSplashScreen = async () => {
await new Promise(resolve => setTimeout(resolve, 2000)); // 2 seconds delay
setAppReady(true);
SplashScreen.hideAsync();
};
hideSplashScreen();
}
}, [fontsLoaded]);
if (!isAppReady) {
return null; // Return null while splash screen is visible
}
return (
<MenuProvider>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<AppNavigator />
</PersistGate>
</Provider>
</MenuProvider>
);
}