-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathApp.js
60 lines (53 loc) · 1.51 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
import { StatusBar } from "expo-status-bar";
import React, { useEffect, useState, useContext } from "react";
import { LogBox, StyleSheet, Text, View } from "react-native";
import AuthNavigation from "./AuthNavigation";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { ActivityIndicator } from "react-native";
import AuthContentProvider, { AuthContext } from "./store/auth-context";
import { GlobalStyles } from "./constants/Styles";
import Loader from "./components/UI/Loader";
export default function App() {
LogBox.ignoreAllLogs();
function Root() {
const [isTryingLogin, setIsTryingLogin] = useState(true);
const authCtx = useContext(AuthContext);
useEffect(() => {
async function fetchToken() {
setTimeout(() => {
setIsTryingLogin(false);
}, 2000);
}
fetchToken();
}, []);
if (isTryingLogin) {
return (
<View
style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: GlobalStyles.colors.primary,
}}
>
<Loader />
</View>
);
}
return <AuthNavigation />;
}
return (
<AuthContentProvider>
<StatusBar backgroundColor={GlobalStyles.colors.primary} />
<Root />
</AuthContentProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: GlobalStyles.colors.primary,
alignItems: "center",
justifyContent: "center",
},
});