-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
66 lines (57 loc) · 1.82 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
56
57
58
59
60
61
62
63
64
65
66
import "react-native-gesture-handler";
import { StatusBar } from "expo-status-bar";
import React, { useState, useEffect, useMemo } from "react";
import { StyleSheet, View } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { NativeBaseProvider, Text, Box, Spinner, Heading } from "native-base";
import { SafeAreaProvider } from "react-native-safe-area-context";
//stacks
import { RootStackNav } from "./navigators/RootStackNav";
import Main from "./navigators/Main";
import AsyncStorage from "@react-native-async-storage/async-storage";
import DrawerNavigator from "./navigators/DrawerNavigator";
export default function App() {
const [isLoading, setIsLoading] = useState(true);
const [user, setUser] = useState(null);
const getToken = async () => {
const jsonValue = await AsyncStorage.getItem("user");
return JSON.parse(jsonValue);
};
useEffect(() => {
setUser(getToken());
setTimeout(() => {
setIsLoading(false);
}, 1500);
}, []);
console.log(user);
if (isLoading) {
return (
<NativeBaseProvider>
<Box space={2} flex={1} alignItems="center" justifyContent="center">
<Spinner accessibilityLabel="Loading" />
<Heading color="primary.500" fontSize="md">
Loading
</Heading>
</Box>
</NativeBaseProvider>
);
}
return (
<NavigationContainer>
<NativeBaseProvider>
<SafeAreaProvider>
{user._W !== null ? <DrawerNavigator /> : <RootStackNav />}
</SafeAreaProvider>
</NativeBaseProvider>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});