Skip to content

Commit 8e8adaa

Browse files
committed
feat: delete confirmation
1 parent faa14bd commit 8e8adaa

File tree

2 files changed

+125
-7
lines changed

2 files changed

+125
-7
lines changed

example/src/Screens/HomeScreen.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ const styles = StyleSheet.create({
166166
fontFamily: 'Outfit-Regular',
167167
fontSize: 16,
168168
color: 'white',
169-
lineHeight: 15,
170169
},
171170
roundButton: {
172171
width: '100%',

example/src/Screens/ProofScreen.tsx

+125-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable react-native/no-inline-styles */
2-
import React, { useContext, type FunctionComponent } from 'react';
2+
import React, { useContext, useState, type FunctionComponent } from 'react';
33
import {
4+
Modal,
45
SafeAreaView,
56
StyleSheet,
67
Text,
@@ -18,19 +19,94 @@ import { icons } from '../Components/illustrations';
1819
import { SvgXml } from 'react-native-svg';
1920
import Clipboard from '@react-native-clipboard/clipboard';
2021
import Toast from 'react-native-toast-message';
22+
import { BlurView } from '@react-native-community/blur';
2123

2224
type ProofScreenProps = {
2325
route: any;
2426
navigation: any;
2527
};
2628

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+
27102
export const ProofScreen: FunctionComponent<ProofScreenProps> = ({
28103
route,
29104
navigation,
30105
}) => {
31106
const { anonAadhaarProof } = route.params;
32107
const proof: AnonAadhaarProof = anonAadhaarProof.anonAadhaarProof;
33108
const { setProofState } = useContext(AnonAadhaarContext);
109+
const [modalVisible, setModalVisible] = useState<boolean>(false);
34110

35111
const copyToClipboard = () => {
36112
Clipboard.setString(JSON.stringify(proof));
@@ -65,6 +141,12 @@ export const ProofScreen: FunctionComponent<ProofScreenProps> = ({
65141
<Text style={styles.infoText}>Copy Proof</Text>
66142
<SvgXml xml={icons.fileCopyLine} width="24" height="24" />
67143
</TouchableOpacity>
144+
<ConfirmationModal
145+
setModalVisible={setModalVisible}
146+
modalVisible={modalVisible}
147+
navigation={navigation}
148+
setProofState={setProofState}
149+
/>
68150
<TouchableOpacity
69151
style={[
70152
styles.actionButton,
@@ -74,11 +156,7 @@ export const ProofScreen: FunctionComponent<ProofScreenProps> = ({
74156
justifyContent: 'space-around',
75157
},
76158
]}
77-
onPress={async () => {
78-
await cleanAnonAadhaarState();
79-
setProofState('deleted');
80-
navigation.navigate('Home');
81-
}}
159+
onPress={() => setModalVisible(true)}
82160
>
83161
<Text style={[styles.infoText, { color: '#ED3636' }]}>
84162
Delete Proof
@@ -316,4 +394,45 @@ const styles = StyleSheet.create({
316394
flexDirection: 'row',
317395
alignItems: 'center',
318396
},
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+
},
319438
});

0 commit comments

Comments
 (0)