-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
127 lines (114 loc) · 3.54 KB
/
App.js
File metadata and controls
127 lines (114 loc) · 3.54 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import React, { Component } from 'react';
import { View, Text, Settings } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import LoginScreen from './src/screens/LoginScreen';
import SignUpStudent from './src/screens/SignUpStudent';
import SignUpCompany from './src/screens/SignUpCompany';
import HomeScreen from './src/screens/HomeScreen';
import ForgotUsername from './src/screens/ForgotUsername';
import ForgotPassword from './src/screens/ForgotPassword';
import SettingsScreen from './src/screens/SettingsScreen';
import * as firebase from 'firebase';
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyBYSmwXc4ga5dBQdfeFVdQEMhqUo6N7auY",
authDomain: "untitled-oasis-project.firebaseapp.com",
projectId: "untitled-oasis-project",
storageBucket: "untitled-oasis-project.appspot.com",
messagingSenderId: "36325963141",
appId: "1:36325963141:web:724186fe298dde6ea4c0ec",
measurementId: "G-VPR91JF27V"
};
if (firebase.apps.length === 0) {
firebase.initializeApp(firebaseConfig);
}
// const navigator = createStackNavigator(
// {
// Login: LoginScreen,
// SignUpStudent: SignUpStudent,
// SignUpCompany: SignUpCompany,
// Home: HomeScreen,
// ForgotUsername: ForgotUsername,
// ForgotPassword: ForgotPassword,
// Settings: SettingsScreen,
// },
// {
// initialRouteName: 'Login',
// defaultNavigationOptions: {
// title: 'Untitled Oasis Project',
// },
// }
// );
// export default createAppContainer(navigator);
const Stack = createStackNavigator();
const getUserData = async () => {
firebase
.database()
.ref('users/' + firebase.auth().currentUser.uid)
.once('value')
.then(snapshot => {
console.log(snapshot.val())
});
}
export class App extends Component {
constructor(props) {
super();
this.state = {
loaded: false,
};
}
componentDidMount() {
firebase.auth().onAuthStateChanged((user) => {
if (!user) {
this.setState({
loggedIn: false,
loaded: true,
});
} else {
this.setState({
loggedIn: true,
loaded: true,
});
}
});
}
render() {
const { loggedIn, loaded } = this.state;
if (!loaded) {
return (
<View style={{ flex: 1, justifyContent: 'center' }}>
<Text>Loading</Text>
</View>
);
}
if (!loggedIn) {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName='Login'>
<Stack.Screen
name='Login'
component={LoginScreen}
options={{ headerShown: false }}
/>
<Stack.Screen name='SignUpStudent' component={SignUpStudent} />
<Stack.Screen name='SignUpCompany' component={SignUpCompany} />
<Stack.Screen name='Home' component={HomeScreen} />
<Stack.Screen name='Settings' component={SettingsScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
return (
<NavigationContainer>
<Stack.Navigator initialRouteName='Home'>
<Stack.Screen name='Home' component={HomeScreen} />
<Stack.Screen name='Login' component={LoginScreen} />
<Stack.Screen name='Settings' component={SettingsScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
}
export default App;