generated from osamhack2020/Sample_Technology_ProjectName_TeamName
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
1273 lines (1212 loc) · 40.1 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
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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import ProgressCircle from 'react-native-progress-circle';
import { StyleSheet, NativeModules, SafeAreaView, Text, View, Image,
TouchableOpacity, PermissionsAndroid, Platform, Button, TextInput,
ImageBackground} from 'react-native';
import RadioForm, {RadioButton, RadioButtonInput, RadioButtonLabel} from 'react-native-simple-radio-button';
import DatePicker from 'react-native-datepicker';
import ToastExample from './ToastExample';
import DialogAndroid from 'react-native-dialogs';
import RNPickerSelect from 'react-native-picker-select';
import {Picker} from '@react-native-picker/picker';
//initName : 첫 시작화면
//lockedCondition : 잠금상태 확인변수
//permissionCheck : 권한 허용여부
var initName;
var lockedCondition = NativeModules.Block.checkBlockState();
var permissionCheck = NativeModules.Block.checkPermissionState();
renderBlockState = () => {
//상시 실행. 근데 이걸 계속 받아올 수 있는지 잘 모르겠음.
lockedCondition = NativeModules.Block.checkBlockState();
var renderingText =" ";
if(lockedCondition == true){
renderingText = <Text style={styles.lockStateText}>LOCKED</Text>
}
else{
renderingText = <Text style={styles.unlockStateText}>UNLOCKED</Text>
}
return renderingText;
}
calcSalary = (selectMilitary, Savings, corpProm ,sgtProm, usedMoney) => {
//월급계산하는 함수
//selectMilitary: 0:육군 1:해군 2:공군 3:해병대
//Savings: 한달에 넣는 적금
var firstMonth = 6;
var corpMonth = 6;
var armysgtMonth = 4;
var airforcesgtMonth = 7;
var navysgtMonth=6;
firstMonth -= corpProm;
corpMonth -=sgtProm;
let sumOfMoney = 0;
let savingMoney = 0;
let privateSalary = 408100;
let firstprivateSalary = 441700;
let corporalSalary = 488200;
let sergeantSalary = 540900;
let text1 = '총';
if (selectMilitary==0 || selectMilitary==3){
//육군, 해병대 월급 총액
var sumUsedMoney = usedMoney * 18;
armysgtMonth += (corpProm + sgtProm);
sumOfMoney=(privateSalary*2) + (firstprivateSalary*firstMonth) + (corporalSalary*corpMonth) + (sergeantSalary*armysgtMonth);
savingMoney = (Savings*18) * ((0.05*19)/24);
sumOfMoney+=savingMoney;
sumOfMoney-=sumUsedMoney;
}
else if(selectMilitary == 1){
//해군 월급 총액
var sumUsedMoney = usedMoney * 20;
navysgtMonth += (corpProm + sgtProm);
sumOfMoney=(privateSalary*2) + (firstprivateSalary*firstMonth) + (corporalSalary*corpMonth) + (sergeantSalary*navysgtMonth);
savingMoney = (Savings*20) * ((0.05*21)/24);
sumOfMoney+=savingMoney;
sumOfMoney-=sumUsedMoney;
}
else{
//공군 월급 총액
var sumUsedMoney = usedMoney * 21;
airforcesgtMonth += (corpProm + sgtProm);
sumOfMoney=(privateSalary*2) + (firstprivateSalary*firstMonth) + (corporalSalary*corpMonth) + (sergeantSalary*airforcesgtMonth);
savingMoney = (Savings*21) * ((0.05*22)/24);
sumOfMoney+=savingMoney;
sumOfMoney-=sumUsedMoney;
}
sumOfMoney=String(sumOfMoney);
var result = text1.concat(" ", sumOfMoney,"원을 모을 수 있습니다.");
return result
}
renderDayofweek = (Dayofweek) => {
//Dayofweek : 요일
var renderingText;
if(Dayofweek == 0){
renderingText =
<View style={styles.daysGroup}>
<Text style={styles.weekdays}>월</Text>
<Text style={styles.weekdays}>화</Text>
<Text style={styles.weekdays}>수</Text>
<Text style={styles.weekdays}>목</Text>
<Text style={styles.weekdays}>금</Text>
<Text style={styles.satday}>토</Text>
<Text style={{marginRight: 6, marginLeft: 6, color: '#e15858', fontSize: 20, textDecorationLine: 'underline'}}>일</Text>
</View>
}
else if(Dayofweek == 1){
//월요일
renderingText =
<View style={styles.daysGroup}>
<Text style={styles.todayText}>월</Text>
<Text style={styles.weekdays}>화</Text>
<Text style={styles.weekdays}>수</Text>
<Text style={styles.weekdays}>목</Text>
<Text style={styles.weekdays}>금</Text>
<Text style={styles.satday}>토</Text>
<Text style={styles.sunday}>일</Text>
</View>
}
else if(Dayofweek == 2){
renderingText =
<View style={styles.daysGroup}>
<Text style={styles.weekdays}>월</Text>
<Text style={styles.todayText}>화</Text>
<Text style={styles.weekdays}>수</Text>
<Text style={styles.weekdays}>목</Text>
<Text style={styles.weekdays}>금</Text>
<Text style={styles.satday}>토</Text>
<Text style={styles.sunday}>일</Text>
</View>
}
else if(Dayofweek == 3){
renderingText =
<View style={styles.daysGroup}>
<Text style={styles.weekdays}>월</Text>
<Text style={styles.weekdays}>화</Text>
<Text style={styles.todayText}>수</Text>
<Text style={styles.weekdays}>목</Text>
<Text style={styles.weekdays}>금</Text>
<Text style={styles.satday}>토</Text>
<Text style={styles.sunday}>일</Text>
</View>
}
else if(Dayofweek == 4){
renderingText =
<View style={styles.daysGroup}>
<Text style={styles.weekdays}>월</Text>
<Text style={styles.weekdays}>화</Text>
<Text style={styles.weekdays}>수</Text>
<Text style={styles.todayText}>목</Text>
<Text style={styles.weekdays}>금</Text>
<Text style={styles.satday}>토</Text>
<Text style={styles.sunday}>일</Text>
</View>
}
else if(Dayofweek == 5){
renderingText =
<View style={styles.daysGroup}>
<Text style={styles.weekdays}>월</Text>
<Text style={styles.weekdays}>화</Text>
<Text style={styles.weekdays}>수</Text>
<Text style={styles.weekdays}>목</Text>
<Text style={styles.todayText}>금</Text>
<Text style={styles.satday}>토</Text>
<Text style={styles.sunday}>일</Text>
</View>
}
else{
renderingText =
<View style={styles.daysGroup}>
<Text style={styles.weekdays}>월</Text>
<Text style={styles.weekdays}>화</Text>
<Text style={styles.weekdays}>수</Text>
<Text style={styles.weekdays}>목</Text>
<Text style={styles.weekdays}>금</Text>
<Text style={{marginRight: 6, marginLeft: 6, color: '#52a6f2', fontSize: 20, textDecorationLine: 'underline'}}>토</Text>
<Text style={styles.sunday}>일</Text>
</View>
}
return renderingText;
}
// 잠금 해제시 인증번호 입력 화면
class LoginScreen extends React.Component{
static navigationOptions = {
header: null ,
};
constructor(props) {
super(props);
this.state = {
password: "00000000",
};
this.inputPassword = " ";
}
changePassword= (value) =>{
//Textbox에 입력하는 문자열을 가져와서 inputPassword에 저장한다.
this.inputPassword=value;
}
checkPassword = () =>{
//비밀번호가 맞는지 확인하는 함수
//맞다면 다음화면으로, 틀렸다면 토스트메시지를 띄워준다.
if (this.inputPassword==this.state.password){
this.props.navigation.navigate('Main');
NativeModules.Block.stopService();
}
else{
ToastExample.show('비밀번호가 틀렸습니다.', ToastExample.SHORT);
}
}
render(){
return(
<View style={styles.newContainer}>
<ImageBackground
style={{width: '100%', height: '100%'}}
source={require('./images/CommonB.png')}>
<View style={styles.delLoc}>
<TouchableOpacity style={styles.delBtn}
onPress = {() => NativeModules.Block.deleteLOCKA()}>
<Text style={styles.delWord}>삭제</Text>
</TouchableOpacity>
</View>
<View style={{flex: 2.4, alignItems: 'center',justifyContent: 'flex-end'}}>
<Text style={{color: 'white', fontWeight: 'bold',fontSize: 20, marginBottom: 10}}>
잠금해제 코드를 입력해주세요
</Text>
</View>
<View style={styles.codeSec}>
<TextInput
style={styles.chatInput}
onChangeText={this.changePassword}
secureTextEntry={true}
//onSubmitEditing={this.submitEdit.bind(this)}
/>
</View>
<View style={{flex: 0.4}}/>
<View style={styles.codeSec}>
<TouchableOpacity style={styles.accessBtn}
// 추후 인증번호 확인하고 넘어가야함
onPress = {() => this.checkPassword()}>
<Text style={styles.accessWord}>인증하기</Text>
</TouchableOpacity>
</View>
<View style={{flex: 0.6}}/>
</ImageBackground>
</View>
);
}
}
//휴일, 전투휴무와 같이 일시적으로 해제할 때
class holidayScreen extends React.Component{
static navigationOptions = {
header: null ,
};
constructor(props) {
super(props);
this.state = {
password: "12345678",
};
this.inputPassword = " ";
}
changePassword= (value) =>{
//Textbox에 입력하는 문자열을 가져와서 inputPassword에 저장한다.
this.inputPassword=value;
}
checkPassword = () =>{
//비밀번호가 맞는지 확인하는 함수
//맞다면 다음화면으로, 틀렸다면 토스트메시지를 띄워준다.
if (this.inputPassword==this.state.password){
ToastExample.show('당일 21:00까지 잠금이 해제됩니다.', ToastExample.SHORT);
NativeModules.Block.applyHoliday();
this.props.navigation.navigate('Main');
}
else{
ToastExample.show('비밀번호가 틀렸습니다.', ToastExample.SHORT);
}
}
render(){
return(
<View style={styles.newContainer}>
<ImageBackground
style={{width: '100%', height: '100%'}}
source={require('./images/CommonB.png')}>
<View style={styles.delLoc}>
<TouchableOpacity style={styles.delBtn}
onPress = {() => NativeModules.Block.deleteLOCKA()}>
<Text style={styles.delWord}>삭제</Text>
</TouchableOpacity>
</View>
<View style={{flex: 2.4, alignItems: 'center',justifyContent: 'flex-end'}}>
<Text style={{color: 'white', fontWeight: 'bold',fontSize: 20, marginBottom: 10}}>
일시해제코드를 입력해주세요
</Text>
</View>
<View style={styles.codeSec}>
<TextInput
style={styles.chatInput}
onChangeText={this.changePassword}
secureTextEntry={true}
//onSubmitEditing={this.submitEdit.bind(this)}
/>
</View>
<View style={{flex: 0.4}}/>
<View style={styles.codeSec}>
<TouchableOpacity style={styles.accessBtn}
// 추후 인증번호 확인하고 넘어가야함
onPress = {() => this.checkPassword()}>
<Text style={styles.accessWord}>인증하기</Text>
</TouchableOpacity>
</View>
<View style={{flex: 0.6}}/>
</ImageBackground>
</View>
);
}
}
//권한 설명 및 요청 화면
class PermissionScreen extends React.Component{
constructor(props){
super(props)
}
// 상단의 toolbar 가리기
static navigationOptions = {
header: null ,
};
setAccessibility = () =>{
//권한을 요청하는 화면으로 이동시키는 함수.
NativeModules.Block.setAccessibilityPermissions();
this.props.navigation.navigate('Main');
}
render(){
return(
<View style={styles.newContainer}>
<ImageBackground
style={{width: '100%', height: '100%'}}
source={require('./images/CommonB.png')}>
<View style={styles.delLoc}>
<TouchableOpacity style={styles.delBtn}
onPress = {() => NativeModules.Block.deleteLOCKA()}>
<Text style={styles.delWord}>삭제</Text>
</TouchableOpacity>
</View>
<View style={{flex: 1.7}}/>
<View style={styles.textArea}>
<View style={styles.textArea2}>
<Text style={styles.h1Text}>
어플기능
</Text>
<Text style={styles.h3Text}>
LOCKA 어플리케이션은 핸드폰 비대면 반납을 지원합니다.
</Text>
</View>
</View>
<View style={styles.textArea}>
<View style={styles.textArea2}>
<Text style={styles.h1Text}>
요구권한
</Text>
<Text style={styles.h2Text}>
* 내 동작 확인
</Text>
<Text style={styles.h3Text}>
앱을 제어하는 중에 알림을 받습니다.
</Text>
<Text style={styles.h2Text}>
* 컨텐츠 가져오기
</Text>
<Text style={styles.h3Text}>
사용 중인 화면에서 원하는 컨텐츠를 가져올 수 있습니다.
</Text>
</View>
</View>
<View style={{flex: 0.5}}/>
<View style={styles.codeSec}>
<TouchableOpacity style={styles.accessBtn}
onPress = {()=>this.setAccessibility()}>
<Text style={styles.accessWord}>권한 요청하기</Text>
</TouchableOpacity>
</View>
<View style={{flex: 0.5}}/>
</ImageBackground>
</View>
);
}
}
// 권한 받은 후, 어플의 메인 화면
class MainScreen extends React.Component {
// 상단의 toolbar 가리기
static navigationOptions = {
header: null ,
};
constructor(props){
super(props)
this.loadPermissionState();
this.state = {
d: new Date()
}
//요일
}
componentDidMount() { // Clockcmp 컴포넌트가 불러올때마다 1초씩 this.Change()를 부른다
this.timeID = setInterval(
() => this.Change(),
1000
)
}
componentWillUnmount(){ //종료되면 반복하는것도 클리어시키기
clearInterval(this.timeID)
}
Change = () => { //시계 구현
this.setState({
d : new Date(),
})
}
loadPermissionState = () => {
permissionCheck = NativeModules.Block.checkPermissionState();
if (permissionCheck == false){
this.props.navigation.navigate('Permission');
}
}
clockrender = (dayofweek) => {
//{String(this.state.d.getHours()).padStart(2, "0")}:{String(this.state.d.getMinutes()).padStart(2, "0")}:{String(this.state.d.getSeconds()).padStart(2, "0")}
var clockTexts = " ";
let lockedCondition = NativeModules.Block.checkBlockState();
let pauseLockState = NativeModules.Block.getpauseLock();
var result = "";
if(pauseLockState){
//완전해제 상태일 시 체크해줌.
clockTexts = "완전해제 상태입니다."
result =
<View style={{flex: 1.1, justifyContent: 'center', alignItems: 'center'}}>
<Text
// 시계넣는공간
style={{ color: 'white', fontSize: 30, fontWeight: 'bold', textAlign: 'center',}}>
{clockTexts}
</Text>
</View>
}
else if(( (dayofweek==5 && this.state.d.getHours()>=21) || dayofweek==6 || (dayofweek==0 && this.state.d.getHours()<9) ) && lockedCondition==true){
//주말 해제시간의 경우
if(12<this.state.d.getHours()<=24){
//저녁시간
var end = new Date(this.state.d.getFullYear(),this.state.d.getMonth(),this.state.d.getDate()+1,8, 30)
var betweenTime = end - this.state.d;
var Hours = String(Math.floor((betweenTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, "0");
var Minutes = String(Math.floor((betweenTime % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, "0");
var Seconds = String(Math.floor((betweenTime % (1000 * 60)) / 1000)).padStart(2, "0");
clockTexts = Hours+":"+Minutes+":"+Seconds;
}
else{
//오전시간
var end = new Date(this.state.d.getFullYear(),this.state.d.getMonth(),this.state.d.getDate(),8, 30)
var betweenTime = end - this.state.d;
var Hours = String(Math.floor((betweenTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, "0");
var Minutes = String(Math.floor((betweenTime % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, "0");
var Seconds = String(Math.floor((betweenTime % (1000 * 60)) / 1000)).padStart(2, "0");
clockTexts = Hours+":"+Minutes+":"+Seconds;
}
result =
<View style={{flex: 1.1, justifyContent: 'center', alignItems: 'center'}}>
<Text style= {{color: 'white', fontSize: 23, alignSelf: 'flex-start', marginLeft: '15%', fontWeight: 'bold'}} > 해제까지 </Text>
<Text
// 시계넣는공간
style={styles.clockText}>
{clockTexts}
</Text>
</View>
}
else if( !( (dayofweek==5 && this.state.d.getHours()>=21) || dayofweek==6 || (dayofweek==0 && this.state.d.getHours()<9) ) && lockedCondition==true){
//평일 잠금해제까지 남은시간.
if(21<=this.state.d.getHours()<=24){
//저녁시간
var end = new Date(this.state.d.getFullYear(),this.state.d.getMonth(),this.state.d.getDate()+1, 18, 0)
var betweenTime = end - this.state.d;
var Hours = String(Math.floor((betweenTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, "0");
var Minutes = String(Math.floor((betweenTime % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, "0");
var Seconds = String(Math.floor((betweenTime % (1000 * 60)) / 1000)).padStart(2, "0");
clockTexts = Hours+":"+Minutes+":"+Seconds;
}
else{
//오전시간
var end = new Date(this.state.d.getFullYear(),this.state.d.getMonth(),this.state.d.getDate(),18, 0)
var betweenTime = end - this.state.d;
var Hours = String(Math.floor((betweenTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, "0");
var Minutes = String(Math.floor((betweenTime % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, "0");
var Seconds = String(Math.floor((betweenTime % (1000 * 60)) / 1000)).padStart(2, "0");
clockTexts = Hours+":"+Minutes+":"+Seconds;
}
result =
<View style={{flex: 1.1, justifyContent: 'center', alignItems: 'center'}}>
<Text style= {{color: 'white', fontSize: 23, alignSelf: 'flex-start', marginLeft: '15%', fontWeight: 'bold'}} > 해제까지 </Text>
<Text
// 시계넣는공간
style={styles.clockText}>
{clockTexts}
</Text>
</View>
}
else if(lockedCondition==false){
//이미 잠금이 풀려있는 경우.
var end = new Date(this.state.d.getFullYear(),this.state.d.getMonth(),this.state.d.getDate(), 21, 0)
var betweenTime = end - this.state.d;
var Hours = String(Math.floor((betweenTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, "0");
var Minutes = String(Math.floor((betweenTime % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, "0");
var Seconds = String(Math.floor((betweenTime % (1000 * 60)) / 1000)).padStart(2, "0");
clockTexts = Hours+":"+Minutes+":"+Seconds;
result =
<View style={{flex: 1.1, justifyContent: 'center', alignItems: 'center'}}>
<Text style= {{color: 'white', fontSize: 23, alignSelf: 'flex-start', marginLeft: '15%', fontWeight: 'bold'}} > 잠금까지 </Text>
<Text
// 시계넣는공간
style={styles.clockText}>
{clockTexts}
</Text>
</View>
}
else{
clockText = String(this.state.d.getHours()).padStart(2, "0")+":"+String(this.state.d.getMinutes()).padStart(2, "0")+":"+String(this.state.d.getSeconds()).padStart(2, "0")
}
return result;
}
render(){
return(
<View style={styles.newContainer}>
<ImageBackground
style={{width: '100%', height: '100%'}}
source={require('./images/simple_background.jpg')}>
<View style={styles.delLoc}>
<TouchableOpacity style={styles.delBtn}
onPress = {() => NativeModules.Block.deleteLOCKA()}>
<Text style={styles.delWord}>삭제</Text>
</TouchableOpacity>
</View>
<View style={{flex: 0.7}}/>
{this.clockrender(this.state.d.getDay())}
<View style={{flex: 0.1}}/>
{renderDayofweek(this.state.d.getDay())}
<View style={{flex: 0.3}}/>
<View style={styles.codeSec}>
{renderBlockState()}
</View>
<View style={{flex: 1}}/>
<View style={{flex: 1}}>
<View style={styles.buttonGroup}>
<View style={styles.buttonSet}>
<TouchableOpacity
onPress = {()=>this.props.navigation.navigate('Calc')}>
<Image
// 1번 아이콘 >> 전역일/월급 계산기
resizeMode="contain"
style={styles.iconStyle}
source = {require('./images/calcbutton.png')} />
</TouchableOpacity>
<Text style={styles.iconText}>
계산기
</Text>
</View>
<View style={styles.buttonSet}>
<TouchableOpacity
// 추후 버튼 별 기능 실행해야함
onPress={() => NativeModules.Block.startService()}>
<Image
// 2번 아이콘 >> 핸드폰 잠금
resizeMode="contain"
style={styles.iconStyle}
source = {require('./images/lockbutton.png')} />
</TouchableOpacity>
<Text style={styles.iconText}>
잠금
</Text>
</View>
<View style={styles.buttonSet}>
<TouchableOpacity
onPress = {()=>this.props.navigation.navigate('UnlockCheck')}>
<Image
// 3번 아이콘 >> 핸드폰 잠금 해체
resizeMode="contain"
style={styles.iconStyle}
source = {require('./images/unlockbutton.png')} />
</TouchableOpacity>
<Text style={styles.iconText}>
해제
</Text>
</View>
<View style={styles.buttonSet}>
<TouchableOpacity
onPress = {()=>this.props.navigation.navigate('Holiday')}>
<Image
// 4번 아이콘 >> 잠금 일시해제
resizeMode="contain"
style={styles.iconStyle}
source = {require('./images/holidayunlockbutton.png')} />
</TouchableOpacity>
<Text style={styles.iconText}>
일시해제
</Text>
</View>
</View>
</View>
</ImageBackground>
</View>
);
}
}
//계산용 화면
class CalcScreen extends React.Component {
constructor(props) {
super(props);
//특별한 맴버 변수(화면 자동갱신) 설명
/*
clicked : 월급 확인버튼 눌렀는지 확인함.
saving : 1달에 넣는 적금
selectArmy : 육해공군 등 군종선택
date : 현재 날짜, 초기값은 임의로 넣어둠.
*/
this.state = {
clicked: true,
saving: 0,
usedAmount: 0,
selectArmy: 0,
date: "2020-10-22",
// datepicker의 placeholder를 사용하기 위해 수정.
startDay: "",
endDay: "",
corporalPromotionitems: [
{
label: '2달 진급누락',
value: -2,
},
{
label: '1달 진급누락',
value: -1,
},
{
label: '정상진급',
value: 0,
},
{
label: '1달 조기진급',
value: 1,
},
{
label: '2달 조기진급',
value: 2,
},
],
sgtPromotionitems : [
{
label: '1달 진급누락',
value: -1,
},
{
label: '정상진급',
value: 0,
},
{
label: '1달 조기진급',
value: 1,
},
],
corporalPromotion: 0,
sgtPromotion: 0
};
//일반 맴버변수(사용자 입력값을 저장하는 변수.) 설명
/*
inputText : 월 적금을 받아주는 변수
dDays : 남은 군생활 일수, 초기값은 임의로 18달*30일로 설정
allDays : 전체 군생활 일수
*/
this.inputText=0;
this.dDays=540; //그냥 30*18
this.allDays=540;
this.radio_props = [
{label: '육군', value: 0 },
{label: '해군', value: 1 },
{label: '공군', value: 2 },
{label: '해병대', value: 3 }
];
}
static navigationOptions = {
header: null ,
};
calcPercentInt=()=>{
//군생활 퍼센트를 숫자로 리턴
var percent = 100 - Math.round((this.dDays/this.allDays)*100);
return percent
}
calcPercent=()=>{
//군생활 퍼센트를 문자열로 리턴
var percent = String(100 - Math.round((this.dDays/this.allDays)*100));
var result = percent.concat("%");
return result
}
clickBtn=()=>{
//월급 계산 버튼 눌렀을 때 실행되는 함수.
this.setState({saving: this.inputText, clicked:false})
}
changeSaving= (value) =>{
//월급이 얼마인지 바뀔때마다 inputText의 값을 바꿔주는 함수.
this.inputText=value;
}
ddayCalculator = (StartDate,EndDate) => {
//Dday계산하는 함수
//StartDate : 입대일
//EndDate : 전역일
if((StartDate != " ") && (EndDate != " ")){
let today = new Date();
var startdateArray = StartDate.split("-");
var enddateArray = EndDate.split("-");
var startDateObj = new Date(Number(startdateArray[0]), Number(startdateArray[1])-1, Number(startdateArray[2]));
var endDateObj = new Date(Number(enddateArray[0]), Number(enddateArray[1])-1, Number(enddateArray[2]));
//현재 시간 가져와서 D-day 계산, 올림을 해줘서 일수로 딱 떨어지게끔 함.
var betweenDay = Math.ceil(( endDateObj.getTime() - today.getTime() )/1000/60/60/24);
var allDay = Math.abs((startDateObj.getTime() - endDateObj.getTime())/1000/60/60/24);
this.dDays= betweenDay;
this.allDays=allDay;
var text1 = 'D-';
var result = text1.concat(betweenDay);
//this.Ddaymessage=result
return result
}
else{
var result = " "
//this.Ddaymessage=result
return result
}
}
inputsavingAmount = async () => {
const { action, text } = await DialogAndroid.prompt('적금액수를 입력하세요 (원/1달)', 'ex) 200000');
if (action === DialogAndroid.actionPositive) {
this.setState({saving: text})
}
}
inputusedAmount = async () => {
const { action, text } = await DialogAndroid.prompt('1달에 사용하는 평균금액을 입력하세요', 'ex) 200000');
if (action === DialogAndroid.actionPositive) {
this.setState({usedAmount: text})
}
}
render() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' , color: '#1e3269' }}>
<ImageBackground
style={{width: '100%', height: '100%'}}
source={require('./images/simple_background.jpg')}>
<View style={styles.ddayCalc}>
<Text style={styles.calcTitle}>전역일 계산기</Text>
<View
// progressBar가 담기는 뷰
style={{flexDirection: 'row', alignSelf: 'center', margin: 5}}>
<ProgressCircle
radius={100}
percent={this.calcPercentInt()}
borderWidth={8}
bgColor="#000038"
color="#8b00ff"
shadowColor="#b19cd9"
style={{flexDirection: 'row', alignSelf: 'center'}}
>
<Text style={styles.contentsText}>{this.ddayCalculator(this.state.startDay, this.state.endDay)}</Text>
<Text style={styles.contentsText}>{this.calcPercent()}</Text>
</ProgressCircle>
</View>
<View style={styles.calenderGroup}>
<View style={styles.calenderSet}>
<View style={{flexDirection: 'row', alignSelf: 'center'}}>
<Text style={styles.dayofarmy}>
입대일
</Text>
</View>
<View style={{flexDirection: 'row', alignSelf: 'center'}}>
<DatePicker
style={{width: 160}}
date={this.state.startDay}
mode="date"
placeholder="입대일을 입력해주세요"
format="YYYY-MM-DD"
minDate="2019-01-01"
maxDate="2099-12-31"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
dateIcon: {
width: 0,
height: 0,
},
dateInput: {
marginLeft: 0,
borderWidth: 0
},
placeholderText: {
color: 'white'
},
dateText: {
color: "white",
}
}}
onDateChange={(date) => {this.setState({startDay: date})}}
/>
</View>
</View>
<View style={styles.calenderSet}>
<View style={{flexDirection: 'row', alignSelf: 'center'}}>
<Text style={styles.dayofarmy}>
전역일
</Text>
</View>
<View style={{flexDirection: 'row', alignSelf: 'center'}}>
<DatePicker
style={{width: 160}}
date={this.state.endDay}
mode="date"
placeholder="전역일을 입력해주세요"
format="YYYY-MM-DD"
minDate="2020-01-01"
maxDate="2099-12-31"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
dateIcon: {
width: 0,
height: 0,
},
dateInput: {
marginLeft: 0,
borderWidth: 0
},
placeholderText: {
color: 'white'
},
dateText: {
color: "white",
}
}}
onDateChange={
(date) => {this.setState({endDay: date})}
}
/>
</View>
</View>
</View>
</View>
<View style={styles.salaryCalc}>
<Text style={styles.calcTitle}>월급 계산기</Text>
<View style={{alignSelf: 'center', flexDirection: 'row', margin: 5}}>
<RadioForm
//checked된 radio의 값을 뽑아내야 함.
radio_props={this.radio_props}
initial={0}
onPress={(value) => {this.setState({selectArmy:value})}}
selectedButtonColor={'white'}
selectedLabelColor={'white'}
labelStyle={{fontSize:12, color: '#50bcdf'}}
formHorizontal={true}
//이거 setState 잘 봐야 할 거 같음.
/>
</View>
<View style={{flexDirection: 'row', alignSelf: 'center'}}>
<View style={{flexDirection: 'row', alignSelf: 'center', margin: 7}}>
<Button title="적금액 입력" onPress={this.inputsavingAmount} />
</View>
<View style={{flexDirection: 'row', alignSelf: 'center', margin: 7}}>
<Button title="사용금액 입력" onPress={this.inputusedAmount} />
</View>
</View>
<View style={{flex: 0.15}}/>
<View style={{flexDirection: 'row', alignSelf: 'center'}}>
<View style={styles.pickerSet}>
<View style={{flexDirection: 'row', alignSelf: 'center'}}>
<Text style={{fontSize: 17, color: 'white', alignItems: 'center',fontWeight: 'bold'}}>상병 진급 여부</Text>
</View>
<Picker
style={{ height: 50, width: 180, color: 'white'}}
onValueChange={(itemValue, itemIndex) =>
this.setState({sgtPromotion: Number(itemValue)})}
selectedValue={String(this.state.sgtPromotion)}
>
<Picker.Item label="2달 진급누락" value = "-2"/>
<Picker.Item label="1달 진급누락" value="-1" />
<Picker.Item label="정상진급" value="0" />
<Picker.Item label="1달 조기진급" value="1" />
<Picker.Item label="2달 조기진급" value="2" />
</Picker>
</View>
<View style={styles.pickerSet}>
<View style={{flexDirection: 'row', alignSelf: 'center'}}>
<Text style={{fontSize: 17, color: 'white', alignItems: 'center',fontWeight: 'bold'}}>병장 진급 여부</Text>
</View>
<Picker
style={{height: 50, width: 180, color: 'white'}}
//textStyle={{ fontSize:16, color: 'white'}}
onValueChange={(itemValue, itemIndex) =>
this.setState({corporalPromotion: Number(itemValue)})}
selectedValue={String(this.state.corporalPromotion)}
>
<Picker.Item label="1달 진급누락" value="-1" />
<Picker.Item label="정상진급" value="0" />
<Picker.Item label="1달 조기진급" value="1" />
</Picker>
</View>
</View>
<View style={{flex: 0.4}}/>
<View style={{flexDirection: 'row', justifyContent: 'center', alignItems: 'center'}}>
{
this.state.clicked
?
<TouchableOpacity style={styles.calBtn} onPress = {this.clickBtn}>
<Text style={styles.calWord}>확인</Text>
</TouchableOpacity>
: <Text style={styles.contentsText}>{calcSalary(this.state.selectArmy, Number(this.state.saving),this.state.corporalPromotion,this.state.sgtPromotion, this.state.usedAmount)} </Text>
}
</View>
</View>
</ImageBackground>
</View>
);
}
}
const AppNavigator = createStackNavigator(
{
//Main: { screen: HomeScreen },
UnlockCheck: { screen: LoginScreen },
Permission: { screen: PermissionScreen },
Calc: { screen: CalcScreen },
Main: { screen: MainScreen },
Holiday: {screen: holidayScreen}
},
{
initialRouteName: "Main"
}
);
export default createAppContainer(AppNavigator);
const styles = StyleSheet.create({
container: {
flex:1,
backgroundColor: "#000038",
justifyContent: 'center',
},
newContainer: {
flex:1,
justifyContent: 'center',
},
settingView: {
flex: 0.5,
backgroundColor: 'black',
},