-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
103 lines (88 loc) · 2.95 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { StatusBar } from 'expo-status-bar';
import React, { Component } from 'react';
import { View, Text } from 'react-native'
import * as firebase from 'firebase'
import { Provider } from 'react-redux'
import { createStore, applyMiddleware } from 'redux'
import rootReducer from './redux/reducers'
import thunk from 'redux-thunk'
const store = createStore(rootReducer, applyMiddleware(thunk))
const firebaseConfig = {
apiKey: "AIzaSyCO38QdpD8CWdFX2_yyhvQn9ZY6ciaNM1s",
authDomain: "event-app-prototype.firebaseapp.com",
projectId: "event-app-prototype",
storageBucket: "event-app-prototype.appspot.com",
messagingSenderId: "641963620476",
appId: "1:641963620476:web:424407e94cb80a2d29f1f9",
measurementId: "G-6H0MXKXRCS"
};
if (firebase.apps.length === 0) {
firebase.initializeApp(firebaseConfig)
}
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import LandingScreen from './components/auth/Landing'
import RegisterScreen from './components/auth/Register'
import LoginScreen from './components/auth/Login'
import MainScreen from './components/Main'
import AddScreen from './components/main/Add'
import SaveScreen from './components/main/Save'
import CommentScreen from './components/main/Comment'
const Stack = createStackNavigator();
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="Landing">
<Stack.Screen name="Landing" component={LandingScreen} options={{ headerShown: false }} />
<Stack.Screen name="Register" component={RegisterScreen} />
<Stack.Screen name="Login" component={LoginScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
return (
<Provider store={store}>
<NavigationContainer >
<Stack.Navigator initialRouteName="Main">
<Stack.Screen name="Main" component={MainScreen} />
<Stack.Screen name="Add" component={AddScreen} navigation={this.props.navigation}/>
<Stack.Screen name="Save" component={SaveScreen} navigation={this.props.navigation}/>
<Stack.Screen name="Comment" component={CommentScreen} navigation={this.props.navigation}/>
</Stack.Navigator>
</NavigationContainer>
</Provider>
)
}
}
export default App