-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
89 lines (76 loc) · 2.5 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import 'react-native-reanimated';
import React, { useEffect, useState } from 'react';
import { View, ActivityIndicator } from 'react-native';
import * as SplashScreen from 'expo-splash-screen';
import { useFonts, Ubuntu_400Regular, Ubuntu_700Bold } from '@expo-google-fonts/ubuntu';
import AppNavigator from "./src/navigation/AppNavigator";
import { AuthProvider } from "./src/provider/AuthProvider";
import { BookProvider } from "./src/provider/BookProvider";
import { UserProvider } from "./src/provider/UserProvider";
import { NotificationProvider } from "./src/provider/NotificationProvider";
import { ThemeProvider } from "react-native-rapi-ui";
import { MessageProvider } from './src/provider/MessageProvider';
// disable yellow and red box
console.disableYellowBox = true;
console.warn = () => { };
console.error = () => { };
// Prevent native splash screen from autohiding
SplashScreen.preventAutoHideAsync();
export default function App() {
const [appIsReady, setAppIsReady] = useState(false);
const [fontsLoaded, error] = useFonts({
Ubuntu_400Regular,
Ubuntu_700Bold,
});
const images = [
require("./assets/icon.png"),
require("./assets/splash.png"),
require("./assets/login.png"),
require("./assets/register.png"),
require("./assets/forget.png"),
];
useEffect(() => {
async function prepare() {
// Prevent auto-hiding the splash screen
await SplashScreen.preventAutoHideAsync();
if (!fontsLoaded) {
console.log('Fonts are not loaded:', error);
setTimeout(() => {
console.log("Font loading error", "Unable to load fonts, continuing without them.");
setAppIsReady(true);
}, 5000);
} else {
console.log('Fonts are loaded');
setAppIsReady(true);
}
}
prepare();
}, [fontsLoaded]);
useEffect(() => {
if (appIsReady && fontsLoaded) {
SplashScreen.hideAsync();
}
}, [appIsReady, fontsLoaded]);
if (!appIsReady || !fontsLoaded) {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<ActivityIndicator size="large" />
</View>
);
}
return (
<ThemeProvider images={images}>
<AuthProvider>
<BookProvider>
<UserProvider>
<NotificationProvider>
<MessageProvider>
<AppNavigator />
</MessageProvider>
</NotificationProvider>
</UserProvider>
</BookProvider>
</AuthProvider>
</ThemeProvider>
);
}