|
1 |
| -import { StatusBar } from "expo-status-bar"; |
2 |
| -import { Button, Modal, StyleSheet, Text, View } from "react-native"; |
| 1 | +import { StyleSheet, View } from "react-native"; |
| 2 | +import { Button, Layout, Modal, Text } from "@ui-kitten/components"; |
3 | 3 | import { useLocalSearchParams, useRouter } from "expo-router";
|
4 | 4 | import { useState } from "react";
|
5 | 5 | import { useFacade } from "../../../data/facades";
|
6 | 6 |
|
| 7 | +import { RemoveAccount as RemoveAccountIcon } from "@/svgs/RemoveAccount"; |
| 8 | + |
7 | 9 | export default function RemoveAccount() {
|
8 | 10 | const router = useRouter();
|
9 | 11 | const facade = useFacade();
|
10 |
| - |
11 | 12 | const { accountName } = useLocalSearchParams<{ accountName: string }>();
|
12 |
| - |
13 | 13 | const removeAccount = facade.removeAccount.useMutation();
|
14 |
| - |
15 | 14 | const [modalVisible, setModalVisible] = useState(false);
|
16 | 15 |
|
| 16 | + const handleRemove = async () => { |
| 17 | + await removeAccount.mutateAsync({ name: accountName }); |
| 18 | + setModalVisible(false); |
| 19 | + router.dismissAll(); |
| 20 | + }; |
| 21 | + |
17 | 22 | return (
|
18 |
| - <View style={styles.container}> |
19 |
| - <Modal visible={modalVisible} animationType="slide"> |
20 |
| - <View style={styles.container}> |
21 |
| - <Text>Are you sure?</Text> |
| 23 | + <Layout style={styles.container}> |
| 24 | + {/* Confirmation Modal */} |
| 25 | + <Modal |
| 26 | + visible={modalVisible} |
| 27 | + backdropStyle={styles.backdrop} |
| 28 | + onBackdropPress={() => setModalVisible(false)} |
| 29 | + > |
| 30 | + <View style={styles.modalContainer}> |
| 31 | + <Text category="h4" style={styles.modalTitle}> |
| 32 | + Are you sure? |
| 33 | + </Text> |
22 | 34 | <Button
|
23 |
| - title="Yes, remove account" |
24 |
| - onPress={async () => { |
25 |
| - await removeAccount.mutateAsync({ name: accountName }); |
26 |
| - setModalVisible(false); |
27 |
| - router.dismissAll(); |
28 |
| - }} |
29 |
| - /> |
| 35 | + style={styles.button} |
| 36 | + status="danger" |
| 37 | + onPress={handleRemove} |
| 38 | + disabled={removeAccount.isPending} |
| 39 | + > |
| 40 | + {removeAccount.isPending ? "Removing..." : "Yes, remove account"} |
| 41 | + </Button> |
30 | 42 | <Button
|
31 |
| - title="I changed my mind" |
| 43 | + style={styles.button} |
| 44 | + appearance="ghost" |
32 | 45 | onPress={() => setModalVisible(false)}
|
33 |
| - /> |
| 46 | + > |
| 47 | + I changed my mind |
| 48 | + </Button> |
34 | 49 | </View>
|
35 | 50 | </Modal>
|
36 |
| - <Button title="Back" onPress={() => router.dismissAll()} /> |
37 |
| - <Text>Remove Account</Text> |
38 |
| - <Text> |
39 |
| - Even though you are removing this account, you’re still able to import |
40 |
| - it at another time. Please be sure to backup your accounts. |
41 |
| - </Text> |
42 |
| - <Button title="Remove" onPress={() => setModalVisible(true)} /> |
43 |
| - <Button title="Cancel" onPress={() => router.dismiss()} /> |
44 | 51 |
|
45 |
| - <StatusBar style="auto" /> |
46 |
| - </View> |
| 52 | + {/* Main Screen */} |
| 53 | + <View style={styles.content}> |
| 54 | + <RemoveAccountIcon /> |
| 55 | + <Text category="h3" style={styles.title}> |
| 56 | + Remove Account: |
| 57 | + </Text> |
| 58 | + <Text category="h4" style={styles.subtitle}> |
| 59 | + {accountName} |
| 60 | + </Text> |
| 61 | + <Text style={styles.description}> |
| 62 | + Even though you are removing this account, you're still able to import |
| 63 | + it at another time. Please be sure to backup your accounts. |
| 64 | + </Text> |
| 65 | + <View style={styles.buttonContainer}> |
| 66 | + <Button |
| 67 | + style={styles.button} |
| 68 | + status="danger" |
| 69 | + onPress={() => setModalVisible(true)} |
| 70 | + > |
| 71 | + Remove |
| 72 | + </Button> |
| 73 | + <Button |
| 74 | + style={styles.button} |
| 75 | + appearance="ghost" |
| 76 | + onPress={() => router.dismiss()} |
| 77 | + > |
| 78 | + Cancel |
| 79 | + </Button> |
| 80 | + </View> |
| 81 | + </View> |
| 82 | + </Layout> |
47 | 83 | );
|
48 | 84 | }
|
49 | 85 |
|
50 | 86 | const styles = StyleSheet.create({
|
51 | 87 | container: {
|
52 | 88 | flex: 1,
|
53 |
| - backgroundColor: "#fff", |
| 89 | + }, |
| 90 | + content: { |
| 91 | + flex: 1, |
54 | 92 | alignItems: "center",
|
55 |
| - justifyContent: "center", |
| 93 | + padding: 24, |
| 94 | + gap: 16, |
| 95 | + }, |
| 96 | + title: { |
| 97 | + marginTop: 24, |
| 98 | + textAlign: "center", |
| 99 | + }, |
| 100 | + subtitle: { |
| 101 | + textAlign: "center", |
| 102 | + }, |
| 103 | + description: { |
| 104 | + textAlign: "center", |
| 105 | + color: "#666", |
| 106 | + marginTop: 8, |
| 107 | + }, |
| 108 | + buttonContainer: { |
| 109 | + width: "100%", |
| 110 | + marginTop: "auto", |
| 111 | + gap: 8, |
| 112 | + }, |
| 113 | + button: { |
| 114 | + width: "100%", |
| 115 | + }, |
| 116 | + // Modal styles |
| 117 | + backdrop: { |
| 118 | + backgroundColor: "rgba(0, 0, 0, 0.5)", |
| 119 | + }, |
| 120 | + modalContainer: { |
| 121 | + backgroundColor: "white", |
| 122 | + padding: 24, |
| 123 | + borderRadius: 16, |
| 124 | + width: "90%", |
| 125 | + alignSelf: "center", |
| 126 | + gap: 16, |
| 127 | + }, |
| 128 | + modalTitle: { |
| 129 | + textAlign: "center", |
| 130 | + marginBottom: 8, |
56 | 131 | },
|
57 | 132 | });
|
0 commit comments