-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathProfileLoginScreen.js
647 lines (619 loc) · 21.9 KB
/
ProfileLoginScreen.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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
import React, { Component } from 'react'
import { View, Text, TextInput, SectionList, RefreshControl, Keyboard, Image, Linking, TouchableOpacity, ScrollView, Dimensions, Platform, StatusBar } from 'react-native'
import PropTypes from 'prop-types'
import Modal from "react-native-modal"
import Button from '../../components/Button'
import LogoutButton from '../../containers/LogoutButton'
import HrefButton from '../../components/HrefButton'
import CloseButton from '../../components/CloseButton'
import StudentListItem from '../../components/listItems/StudentListItem'
import StudentCard from '../../containers/StudentCardContainer'
import StudentList from '../../containers/StudentListContainer'
import Icon from 'react-native-vector-icons/FontAwesome'
import LoadingView from '../../components/LoadingView'
import QRCode from 'react-native-qrcode'
const styles = {
listContainer: {
width: '100%',
height: '100%',
backgroundColor: '#fff'
},
welcomeContainer: {
paddingVertical: 20,
borderBottomColor: '#4c4c4c',
borderBottomWidth: 1
},
outerContainer: {
justifyContent: 'center',
alignItems: 'center',
width: '100%',
height: '100%',
backgroundColor: '#fff'
},
innerContainer: {
width: '80%'
},
loginBtn: {
width: '50%',
color: '#000'
},
h1: {
fontSize: 70,
textAlign: 'center'
},
h2: {
fontSize: 12,
textAlign: 'center',
color: global.arkadBlue,
marginTop: 18
},
inputContainer: {
height: 40,
borderTopColor: '#000',
backgroundColor: 'rgba(0, 43, 100, 0.2)',
borderRadius: 8,
marginTop: 8,
paddingLeft: 10
},
input: {
height: '100%',
width: '100%',
},
welcomeText: {
fontSize: 30,
textAlign: 'center',
color: global.arkadBlue,
marginBottom: 10
},
infoText: {
textAlign: 'center',
color: global.arkadBlue
},
image: {
height: 140,
width: 145,
marginTop: 15
},
imageContainer: {
justifyContent: 'center',
alignItems: 'center',
marginBottom: 20
},
createAccountContainer: {
justifyContent: 'center',
alignItems: 'center',
position: 'absolute',
height:'100%',
width:'100%',
},
createAccountView: {
height: Math.round(Dimensions.get('window').height)*0.85,
width:'100%',
backgroundColor: '#fff',
borderRadius:10
},
headerRightView: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
paddingLeft: 1
},
createAccountText: {
fontSize: 14,
color: global.arkadBlue,
marginBottom: 8
},
modalText: {
fontSize: 16,
color: '#fff'
},
cardImage: {
top: 0,
right: 0,
width: 125,
height: 125,
},
button: {
paddingRight: 8,
paddingLeft: 12,
paddingVertical: 8,
alignItems: 'center',
justifyContent: 'center'
},
buttonText: {
right: 0,
fontSize: 12,
color: global.arkadGray
},
helpContainer: {
justifyContent: 'center',
alignItems: 'center',
position: 'absolute',
width:'100%',
},
helpView: {
height: Math.round(Dimensions.get('window').height)*0.85,
width:'100%',
backgroundColor: '#fff',
borderRadius:10,
},
qrModal: {
height:'100%',
width:'100%',
backgroundColor: '#fff',
borderRadius:10,
},
text: {
fontSize: 16,
color: '#fff'
},
headerIcon: {
paddingHorizontal: 7,
alignItems: 'center'
},
hostImage: {
width: 60,
height: 60,
borderRadius: 8,
marginLeft: 5,
marginRight: 20
},
qrText: {
textAlign: 'center',
fontSize: 14,
width: '100%',
marginBottom: 20,
color: global.arkadBlue
},
}
const { header, buttonText, headerIcon, bar, title, scrollViewContent, listContainer, welcomeContainer, outerContainer, innerContainer, loginBtn, h1, h2, input,
welcomeText, infoText, image, imageContainer, createAccountContainer, createAccountText, createAccountView, headerRightView, modalText, cardImage, button, helpView, helpContainer, text, hostImage, inputContainer, qrText, qrModal } = styles
class ProfileLoginScreen extends Component {
constructor(props){
super(props)
this.state = {
username: '',
password: '',
createAccount: false,
logedIn: false,
showRemoveModal: false,
showCreateAccountModal: false,
showHelpModal: false,
showStudentHelpModal: false,
showStudentQRModal: false,
student: false,
student_id: 0,
}
}
componentDidMount() {
this.props.navigation.setParams({
header: null,
})
{!this.props.companyLogedIn
? (this.setState({
student: true
})
)
: (this.setState({
student: false
})
)
}
}
async handlePress() {
await this.props.loadLogin(this.state.username, this.state.password)
if (this.props.logedIn == false) {
return
}
this.fetchBlips()
this.setState({
password: '',
})
}
async fetchBlips() {
await this.props.getMyInfo()
const windowWidth = Dimensions.get('window').width
if (!this.props.companyLogedIn) {
this.props.navigation.setParams({
header: undefined,
headerRight: (
<View style={{flex: 1, flexDirection: 'row', justifyContent: 'center'}}>
{Platform.OS === 'android' ?
<TouchableOpacity style={button} onPress={() => this.toggleStudentQRModal()}>
{ windowWidth < 350 ?
[<Icon style={[headerIcon, {marginLeft: 0}]} name='qrcode' size={14} color='#fff'/>,
<Text style={[buttonText, {fontSize: 9, marginTop: 3}]}>QR-Code</Text>]
: [<Icon style={headerIcon} name='qrcode' size={20} color='#fff'/>,
<Text style={buttonText}>QR-Code</Text>]}
</TouchableOpacity>
: null}
<TouchableOpacity style={button} onPress={() => this.toggleStudentHelpModal()}>
{ windowWidth < 350 ?
[<Icon style={[headerIcon, {paddingHorizontal: 0}]} name='question' size={16} color='#fff'/>,
<Text style={[buttonText, {fontSize: 9}]}>Help</Text>]
: [<Icon style={headerIcon} name='question' size={21} color='#fff'/>,
<Text style={buttonText}>Help</Text>]}
</TouchableOpacity>
<LogoutButton navigation={this.props.navigation} />
</View>
),
headerLeft: (
Platform.OS === 'android' ? null :
<View style={{flex: 1, flexDirection: 'row', justifyContent: 'center'}}>
<TouchableOpacity style={button} onPress={() => this.toggleStudentQRModal()}>
{ windowWidth < 350 ?
[<Icon style={[headerIcon, {marginLeft: 0}]} name='qrcode' size={14} color='#fff'/>,
<Text style={[buttonText, {fontSize: 9, marginTop: 3}]}>QR-Code</Text>]
: [<Icon style={headerIcon} name='qrcode' size={20} color='#fff'/>,
<Text style={buttonText}>QR-Code</Text>]}
</TouchableOpacity>
</View>
)
})
}
this.checkBlips()
}
async checkBlips() {
if (this.props.companyLogedIn) {
const windowWidth = Dimensions.get('window').width
await this.props.getBlips()
this.props.navigation.setParams({
header: undefined,
headerRight: (
<View style={{flex: 1, flexDirection: 'row'}}>
<TouchableOpacity style={button} onPress={() => this.toggleHelpModal()}>
{ windowWidth < 350 ?
[<Icon style={[headerIcon, {paddingHorizontal: 0}]} name='question' size={16} color='#fff'/>,
<Text style={[buttonText, {fontSize: 9}]}>Help</Text>]
: [<Icon style={headerIcon} name='question' size={21} color='#fff'/>,
<Text style={buttonText}>Help</Text>]}
</TouchableOpacity>
<LogoutButton navigation={this.props.navigation} />
</View>
)
})
}
}
toggleCreateAccountModal() {
this.setState({ showCreateAccountModal: !this.state.showCreateAccountModal });
}
toggleRemoveModal() {
this.setState({ showRemoveModal: !this.state.showRemoveModal });
}
toggleHelpModal() {
this.setState({ showHelpModal: !this.state.showHelpModal });
}
toggleStudentHelpModal() {
this.setState({ showStudentHelpModal: !this.state.showStudentHelpModal });
}
toggleStudentQRModal() {
this.setState({ showStudentQRModal: !this.state.showStudentQRModal });
}
createAccountView() {
return(
<View>
<Modal onBackdropPress={() => this.setState({ showCreateAccountModal: false })} backdropTransitionOutTiming={0} isVisible={this.state.showCreateAccountModal} style={{ flex:1, alignItems: 'center', justifyContent: 'center'}}>
<View style={createAccountContainer}>
<View style={createAccountView}>
<ScrollView>
<View style={{marginVertical: 20, marginHorizontal: 20}}>
<View style={{justifyContent: 'center',
alignItems: 'center', marginBottom:30}}>
<Text style={{fontSize: 30, color:global.arkadBlue, fontWeight: 'bold'}}>
Need an account?
</Text>
</View>
<View>
<Text style={[createAccountText, {fontWeight: 'bold', fontSize:18}]}>
Student
</Text>
<Button title='Sign up here' onPress={() => Linking.openURL('https://arkad-nexpo.herokuapp.com/signup')}>
</Button>
</View>
<View style={{marginTop: 20}}>
<Text style={[createAccountText, {fontWeight: 'bold', fontSize:18}]}>
Company
</Text>
<Text style={createAccountText}>
Check if any of your co-workers has been invited,
if so they can invite you. Check our support page to read more about how it works.
</Text>
<View style={{marginBottom: 20}}>
<CloseButton onPress={() => Linking.openURL('https://www.arkadtlth.se/scan/')} title='Go to Support Page' />
</View>
<Text style={createAccountText}>
If none of your co-workers has been invited email our support.
</Text>
<View style={{marginBottom: 10}}>
<CloseButton onPress={() => Linking.openURL('mailto:[email protected]')} title='Send Email to Support'/>
</View>
</View>
</View>
<View style={{
justifyContent: 'center',
alignItems: 'center',
bottom:0,
width:'100%',
marginBottom:20,
marginTop: 10}}>
<View style={{width:'40%'}}>
<CloseButton title='Close'
onPress={() => this.toggleCreateAccountModal()}
showIcon={false}
/>
</View>
</View>
</ScrollView>
</View>
</View>
</Modal>
</View>
)
}
loginView() {
return (
<View>
<View style={outerContainer}>
<View style={innerContainer}>
<View style={imageContainer}>
<Image
style={image}
source={require('../../../resources/img/arkad_logo.png')}
/>
<Text style={{fontStyle: 'italic', marginTop: 16, fontSize: 20 }}> Scanning System </Text>
</View>
<View style={inputContainer}>
<TextInput
underlineColorAndroid={'transparent'}
style={input}
placeholder="Email"
placeholderTextColor = 'gray'
autoCapitalize = 'none'
autoCompleteType={'email'}
keyboardType={'email-address'}
value={this.state.username}
onChangeText={(text) => this.setState({username: text})}
/>
</View>
<View style={[inputContainer, {marginBottom: 20}]}>
<TextInput
underlineColorAndroid={'transparent'}
style={input}
placeholder="Password"
placeholderTextColor = 'gray'
secureTextEntry={true}
autoCompleteType={'password'}
value={this.state.password}
onChangeText={(text) => this.setState({password: text})}
/>
</View>
<Button title='Login'
onPress={() => this.handlePress()}
loading={this.props.loading}
/>
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<TouchableOpacity style={{width:'70%'}} onPress={() => this.toggleCreateAccountModal()}>
<Text style={h2}>
Need an account?
</Text>
</TouchableOpacity>
<TouchableOpacity style={{width:'70%'}} onPress={() => Linking.openURL('https://arkad-nexpo.herokuapp.com/forgot-password')}>
<Text style={h2}>
Forgot your password?
</Text>
</TouchableOpacity>
</View>
</View>
</View>
{ this.createAccountView() }
</View>
)
}
gotoFAQ() {
this.toggleHelpModal()
this.props.navigation.navigate('Faq')
}
gotoStudentFAQ() {
this.toggleStudentHelpModal()
this.props.navigation.navigate('Faq')
}
studentHelpView() {
return(
<View style={{ backgroundColor: 'pink' }}>
<Modal onBackdropPress={() => this.setState({ showStudentHelpModal: false })} backdropTransitionOutTiming={0} isVisible={this.state.showStudentHelpModal} style={{ flex:1, alignItems: 'center', justifyContent: 'center'}}>
<View style={helpView}>
<ScrollView>
<View style={{marginVertical: 20, marginHorizontal: 20}}>
<View style={{justifyContent: 'center',
alignItems: 'center', marginBottom:20}}>
<Text style={{fontSize: 30, color:global.arkadBlue, fontWeight: 'bold'}}>
Need help?
</Text>
</View>
<View>
<Text style={[createAccountText, {fontWeight: 'bold', fontSize:18}]}>
How does the card work?
</Text>
<Text style={createAccountText}>
Click the card to see your QR-code. Companies see the same card as you once they scan you!
</Text>
<CloseButton title='Learn more about the system' onPress={() => Linking.openURL('https://www.arkadtlth.se/scan')}></CloseButton>
</View>
<View style={{marginTop: 15}}>
<Text style={[createAccountText, {fontWeight: 'bold', fontSize:18}]}>
Can I add a profile-picture?
</Text>
<Text style={createAccountText}>
Unfortunately not yet, but we are adding that feature soon!
</Text>
</View>
<View style={{marginTop: 15, marginBottom:50}}>
<Text style={[createAccountText, {fontWeight: 'bold', fontSize:18}]}>
Changing your information
</Text>
<Button title='Edit Profile' onPress={() => Linking.openURL('https://arkad-nexpo.herokuapp.com/user')}></Button>
</View>
</View>
<View style={{
justifyContent: 'center',
alignItems: 'center',
bottom:0,
position: 'absolute',
width:'100%',
marginBottom:20}}>
<View style={{width:'40%'}}>
<CloseButton
title='Close'
onPress={() => this.toggleStudentHelpModal()}
showIcon={false}
/>
</View>
</View>
</ScrollView>
</View>
</Modal>
</View>
)
}
studentQRView() {
return(
<View>
<Modal onBackdropPress={() => this.setState({ showStudentQRModal: false })} backdropTransitionOutTiming={0} isVisible={this.state.showStudentQRModal} style={{ flex:1, alignItems: 'center', justifyContent: 'center'}}>
<View style={helpContainer}>
<View style={qrModal}>
<View style={{flex: 1, flexDirection: 'column', width: '100%', alignItems: 'center', justifyContent: 'center'}}>
<Text style={[qrText, { marginTop: 20, fontWeight: 'bold' }]}>
Your personal QR-code.
</Text>
<Text style={qrText}>
Go share it with your favourite companies!
</Text>
{ this.props.myInfo.student != undefined ?
<View style={{ marginTop: 10, marginBottom: 25 }}>
<QRCode
value={'https://www.arkadtlth.se/wrong-qr/' + this.props.myInfo.student.id.toString()}
size={200}
bgColor='rgb(0, 43, 100)'
fgColor='#fff'
/>
</View>
: null}
</View>
<View style={{
justifyContent: 'center',
alignItems: 'center',
width:'100%',
marginBottom:20,
marginTop: 10}}>
<View style={{width:'40%'}}>
<CloseButton title='Close'
onPress={() => this.toggleStudentQRModal()}
showIcon={false}
/>
</View>
</View>
</View>
</View>
</Modal>
</View>
)
}
helpView() {
return(
<View>
<Modal onBackdropPress={() => this.setState({ showHelpModal: false })} backdropTransitionOutTiming={0} isVisible={this.state.showHelpModal} style={{ flex:1, alignItems: 'center', justifyContent: 'center'}}>
<View style={helpContainer}>
<View style={helpView}>
<ScrollView>
<View style={{marginVertical: 20, marginHorizontal: 20}}>
<View style={{justifyContent: 'center',
alignItems: 'center', marginBottom:20}}>
<Text style={{fontSize: 30, color:global.arkadBlue, fontWeight: 'bold'}}>
Need help?
</Text>
</View>
<View>
<Text style={[createAccountText, {fontWeight: 'bold', fontSize:18}]}>
Company Host
</Text>
<Text style={createAccountText}>
Need to get in touch with your company host? Below are the contact details.
</Text>
<View style={{flexDirection: 'row', marginTop: 7, marginBottom: 7}}>
<Image
style={hostImage}
source={require('../../../resources/img/arkadTeam/default.png')}
/>
<Text style={createAccountText}>not set {"\n"} not set {"\n"} not set </Text>
</View>
<Text style={createAccountText}>
If you need help during the fair and can't reach your host, contact your closest Infodesk.
</Text>
</View>
<View>
<Text style={[createAccountText, {fontWeight: 'bold', fontSize:18}]}>
Scanning system
</Text>
<Text style={createAccountText} >
<Text>Want to learn how the scanning system works? You can find the manual on our support page.</Text>
</Text>
<Button title='Go to Support Page' onPress={() => Linking.openURL('https://www.arkadtlth.se/scan/')}></Button>
</View>
<View style={{marginTop: 15, marginBottom:50}}>
<Text style={[createAccountText, {fontWeight: 'bold', fontSize:18}]}>
Other questions
</Text>
<Button title='Go to FAQ' onPress={() => this.gotoFAQ()}></Button>
</View>
</View>
<View style={{
justifyContent: 'center',
alignItems: 'center',
bottom:0,
position: 'absolute',
width:'100%',
marginBottom:20}}>
<View style={{width:'40%'}}>
<CloseButton
title='Close'
onPress={() => this.toggleHelpModal()}
showIcon={false}
/>
</View>
</View>
</ScrollView>
</View>
</View>
</Modal>
</View>
)
}
loadHome() {
if (this.props.companyLogedIn != null) {
if (!this.props.companyLogedIn) {
return <StudentCard student={this.state.student} navigation={this.props.navigation} typeLogedin={this.props.companyLogedIn}/>
} else {
if (!this.props.blips_loading) {
return <StudentList navigation={this.props.navigation} isLoading={this.props.loading} cameraPermissionGiven={this.props.cameraPermissionGiven} setCameraPermission={this.props.setCameraPermission}/>
}
}
} else {
return <View style={{alignItems: 'center', justifyContent: 'center', height: '100%', width: '100%'}}><LoadingView /></View>
}
}
render() {
return(
<View>
{ this.props.logedIn ? this.loadHome() : this.loginView()}
{ this.helpView() }
{ this.studentHelpView() }
{ this.props.logedIn && !this.props.companyLogedIn ? this.studentQRView() : null }
</View>
)
}
}
ProfileLoginScreen.propTypes = {
navigation: PropTypes.shape({ navigate: PropTypes.func.isRequired }).isRequired
}
export default ProfileLoginScreen