-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
67 lines (61 loc) · 1.63 KB
/
Copy pathApp.js
File metadata and controls
67 lines (61 loc) · 1.63 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
import React, { Component } from "react";
import { View, Text, ImageBackground } from "react-native";
import LoginForm from "./components/LoginForm";
import Articles from "./components/Articles";
import BG from "./images/bg.jpeg";
import Loading from "./components/Loading";
//config
import { styles } from "./config/styles";
import firebase from "firebase";
class App extends Component {
constructor(props) {
super(props);
this.state = {
loggedIn: null,
};
}
componentDidMount() {
var firebaseConfig = {
apiKey: "AIzaSyCXKJnlTqV2VHXccz0FZ4AlDrm8qsUAH8U",
authDomain: "codenestadb.firebaseapp.com",
databaseURL: "https://codenestadb.firebaseio.com",
projectId: "codenestadb",
storageBucket: "codenestadb.appspot.com",
messagingSenderId: "840774146490",
appId: "1:840774146490:web:f59f7b66c27b5077362583",
};
// Initialize Firebase
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
firebase.auth().onAuthStateChanged((user) => {
if (user) {
this.setState({
loggedIn: true,
});
} else {
this.setState({
loggedIn: false,
});
}
});
}
renderContent = () => {
switch (this.state.loggedIn) {
case false:
return (
<ImageBackground style={styles.BGContainer} source={BG}>
<LoginForm />
</ImageBackground>
);
case true:
return <Articles />;
default:
return <Loading />;
}
};
render() {
return <View style={styles.container}>{this.renderContent()}</View>;
}
}
export default App;