This repository was archived by the owner on May 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
123 lines (104 loc) · 2.89 KB
/
Copy pathApp.js
File metadata and controls
123 lines (104 loc) · 2.89 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
import React, {Fragment, Component} from 'react';
import {
View,
SafeAreaView,
StyleSheet
} from 'react-native';
//import { createAppContainer } from 'react-navigation';
//import { createStackNavigator } from 'react-navigation-stack';
import AsyncStorage from '@react-native-community/async-storage';
import Header from './Commons/Components/Header'
import FirstLogin from "./Commons/Components/FirstLogin"
import HomePage from "./Commons/Components/HomePage"
import MenuRight from "./Commons/Components/MenuRight"
export default class App extends Component {
constructor(props) {
super(props)
this.isFirstLog()
}
state = {
isFirstLogin: undefined,
city: '',
modalVisible: false
}
changeView = (city) => {
AsyncStorage.setItem("city", city);
this.setState({
city: city,
isFirstLogin: false
})
}
showModal = () => {
this.setState({
modalVisible: !this.state.modalVisible
})
}
componentDidMount(): void {
}
isFirstLog = async () => {
try {
await AsyncStorage.getItem("city").then((city) => {
if (city !== undefined && city !== null && city !== '') {
this.changeView(city)
} else {
this.setState({
isFirstLogin: true
})
}
}).done();
} catch (e) {
console.log('error logged in isAlreadyJoined()')
}
}
render() {
let mainComponent = null
if(this.state.isFirstLogin)
mainComponent = (
<View style={styles.firstLoginContainer} >
<FirstLogin style={styles.firstLogin} changeView={this.changeView}/>
</View>)
;
else if(this.state.isFirstLogin === false) {
mainComponent = (
<HomePage style={styles.firstLogin} city={this.state.city}/>
)
}
return (
<Fragment>
<SafeAreaView style={styles.SafeAreaMain}>
<Header showModal={this.showModal}/>
{mainComponent}
<MenuRight showModal={this.showModal} modalVisible={this.state.modalVisible}/>
</SafeAreaView>
</Fragment>
);
}
};
const styles = StyleSheet.create({
SafeAreaMain: {
flex:1,
flexDirection : 'column',
justifyContent: 'flex-start'
},
Header: {
flex: 1
},
scrollViewArea: {
marginTop: 24,
marginBottom: 24,
},
firstLoginContainer: {
flex:6,
flexDirection : 'column',
justifyContent: 'flex-start',
marginTop: 100
},
firstLogin: {
flex:5,
},
menu:{
position: 'absolute',
top: 0,
right: 0
}
});