-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
62 lines (55 loc) · 1.66 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React, { useEffect, useState } from "react";
import * as eva from "@eva-design/eva";
import { ApplicationProvider, IconRegistry } from "@ui-kitten/components";
import { EvaIconsPack } from "@ui-kitten/eva-icons";
import { AppNavigator, AuthNav } from "./navigation/app-navigator";
import { default as theme } from "./theme.json";
import { SafeAreaProvider } from "react-native-safe-area-context";
import Amplify, { Auth } from "aws-amplify";
import config from "./aws-exports";
import { NavigationContainer } from "@react-navigation/native";
Amplify.configure(config);
const app = () => {
const [isAuthenticating, setIsAuthenticating] = useState(true);
const [isAuthenticated, userHasAuthenticated] = useState(false);
useEffect(() => {
onLoad();
}, []);
async function onLoad() {
try {
await Auth.currentSession();
userHasAuthenticated(true);
}
catch(e) {
if (e !== 'No current user') {
alert(e);
}
}
setIsAuthenticating(false);
}
return (
!isAuthenticating &&
<>
<IconRegistry icons={EvaIconsPack} />
<ApplicationProvider {...eva} theme={{ ...eva.light, ...theme } }>
<SafeAreaProvider>
<NavigationContainer>
{!isAuthenticated
? (
// No token found, user isn't signed in
<AuthNav />
) : (
// User is signed in
<AppNavigator />
)}
</NavigationContainer>
</SafeAreaProvider>
</ApplicationProvider>
</>
);
};
export default app;
// if (state.isLoading) {
// // We haven't finished checking for the token yet
// return <SplashScreen />;
// }