-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
69 lines (62 loc) · 1.7 KB
/
Copy pathApp.js
File metadata and controls
69 lines (62 loc) · 1.7 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
import React, { Component } from 'react';
import firebase from 'firebase';
import { ScrollView, View } from 'react-native';
import { LoginForm, AlbumList } from './src/components/views';
import { Button, CardSection, Header, Spinner } from './src/components/common';
// Create a component
class App extends Component {
state = { loggedIn: null };
componentWillMount() {
// Initialize Firebase
const config = {
apiKey: 'AIzaSyDeYNMXMVYbxFMo_OsVkKHRChc9Pt7iiLE',
authDomain: 'health-score-e2149.firebaseapp.com',
databaseURL: 'https://health-score-e2149.firebaseio.com',
projectId: 'health-score-e2149',
storageBucket: 'health-score-e2149.appspot.com',
messagingSenderId: '866707380105'
};
firebase.initializeApp(config);
firebase.auth().onAuthStateChanged((user) => {
if (user) {
this.setState({ loggedIn: true });
} else {
this.setState({ loggedIn: false });
}
});
}
renderContent() {
switch (this.state.loggedIn) {
case true:
return (
<ScrollView >
<Header headerText={'Health Score'} />
<AlbumList />
<CardSection>
<Button onPress={() => firebase.auth().signOut()}>
Log Out
</Button>
</CardSection>
</ScrollView>
);
case false:
return (
<View>
<Header headerText={'Authentication'} />
<LoginForm />
</View>
);
default:
return <Spinner size={'large'} />
}
}
render() {
return (
<View>
{this.renderContent()}
</View>
);
}
}
// Render the component
export default App;