-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
55 lines (48 loc) · 1.89 KB
/
App.js
File metadata and controls
55 lines (48 loc) · 1.89 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
import { useNetInfo } from "@react-native-community/netinfo";
import { NavigationContainer } from "@react-navigation/native";
import AppLoading from "expo-app-loading";
import React, { useState } from "react";
import AuthContext from "./app/auth/context";
// Component
// Assets
import authStorage from "./app/auth/storage";
import AppNavigator from "./app/components/navigators/AppNavigator";
import AuthNavigator from "./app/components/navigators/AuthNavigator";
import myTheme from "./app/components/navigators/navigationTheme";
import navigationRef from "./app/components/navigators/rootNavigation";
import NotificationBanner from "./app/components/NotificationBanner";
import { NotificationsContextProvider } from "./app/contexts/NotificationsContext";
export default function App() {
const NetInfo = useNetInfo();
const [isAppReady, setIsAppReady] = useState(false);
const [user, setUser] = useState();
const restoreUser = async () => {
const user = await authStorage.getUser();
if (!user) return;
setUser(user);
};
if (!isAppReady) {
return (
<AppLoading
startAsync={restoreUser}
onFinish={() => setIsAppReady(true)}
onError={(error) => console.log(error)}
/>
);
}
return (
<>
{NetInfo.isInternetReachable === false &&
NetInfo.type !== "unknown" && <NotificationBanner />}
{/* <NotificationBanner /> */}
<NotificationsContextProvider>
<AuthContext.Provider value={{ user, setUser }}>
<NavigationContainer ref={navigationRef} theme={myTheme}>
{user ? <AppNavigator /> : <AuthNavigator />}
</NavigationContainer>
</AuthContext.Provider>
</NotificationsContextProvider>
</>
// <ChatScreen />
);
}