-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMyProfile.js
111 lines (104 loc) · 3.14 KB
/
MyProfile.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
104
105
106
107
108
109
110
111
import React, {Component} from 'react';
import {ActivityIndicator, FlatList} from 'react-native';
import {firebaseApp} from './App';
import { StyleProvider, Container, Header, Title, Content, Footer, FooterTab,
Button, Left, Right, Body, Icon, Text, List, ListItem} from 'native-base';
import getTheme from './native-base-theme/components';
import material from './native-base-theme/variables/material';
import MyEvents from './MyEvents';
import Settings from './Settings';
import SavedEvents from './SavedEvents';
export default class MyProfile extends Component {
constructor(props) {
super(props);
this.state = {
index: 0,
userEmail: null,
uid: null,
userName: null,
};
console.ignoredYellowBox = ['Setting a timer'];
}
goBack = () => {
this.setState({
index: 0
})
}
// autoupdates on new event
componentDidMount() {
firebaseApp.auth().onAuthStateChanged((user) => {
if (user) {
this.setState({userEmail: user.email, uid: user.uid});
} else {
// No user is signed in.
console.log('no user')
}
});
}
render() {
let AppComponent = null;
if (this.state.index === 1) {
AppComponent = MyEvents;
} else if (this.state.index === 2) {
AppComponent = SavedEvents;
} else if (this.state.index === 3) {
AppComponent = Settings; // placeholder for update profile
} else if (this.state.index === 4) {
AppComponent = Settings;
}
if (this.state.index === 0) {
return (
<StyleProvider style={getTheme(material)}>
<Container>
<Header>
<Body>
<Title>{this.state.userEmail}</Title>
</Body>
</Header>
<Content style={{backgroundColor: 'white'}}>
<List>
<ListItem icon onPress={() => this.setState({index: 1})}>
<Left>
<Icon name="calendar" />
</Left>
<Body>
<Text>My Events</Text>
</Body>
<Right>
<Icon name="arrow-forward" />
</Right>
</ListItem>
<ListItem icon onPress={() => this.setState({index: 2})}>
<Left>
<Icon name="heart" />
</Left>
<Body>
<Text>Saved Events</Text>
</Body>
<Right>
<Icon name="arrow-forward" />
</Right>
</ListItem>
<ListItem icon onPress={() => this.setState({index: 4})}>
<Left>
<Icon name="settings" />
</Left>
<Body>
<Text>Settings</Text>
</Body>
<Right>
<Icon name="arrow-forward" />
</Right>
</ListItem>
</List>
</Content>
</Container>
</StyleProvider>
);
} else {
return (
<AppComponent goBack={this.goBack} navigation={this.props.navigation}/>
);
}
}
}