-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
218 lines (202 loc) · 5.96 KB
/
App.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import React from 'react';
import { StyleSheet, AsyncStorage, Dimensions, View, Alert, TouchableHighlight } from 'react-native';
import {connect} from 'react-redux';
import { Block, Text, Button } from './components';
import { Overlay, Avatar } from 'react-native-elements';
import { theme } from './constants';
import { createRootNavigator } from "./navigation/router";
import { initAppWithRealm } from './store/actions/loginActions';
const { width, height } = Dimensions.get('window');
console.disableYellowBox = true;
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isLoadingComplete: false,
visible: false,
match: {
name: 'Freddie Mercury',
matches: 2,
tags: [
{
name: 'Marvel',
matched: true,
},
{
name: 'DC Comix',
matched: true,
},
]
}
};
}
initializeApp = async () => {
const isRegistered = await this.props.initApplication()
if (isRegistered) {
this.props.getCurrentTopics()
this.props.getAllMatches()
}
}
componentDidMount() {
this.initializeApp()
}
render() {
const { signedIn, checkedSignIn } = this.props.login;
const { visible, match, loading } = this.state;
if (!checkedSignIn) {
return null
}
const Navigation = createRootNavigator(signedIn);
return (
<Block white>
<Navigation
signedIn={signedIn}
handleChange={this.handleChange}
/>
{
visible
?
<Overlay
isVisible
onBackdropPress={()=>{this.setState({visible: false})}}
overlayStyle={styles.overlayContainer}
borderRadius={16}
height="auto"
>
<Block style={styles.avatarContainer}>
<Avatar
rounded
source={{
uri:
'https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg',
}}
containerStyle={styles.avatar}
avatarStyle={styles.avatarImage}
/>
</Block>
<View style={{paddingHorizontal:14, marginTop: 42}}>
<Text center h3 notBlack bold style={{marginTop:20, marginHorizontal: 14}}>{match.name}</Text>
<Text center subhead notBlack style={{marginTop:8, marginHorizontal: 20}}>You have a match by {match.matches} tags</Text>
<Block style={styles.tagContainer}>
{
match.tags.map((l,i) => (
l.matched
?
<Button
key={i}
style={styles.matchedTag}>
<Text caption white center>{l.name}</Text>
</Button>
:
<Button
key={i}
style={styles.dismatchedTag}>
<Text caption blue center>{l.name}</Text>
</Button>
))
}
</Block>
<Block style={styles.buttonContainer}>
<Button style={styles.closeButton}
onPress={()=>{this.setState({visible: false})}}
>
{loading ?
<ActivityIndicator size="small" color="white" /> :
<Text headline bold blue center>Close</Text>
}
</Button>
<Button gradient style={styles.confirmButton}
onPress={() => {Alert.alert('save profile')}}
>
{loading ?
<ActivityIndicator size="small" color="white" /> :
<Text headline bold white center>Save</Text>
}
</Button>
</Block>
</View>
</Overlay>
:
null
}
</Block>
);
}
}
const styles = StyleSheet.create({
avatarContainer: {
alignSelf: 'center',
position: 'absolute',
top: -55
},
avatar: {
width: 110,
height: 110,
borderRadius: 50,
overflow: 'hidden',
borderColor: 'white',
borderStyle: 'solid',
borderWidth: 3,
},
overlayContainer: {
marginHorizontal: 64,
paddingBottom: 15.67,
paddingHorizontal: 0,
flexDirection: 'column',
alignSelf: 'center',
},
tagContainer: {
flex:0,
flexDirection: "row",
justifyContent: 'space-evenly',
flexWrap: 'wrap',
marginTop: 12,
},
matchedTag: {
backgroundColor: theme.colors.blue,
borderRadius: 16,
overflow: 'hidden',
height: 24,
paddingVertical: 4,
paddingHorizontal: 16,
marginHorizontal: 2,
},
buttonContainer: {
flex: 0,
marginTop:15.67,
},
closeButton: {
backgroundColor: theme.colors.white,
borderColor: theme.colors.blue,
borderWidth: 1,
borderRadius: 8,
overflow: 'hidden'
},
text: {
textAlign: 'center'
},
button: {
height: 60,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#0b7eff'
},
buttonText: {
color: 'white'
}
});
function mapStateToProps (state) {
return {
login: state.login,
}
}
function mapDispatchToProps (dispatch) {
return {
initApplication: () => dispatch(initAppWithRealm()),
getCurrentTopics: () => dispatch(getCurrentTopics()),
}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(App)