-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
38 lines (34 loc) · 1.04 KB
/
App.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
import { StatusBar } from "expo-status-bar";
import { useFonts } from "expo-font";
import Karla from "assets/fonts/Karla-Regular.ttf";
import Markazi from "assets/fonts/MarkaziText-Regular.ttf";
import { useEffect, useState } from "react";
import AsyncStorage from "@react-native-async-storage/async-storage";
import SplashScreen from "screens/SplashScreen";
import { UserProvider } from "context/UserContext";
import NavigationRoot from "navigation/NavigationRoot";
export default function App() {
const [isReady, setIsReady] = useState(false);
const [initUser, setInitUser] = useState(null);
const [fontsLoaded] = useFonts({
Karla,
Markazi,
});
useEffect(() => {
AsyncStorage.getItem("user").then((user) => {
if (user) {
setInitUser(JSON.parse(user));
}
setTimeout(() => setIsReady(true), 1000);
});
}, []);
if (!isReady || !fontsLoaded) {
return <SplashScreen />;
}
return (
<UserProvider initUser={initUser}>
<StatusBar style="auto" />
<NavigationRoot />
</UserProvider>
);
}