-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.tsx
48 lines (41 loc) · 1.39 KB
/
Main.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
import React, { useContext, useEffect, useState } from "react";
import * as Font from "expo-font";
import { NavigationContainer } from "@react-navigation/native";
import MainStack from "./src/navigation/MainStack";
import AuthStack from "./src/navigation/AuthStack";
import { AuthContext } from "./src/context/AuthContext";
import { Toasts } from "@backpackapp-io/react-native-toast";
const Main = () => {
const [isLoaded, setIsLoaded] = useState(false);
const { user } = useContext(AuthContext);
useEffect(() => {
const prepare = async () => {
try {
await Font.loadAsync({
black: require("./src/assets/fonts/Poppins-Black.ttf"),
blackBold: require("./src/assets/fonts/Poppins-Bold.ttf"),
light: require("./src/assets/fonts/Poppins-Light.ttf"),
medium: require("./src/assets/fonts/Poppins-Medium.ttf"),
regular: require("./src/assets/fonts/Poppins-Regular.ttf"),
thin: require("./src/assets/fonts/Poppins-Thin.ttf"),
rog: require("./src/assets/fonts/Rog-Regular.ttf"),
});
} catch (error: any) {
console.log(error);
} finally {
setIsLoaded(true);
}
};
prepare();
}, []);
if (!isLoaded) {
return null;
}
return (
<NavigationContainer>
{user !== null ? <MainStack /> : <AuthStack />}
<Toasts />
</NavigationContainer>
);
};
export default Main;