-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
71 lines (66 loc) · 2.99 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
import 'react-native-gesture-handler';
import React, { Component, useEffect, useState } from 'react'
import { NavigationContainer } from '@react-navigation/native'
import {createAppContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
import { DashBoard, MoreInfo, LoginScreen, HomeScreen, RegistrationScreen, CovidScreen, VaccineScreen, MaternalScreen, OtherInfoScreen, FAQScreen, OurTeamScreen, LoadingScreen, InfoScreen1, Resource1, Favorites, StartingScreen, InterestForm1, InterestForm2} from './src/screens'
import {decode, encode} from 'base-64'
if (!global.btoa) { global.btoa = encode }
if (!global.atob) { global.atob = decode }
import { firebase } from './src/firebase/config'
const Stack = createStackNavigator();
export default function App() {
const [loading, setLoading] = useState(true)
const [user, setUser] = useState(null)
const [loggedin, setLoggedIn] = useState(false)
useEffect(() => {
const usersRef = firebase.firestore().collection('users')
firebase.auth().onAuthStateChanged(user => {
if (user) {
usersRef
.doc(user.uid)
.get()
.then((document) => {
const userData = document.data()
setUser(userData)
setLoading(false)
})
.catch((error) => {
setLoading(false)
});
} else {
setLoading(false)
}
});
//return firebase.auth().onAuthStateChanged(setLoggedIn);
}, []);
return (
<NavigationContainer>
<Stack.Navigator initialRouteName={user ? 'Home' : 'Login'}>
<Stack.Screen name="Home">
{props => <HomeScreen {...props} extraData={user}/>}
</Stack.Screen>
{/* <Stack.Screen name="Home" component={HomeScreen} /> */}
<Stack.Screen name="Login" component={LoginScreen} />
<Stack.Screen name="MoreInfo" component={MoreInfo} />
{/* <Stack.Screen name="Dashboard">
{props => <DashBoard {...props}/>}
</Stack.Screen> */}
<Stack.Screen name="DashBoard" component={DashBoard} />
<Stack.Screen name="Registration" component={RegistrationScreen} />
<Stack.Screen name="Covid-19" component={CovidScreen} />
<Stack.Screen name="Vaccine" component={VaccineScreen} />
<Stack.Screen name="Maternal" component={MaternalScreen} />
<Stack.Screen name="Other Info" component={OtherInfoScreen} />
<Stack.Screen name="FAQ" component={FAQScreen} />
<Stack.Screen name="Our Team" component={OurTeamScreen} />
<Stack.Screen name="InfoScreen1" component={InfoScreen1} />
<Stack.Screen name="Resource1" component={Resource1} />
<Stack.Screen name="Favorites" component={Favorites} />
<Stack.Screen name="StartingScreen" component={StartingScreen} />
<Stack.Screen name="InterestForm1" component={InterestForm1} />
<Stack.Screen name="InterestForm2" component={InterestForm2} />
</Stack.Navigator>
</NavigationContainer>
);
}