-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
75 lines (69 loc) · 2.12 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
67
68
69
70
71
72
73
74
75
import React, { useState, useEffect } from "react";
import {
NavigationContainer,
DarkTheme,
DefaultTheme,
} from "@react-navigation/native";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import AsyncStorage from "@react-native-async-storage/async-storage";
//import { AppearanceProvider } from "react-native-appearance";
import { ThemeProvider } from "./globals/theme";
//import { useColorScheme } from "react-native";
import {
useFonts,
Poppins_400Regular,
Poppins_500Medium,
Poppins_500Medium_Italic,
Poppins_600SemiBold,
Poppins_700Bold,
} from "@expo-google-fonts/poppins";
import Home from "./screens/home";
import Login from "./screens/login";
export default function App() {
const [loggedIn, setLoggedIn] = useState(null);
const Stack = createNativeStackNavigator();
//const scheme = useColorScheme();
let [fontsLoaded] = useFonts({
Poppins_400Regular,
Poppins_500Medium,
Poppins_500Medium_Italic,
Poppins_600SemiBold,
Poppins_700Bold,
});
const isLoggedIn = async () => {
try {
const number = await AsyncStorage.getItem("number");
const pass = await AsyncStorage.getItem("password");
setLoggedIn(number !== null && pass !== null);
} catch {}
};
useEffect(() => {
isLoggedIn();
}, []);
if (!fontsLoaded || loggedIn === null) {
return null;
} else {
return (
<ThemeProvider>
<SafeAreaProvider>
<NavigationContainer theme={DarkTheme}>
<Stack.Navigator screenOptions={{ headerShown: false }}>
{loggedIn ? (
<>
<Stack.Screen name="Home" component={Home} />
<Stack.Screen name="Login" component={Login} />
</>
) : (
<>
<Stack.Screen name="Login" component={Login} />
<Stack.Screen name="Home" component={Home} />
</>
)}
</Stack.Navigator>
</NavigationContainer>
</SafeAreaProvider>
</ThemeProvider>
);
}
}