forked from VunderkindMedia/Instantcms-2-mobile-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainScreen.js
More file actions
37 lines (35 loc) · 1.16 KB
/
Copy pathMainScreen.js
File metadata and controls
37 lines (35 loc) · 1.16 KB
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
import React, { useContext, useCallback, useEffect, useState } from "react";
import { AppContext } from "./context/app/AppContext";
import { AppLoading } from "expo";
import { View, Text, ActivityIndicator } from "react-native";
import { List } from "./screens/content/List";
import AppNav from "./navigation/AppNavigator";
import { ErrorView } from "./screens/content/ErrorView";
export const MainScreen = () => {
const { get_icms2_settings, loading, error } = useContext(AppContext);
const loadOptions = useCallback(async () => await get_icms2_settings(), []);
const [ready, setReady] = useState(false);
const onErrorHandle = () => {
setReady(false);
console.log(ready);
console.log("Error " + error);
};
if (!ready) {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<ActivityIndicator />
<AppLoading
startAsync={loadOptions}
onError={error => console.log(error)}
onFinish={() => {
setReady(true);
}}
/>
</View>
);
} else if (error) {
return <ErrorView handle={onErrorHandle} />;
} else {
return <AppNav />;
}
};