This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
64 lines (57 loc) · 1.65 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
/** @format */
import PropTypes from "prop-types";
import { AppLoading } from "expo";
import { Asset } from "expo-asset";
import * as Font from "expo-font";
import React, { useState } from "react";
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
import { Provider } from "react-redux";
import * as firebase from "firebase";
import AppComponent from "./AppComponent";
import store from "./store";
import { firebaseConfig } from "./constants/ApiKeys";
function handleLoadingError(error) {
console.warn(error);
}
function handleFinishLoading(setLoadingComplete) {
setLoadingComplete(true);
}
async function loadResourcesAsync() {
await Promise.all([
Asset.loadAsync([
require("./assets/images/btn_google_signin_dark_normal_web.png")
]),
Asset.loadAsync([
require("./assets/images/btn_google_signin_light_normal_web.png")
]),
Asset.loadAsync([require("./assets/images/icon.png")]),
Font.loadAsync({
...Ionicons.font,
...MaterialCommunityIcons.font,
roboto: require("./assets/fonts/Roboto-Regular.ttf")
})
]);
}
export default function App({ skipLoadingScreen }) {
const [isLoadingComplete, setLoadingComplete] = useState(false);
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
if (!isLoadingComplete && !skipLoadingScreen) {
return (
<AppLoading
startAsync={loadResourcesAsync}
onError={handleLoadingError}
onFinish={() => handleFinishLoading(setLoadingComplete)}
/>
);
}
return (
<Provider store={store}>
<AppComponent />
</Provider>
);
}
App.propTypes = {
skipLoadingScreen: PropTypes.any
};