-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
139 lines (124 loc) · 3.25 KB
/
Copy pathApp.js
File metadata and controls
139 lines (124 loc) · 3.25 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import React from 'react';
import {
Platform,
View,
StyleSheet,
TouchableOpacity,
ScrollView,
Text,
Switch
} from 'react-native';
import { PROVIDER_GOOGLE, PROVIDER_DEFAULT } from 'react-native-maps';
import SetMarker from './src/SetMarker';
import Login from './src/Login';
import Register from './src/Register';
import MarkerMap from './src/MarkerMap';
import t from 'tcomb-form-native';
t.form.Form.stylesheet.textbox.normal.width = 300;
t.form.Form.stylesheet.textbox.error.width = 300;
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
Component: null,
Claim: null
};
}
renderComponent([Component, title, AuthRequired]) {
return (
(AuthRequired && this.state.Claim || !AuthRequired && !this.state.Claim) && <TouchableOpacity
key={title}
style={styles.button}
onPress={() => this.setState({ Component })}
>
<Text>{title}</Text>
</TouchableOpacity>
);
}
renderBackButton() {
return (
<TouchableOpacity
style={styles.back}
onPress={() => this.setState({ Component: null })}
>
<Text style={{ fontWeight: 'bold', fontSize: 30 }}>←</Text>
</TouchableOpacity>
);
}
logOut(){
this.setState({ Claim: null });
}
renderComponents(components) {
const {
Component,
Claim
} = this.state;
return (
<View style={styles.container}>
{Component && <Component
returnMethod = {((comp) => this.setState({ Component: comp })).bind(this)}
getClaim = {(() => this.state.Claim).bind(this)}
setClaim = {((claim) => this.setState({ Claim: claim })).bind(this)}
provider={PROVIDER_GOOGLE} />}
{Component && this.renderBackButton()}
{!Component &&
<ScrollView
style={StyleSheet.absoluteFill}
contentContainerStyle={styles.scrollview}
showsVerticalScrollIndicator={false}
>
<Text style={{ fontWeight: 'bold', fontSize: 30 , paddingBottom : 30}}>WPAM</Text>
{components.map(component => this.renderComponent(component))}
</ScrollView>
}
{!Component && this.state.Claim &&
<TouchableOpacity
style={styles.back}
onPress={() => this.logOut()}
>
<Text>Wyloguj</Text>
</TouchableOpacity>
}
</View>
);
}
render() {
return this.renderComponents([
[Login, 'Logowanie', false],
[Register, 'Rejestracja', false],
[MarkerMap, 'Mapa', true],
[SetMarker, 'Dodaj zdjęcie!', true],
]);
}
}
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
justifyContent: 'flex-end',
alignItems: 'center',
},
scrollview: {
alignItems: 'center',
paddingVertical: 40,
},
button: {
flex: 1,
marginTop: 10,
backgroundColor: 'rgba(220,220,220,0.7)',
paddingHorizontal: 18,
paddingVertical: 12,
borderRadius: 20,
},
back: {
position: 'absolute',
top: 20,
left: 12,
backgroundColor: 'rgba(255,255,255,0.4)',
padding: 12,
borderRadius: 20,
width: 80,
alignItems: 'center',
justifyContent: 'center',
},
});
export default App;