forked from hossam1231/RNETrackerTRADE
-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
64 lines (59 loc) · 2.06 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
55
56
57
58
59
60
61
62
63
64
import "react-native-gesture-handler";
import * as SplashScreen from "expo-splash-screen";
import { StatusBar } from "expo-status-bar";
import { NativeBaseProvider, Box } from "native-base";
import React, { useState, useEffect, useCallback } from "react";
import { View, Platform } from "react-native";
import { Provider as PaperProvider } from "react-native-paper";
import { Provider as ReduxProvider } from "react-redux";
import { PersistGate } from "redux-persist/integration/react";
// import root navigator
import useCachedResources from "./src/hooks/useCachedResources";
import RootNavigator from "./src/navigation";
// importing screens
import SplashScreenWeb from "./src/screens/SplashScreen.web";
// importing services
import { store, persister } from "./src/services/redux/index";
import { CombinedDarkTheme } from "./src/services/themes";
export default function App() {
const isAppReady = useCachedResources();
// make sure the splash screen doesn't auto hide
// also remember `expo-splash-screen` is not supported by web
useEffect(() => {
(async () => {
try {
await SplashScreen.preventAutoHideAsync();
// we can also load required assets here like initial API requests, fonts, etc.
} catch (err) {
console.log(err);
} finally {
}
})();
}, []);
// use a onLayout callback to avoid flicker when transitioning from splash to rendered app
const onLayout = useCallback(async () => {
if (isAppReady) {
await SplashScreen.hideAsync();
}
}, [isAppReady]);
if (!isAppReady) {
if (Platform.OS === "web") {
return <SplashScreenWeb />;
}
return null;
}
return (
<NativeBaseProvider>
<View onLayout={onLayout} style={{ flex: 1 }}>
<ReduxProvider store={store}>
<PersistGate loading={false} persistor={persister}>
<PaperProvider theme={CombinedDarkTheme}>
<StatusBar style="auto" />
<RootNavigator />
</PaperProvider>
</PersistGate>
</ReduxProvider>
</View>
</NativeBaseProvider>
);
}