-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
294 lines (281 loc) · 7.29 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
import React, { useState } from 'react';
import {
View,
Text,
StyleSheet,
Dimensions,
TouchableWithoutFeedback,
ScrollView,
TouchableOpacity
} from 'react-native';
import { useFonts } from '@use-expo/font';
import { AppLoading } from 'expo';
import {
Fontisto,
MaterialCommunityIcons,
FontAwesome
} from '@expo/vector-icons';
import DateTimePickerModal from 'react-native-modal-datetime-picker';
import moment from 'moment';
import * as WebBrowser from 'expo-web-browser';
const customFont = {
'Press-Start2p': require('./assets/fonts/PressStart2P-Regular.ttf')
};
const W = Dimensions.get('window').width;
export default function App() {
const [isLoaded] = useFonts(customFont);
const [pickedDate, setPickedDate] = useState(null);
const [isDatePickerVisible, setDatePickerVisibility] = useState(false);
const [days, setDays] = useState('');
function showDatePicker() {
setDatePickerVisibility(true);
}
function hideDatePicker() {
setDatePickerVisibility(false);
}
function handleConfirm(date) {
// console.log('A date has been picked: ', date);
hideDatePicker();
setPickedDate(date);
}
function daysRemaining() {
let eventdate = moment(pickedDate);
let todaysdate = moment();
let remainingDays = todaysdate.diff(eventdate, 'days');
setDays(remainingDays);
return remainingDays;
}
function renderAchievements() {
if (days > 1 && days < 5) {
return (
<>
<MaterialCommunityIcons
name="guy-fawkes-mask"
color="#000"
size={54}
/>
<Text style={styles.resultText}>
You are Quarantine Noob. Don't forget to wear a mask. Keep
self-isolating.
</Text>
</>
);
} else if (days >= 5 && days <= 7) {
return (
<>
<MaterialCommunityIcons name="glass-wine" color="#000" size={54} />
<Text style={styles.resultText}>
Quarantine Connoisseur. Welcome to the (literal) dark side!
</Text>
</>
);
} else if (days >= 8 && days <= 15) {
return (
<>
<MaterialCommunityIcons
name="seat-legroom-reduced"
color="#000"
size={54}
/>
<Text style={styles.resultText}>
Quarantine Proficient. AKA “What is pants?”
</Text>
</>
);
} else if (days >= 16 && days <= 22) {
return (
<>
<MaterialCommunityIcons
name="star-circle-outline"
color="#000"
size={54}
/>
<Text style={styles.resultText}>
Quarantine Veteran. #StayHome became your life motto.
</Text>
</>
);
} else if (days >= 23) {
return (
<>
<FontAwesome name="paint-brush" color="#000" size={54} />
<Text style={styles.resultText}>
THE ULTIMATE QUARANTINE PRO! You are part of the solution - thank
you!
</Text>
</>
);
} else
return (
<Text style={styles.resultText}>Your level will be shown here.</Text>
);
}
function openWebBrowser() {
WebBrowser.openBrowserAsync('https://jscrambler.com/');
}
if (!isLoaded) {
return <AppLoading />;
}
return (
<View style={styles.container}>
<ScrollView
contentContainerStyle={{
justifyContent: 'center',
alignItems: 'center'
}}
>
<Text style={styles.title}>{`Are You a Quarantine Pro?`}</Text>
<TouchableWithoutFeedback onPress={showDatePicker}>
<View style={styles.pickerContainer}>
<Fontisto style={styles.icon} name="calendar" size={48} />
<Text
style={styles.pickerText}
>{`Tap here to\nselect a date`}</Text>
</View>
</TouchableWithoutFeedback>
<DateTimePickerModal
isVisible={isDatePickerVisible}
mode="date"
onConfirm={handleConfirm}
onCancel={hideDatePicker}
headerTextIOS="When did you start isolating?"
/>
<View style={styles.showDateContainer}>
<Text style={styles.showDateText}>
You started isolating on{' '}
{pickedDate && (
<Text style={styles.showDateText}>
{moment(pickedDate).format('YYYY-MM-DD')}.
</Text>
)}
</Text>
<TouchableWithoutFeedback onPress={daysRemaining}>
<View style={styles.evaluateButtonContainer}>
<Text style={styles.evaluateButtonText}>Check your level</Text>
</View>
</TouchableWithoutFeedback>
</View>
<View style={styles.resultContainer}>{renderAchievements()}</View>
<TouchableOpacity onPress={openWebBrowser}>
<Text style={styles.footerText}>
{`Built with `}
<MaterialCommunityIcons
name="heart-circle"
color="#000"
size={30}
/>{' '}
by Jscrambler & @amanhimself
</Text>
</TouchableOpacity>
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#ffbd12'
},
scrollContainer: {
justifyContent: 'center',
alignItems: 'center'
},
title: {
fontFamily: 'Press-Start2p',
fontSize: 20,
marginTop: 50,
paddingHorizontal: 20,
lineHeight: 30
},
pickerContainer: {
marginTop: 20,
backgroundColor: '#00c6ae',
width: W / 1.2,
height: W / 4,
borderRadius: 10,
borderWidth: 1,
borderColor: '#000',
borderBottomWidth: 5,
borderBottomColor: '#000',
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row'
},
pickerText: {
fontFamily: 'Press-Start2p',
fontSize: 14,
paddingHorizontal: 10,
lineHeight: 20
},
icon: {
color: '#000'
},
showDateContainer: {
marginTop: 20,
backgroundColor: '#F95A2C',
width: W / 1.2,
height: W / 2,
borderRadius: 10,
borderWidth: 1,
borderColor: '#000',
alignItems: 'center'
},
showDateText: {
fontFamily: 'Press-Start2p',
fontSize: 14,
padding: 10,
marginTop: 20,
lineHeight: 20
},
evaluateButtonContainer: {
marginTop: 20,
backgroundColor: '#1947E5',
width: W / 1.4,
height: W / 6,
borderRadius: 10,
borderWidth: 1,
borderColor: '#000',
borderBottomWidth: 5,
borderBottomColor: '#000',
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row'
},
evaluateButtonText: {
color: '#fff',
fontFamily: 'Press-Start2p',
fontSize: 14,
paddingHorizontal: 10,
lineHeight: 20
},
resultContainer: {
marginTop: 20,
backgroundColor: '#FF89BB',
width: W / 1.2,
height: W / 2,
borderRadius: 10,
borderWidth: 1,
borderColor: '#000',
justifyContent: 'center',
alignItems: 'center'
},
resultText: {
color: '#fff',
fontFamily: 'Press-Start2p',
fontSize: 16,
padding: 15,
lineHeight: 20
},
footerText: {
color: '#333',
fontSize: 14,
fontFamily: 'Press-Start2p',
alignSelf: 'center',
// position: 'absolute',
marginTop: 40,
padding: 25,
lineHeight: 30,
textDecorationLine: 'underline',
textDecorationStyle: 'dotted'
}
});