forked from Axionvera/pocketpay-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWalletResetConfirmModal.tsx
More file actions
180 lines (168 loc) · 5.57 KB
/
Copy pathWalletResetConfirmModal.tsx
File metadata and controls
180 lines (168 loc) · 5.57 KB
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
/**
* WalletResetConfirmModal
*
* A destructive confirmation modal that requires the user to type "RESET"
* before proceeding. Displays a clear breakdown of what data will be removed.
*
* Accessibility: all interactive elements carry accessibilityLabel / accessibilityRole.
*/
import React, { useEffect, useMemo, useState } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { SIZES, RADIUS, ThemeColors } from '../constants/theme';
import { useTheme } from '../hooks/useTheme';
import { ShieldAlert, AlertTriangle, KeyRound, Users, Clock, Settings } from 'lucide-react-native';
import { Input } from './Input';
import { ConfirmModal } from './ConfirmModal';
interface WalletResetConfirmModalProps {
visible: boolean;
isLoading?: boolean;
onConfirm: () => void;
onCancel: () => void;
}
/** The exact text the user must type to enable the destructive action. */
const CONFIRMATION_TEXT = 'confirm reset';
/** Items that will be permanently deleted, displayed as a bullet-point list. */
const DATA_TO_BE_REMOVED = [
{ icon: KeyRound, label: 'Wallet secret key', detail: 'Your Stellar secret key stored on this device' },
{ icon: Settings, label: 'App preferences', detail: 'Theme selection and app lock settings' },
{ icon: Users, label: 'Saved contacts', detail: 'Your address book entries' },
{ icon: Clock, label: 'Transaction history', detail: 'Cached payment activity' },
] as const;
export const WalletResetConfirmModal: React.FC<WalletResetConfirmModalProps> = ({
visible,
isLoading = false,
onConfirm,
onCancel,
}) => {
const { colors } = useTheme();
const styles = useMemo(() => createStyles(colors), [colors]);
const [typedText, setTypedText] = useState('');
useEffect(() => {
if (visible) {
setTypedText('');
}
}, [visible]);
const isConfirmed = typedText.trim().toLowerCase() === CONFIRMATION_TEXT;
return (
<ConfirmModal
visible={visible}
title="Reset Wallet"
message=""
confirmLabel="Delete Everything"
cancelLabel="Cancel"
destructive
isLoading={isLoading}
confirmDisabled={!isConfirmed}
onConfirm={onConfirm}
onCancel={onCancel}
>
{/* Warning message */}
<View style={styles.warningBanner}>
<AlertTriangle color={colors.warning} size={16} style={{ marginRight: SIZES.sm }} />
<Text style={styles.warningBannerText}>
This will permanently delete all wallet data from this device. Your funds on the Stellar network will remain, but you will need your secret key to access them again.
</Text>
</View>
{/* Data that will be removed */}
<Text style={styles.dataListTitle}>The following data will be permanently removed:</Text>
{DATA_TO_BE_REMOVED.map(({ icon: Icon, label, detail }) => (
<View key={label} style={styles.dataRow}>
<View style={styles.dataIconContainer}>
<Icon color={colors.error} size={16} />
</View>
<View style={styles.dataTextGroup}>
<Text style={styles.dataLabel}>{label}</Text>
<Text style={styles.dataDetail}>{detail}</Text>
</View>
</View>
))}
{/* Typed confirmation */}
<Input
label={`Type "${CONFIRMATION_TEXT}" to confirm`}
value={typedText}
onChangeText={setTypedText}
placeholder={CONFIRMATION_TEXT}
autoCapitalize="none"
autoComplete="off"
autoCorrect={false}
editable={!isLoading}
accessibilityLabel="Type confirm reset to confirm wallet deletion"
/>
{/* Disclaimer */}
<View style={styles.disclaimer}>
<ShieldAlert color={colors.warning} size={14} style={{ marginRight: SIZES.sm }} />
<Text style={styles.disclaimerText}>
This action is irreversible. Make sure you have backed up your secret key before proceeding — without it, any funds in your wallet will be unreachable.
</Text>
</View>
</ConfirmModal>
);
};
// ── Styles ───────────────────────────────────────────────────────────────────
const createStyles = (colors: ThemeColors) => StyleSheet.create({
warningBanner: {
flexDirection: 'row',
alignItems: 'flex-start',
backgroundColor: 'rgba(255, 196, 0, 0.1)',
borderWidth: 1,
borderColor: 'rgba(255, 196, 0, 0.3)',
borderRadius: RADIUS.md,
padding: SIZES.md,
marginBottom: SIZES.md,
},
warningBannerText: {
color: colors.warning,
fontSize: 12,
lineHeight: 18,
flex: 1,
},
dataListTitle: {
color: colors.textPrimary,
fontSize: 13,
fontWeight: '600',
marginBottom: SIZES.sm,
},
dataRow: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: SIZES.sm,
paddingLeft: SIZES.xs,
},
dataIconContainer: {
width: 28,
height: 28,
borderRadius: 14,
backgroundColor: 'rgba(255, 61, 0, 0.1)',
justifyContent: 'center',
alignItems: 'center',
marginRight: SIZES.sm,
},
dataTextGroup: {
flex: 1,
},
dataLabel: {
color: colors.textPrimary,
fontSize: 13,
fontWeight: '500',
},
dataDetail: {
color: colors.textMuted,
fontSize: 11,
lineHeight: 15,
marginTop: 1,
},
disclaimer: {
flexDirection: 'row',
alignItems: 'flex-start',
backgroundColor: 'rgba(255, 196, 0, 0.08)',
borderRadius: RADIUS.sm,
padding: SIZES.sm,
marginTop: SIZES.xs,
},
disclaimerText: {
color: colors.textMuted,
fontSize: 11,
lineHeight: 16,
flex: 1,
},
});