-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
84 lines (65 loc) · 2.21 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
import React, {useState, useEffect, Fragment} from 'react';
import { Platform, SafeAreaView, View, LogBox } from 'react-native'
import AppNavigation from './App/Navigation/AppNavigation';
import LoginScreen from './App/Screens/LoginScreen';
import firebase from 'firebase';
import "firebase/auth";
import BackgroundGradient from './App/Components/BackgroundGradient';
import AppLoading from 'expo-app-loading';
import { useFonts } from 'expo-font';
import { ModalPortal } from 'react-native-modals';
LogBox.ignoreAllLogs();
export default function App() {
let [fontsLoaded] = useFonts({
'Montserrat': require('./App/Fonts/Montserrat-Regular.ttf'),
'Montserrat-Bold': require('./App/Fonts/Montserrat-Bold.ttf'),
'Montserrat-Light': require('./App/Fonts/Montserrat-Light.ttf'),
'Montserrat-Italic': require('./App/Fonts/Montserrat-Italic.ttf'),
});
const [loggedIn, setLoggedIn] = useState(false);
// Check out this link to learn more about firebase.auth()
// https://firebase.google.com/docs/reference/node/firebase.auth.Auth
useEffect(() => {
let unsubscribe = firebase.auth().onAuthStateChanged((user) => {
if (user) {
setLoggedIn(true);
} else {
setLoggedIn(false);
}
});
return () => {
unsubscribe()
}
}, []);
if (!fontsLoaded) {
return <AppLoading />;
}
if (loggedIn) {
return ( Platform.OS === 'ios' ?
<Fragment>
<ModalPortal />
<SafeAreaView style={{flex:0, backgroundColor: '#FDF0AF'}}/>
<SafeAreaView style={{flex:1}}>
<AppNavigation />
</SafeAreaView>
</Fragment>
:
<Fragment>
<View style={{flex:0, backgroundColor: '#FDF0AF'}}/>
<View style={{flex:1}}>
<AppNavigation />
</View>
</Fragment>
);
}
else {
return (
<Fragment>
<SafeAreaView style={{flex:0, backgroundColor: '#FDF0AF'}}/>
<SafeAreaView style={{flex:1}}>
<LoginScreen updateStatus={(val) => setLoggedIn(val)} setBioInfo={(val) => setBioInfoFilled(val)}/>
</SafeAreaView>
</Fragment>
);
}
}