1
1
/* eslint-disable react-native/no-inline-styles */
2
- import React , { useContext , type FunctionComponent } from 'react' ;
2
+ import React , { useContext , useState , type FunctionComponent } from 'react' ;
3
3
import {
4
+ Modal ,
4
5
SafeAreaView ,
5
6
StyleSheet ,
6
7
Text ,
@@ -18,19 +19,94 @@ import { icons } from '../Components/illustrations';
18
19
import { SvgXml } from 'react-native-svg' ;
19
20
import Clipboard from '@react-native-clipboard/clipboard' ;
20
21
import Toast from 'react-native-toast-message' ;
22
+ import { BlurView } from '@react-native-community/blur' ;
21
23
22
24
type ProofScreenProps = {
23
25
route : any ;
24
26
navigation : any ;
25
27
} ;
26
28
29
+ const ConfirmationModal = ( {
30
+ setModalVisible,
31
+ modalVisible,
32
+ setProofState,
33
+ navigation,
34
+ } : {
35
+ setModalVisible : any ;
36
+ modalVisible : boolean ;
37
+ navigation : any ;
38
+ setProofState : any ;
39
+ } ) => {
40
+ return (
41
+ < Modal
42
+ animationType = "slide"
43
+ transparent = { true }
44
+ visible = { modalVisible }
45
+ onRequestClose = { ( ) => {
46
+ setModalVisible ( ! modalVisible ) ;
47
+ } }
48
+ >
49
+ < BlurView
50
+ style = { styles . absolute }
51
+ blurType = "dark"
52
+ blurAmount = { 1 }
53
+ reducedTransparencyFallbackColor = "dark"
54
+ >
55
+ < View style = { styles . centeredView } >
56
+ < View style = { styles . modalView } >
57
+ < Text style = { styles . modalText } >
58
+ Are you sure you want to delete this proof?
59
+ </ Text >
60
+ < View
61
+ style = { {
62
+ flexDirection : 'row' ,
63
+ justifyContent : 'space-between' ,
64
+ marginTop : 20 ,
65
+ } }
66
+ >
67
+ < TouchableOpacity
68
+ onPress = { ( ) => {
69
+ setModalVisible ( ! modalVisible ) ;
70
+ } }
71
+ style = { [
72
+ styles . confirmationModalButton ,
73
+ { borderEndStartRadius : 8 } ,
74
+ ] }
75
+ >
76
+ < Text style = { { color : 'white' } } > Cancel</ Text >
77
+ </ TouchableOpacity >
78
+ < TouchableOpacity
79
+ onPress = { ( ) => {
80
+ cleanAnonAadhaarState ( ) ;
81
+ setProofState ( 'deleted' ) ;
82
+ navigation . navigate ( 'Home' ) ;
83
+ setModalVisible ( ! modalVisible ) ;
84
+ } }
85
+ style = { [
86
+ styles . confirmationModalButton ,
87
+ { borderEndEndRadius : 8 , borderLeftWidth : 1 } ,
88
+ ] }
89
+ >
90
+ < Text style = { { color : '#ED3636' , fontWeight : 'bold' } } >
91
+ Delete
92
+ </ Text >
93
+ </ TouchableOpacity >
94
+ </ View >
95
+ </ View >
96
+ </ View >
97
+ </ BlurView >
98
+ </ Modal >
99
+ ) ;
100
+ } ;
101
+
27
102
export const ProofScreen : FunctionComponent < ProofScreenProps > = ( {
28
103
route,
29
104
navigation,
30
105
} ) => {
31
106
const { anonAadhaarProof } = route . params ;
32
107
const proof : AnonAadhaarProof = anonAadhaarProof . anonAadhaarProof ;
33
108
const { setProofState } = useContext ( AnonAadhaarContext ) ;
109
+ const [ modalVisible , setModalVisible ] = useState < boolean > ( false ) ;
34
110
35
111
const copyToClipboard = ( ) => {
36
112
Clipboard . setString ( JSON . stringify ( proof ) ) ;
@@ -65,6 +141,12 @@ export const ProofScreen: FunctionComponent<ProofScreenProps> = ({
65
141
< Text style = { styles . infoText } > Copy Proof</ Text >
66
142
< SvgXml xml = { icons . fileCopyLine } width = "24" height = "24" />
67
143
</ TouchableOpacity >
144
+ < ConfirmationModal
145
+ setModalVisible = { setModalVisible }
146
+ modalVisible = { modalVisible }
147
+ navigation = { navigation }
148
+ setProofState = { setProofState }
149
+ />
68
150
< TouchableOpacity
69
151
style = { [
70
152
styles . actionButton ,
@@ -74,11 +156,7 @@ export const ProofScreen: FunctionComponent<ProofScreenProps> = ({
74
156
justifyContent : 'space-around' ,
75
157
} ,
76
158
] }
77
- onPress = { async ( ) => {
78
- await cleanAnonAadhaarState ( ) ;
79
- setProofState ( 'deleted' ) ;
80
- navigation . navigate ( 'Home' ) ;
81
- } }
159
+ onPress = { ( ) => setModalVisible ( true ) }
82
160
>
83
161
< Text style = { [ styles . infoText , { color : '#ED3636' } ] } >
84
162
Delete Proof
@@ -316,4 +394,45 @@ const styles = StyleSheet.create({
316
394
flexDirection : 'row' ,
317
395
alignItems : 'center' ,
318
396
} ,
397
+ modalView : {
398
+ margin : 20 ,
399
+ backgroundColor : '#3E3B3B' ,
400
+ borderRadius : 8 ,
401
+ paddingTop : 35 ,
402
+ alignItems : 'center' ,
403
+ shadowColor : '#000' ,
404
+ shadowOffset : {
405
+ width : 0 ,
406
+ height : 2 ,
407
+ } ,
408
+ shadowOpacity : 0.25 ,
409
+ shadowRadius : 4 ,
410
+ elevation : 5 ,
411
+ } ,
412
+ modalText : {
413
+ marginBottom : 15 ,
414
+ textAlign : 'center' ,
415
+ color : 'white' ,
416
+ fontSize : 16 ,
417
+ fontFamily : 'Outfit-Regular' ,
418
+ } ,
419
+ centeredView : {
420
+ flex : 1 ,
421
+ justifyContent : 'center' ,
422
+ alignItems : 'center' ,
423
+ marginTop : 22 ,
424
+ } ,
425
+ absolute : {
426
+ position : 'absolute' ,
427
+ width : '100%' ,
428
+ height : '100%' ,
429
+ } ,
430
+ confirmationModalButton : {
431
+ flex : 1 ,
432
+ backgroundColor : '#484343' ,
433
+ alignItems : 'center' ,
434
+ borderTopWidth : 1 ,
435
+ paddingVertical : 15 ,
436
+ borderColor : 'gray' ,
437
+ } ,
319
438
} ) ;
0 commit comments