|
1 |
| -import { StatusBar } from "expo-status-bar"; |
2 |
| -import { Button, Modal, StyleSheet, Text, View } from "react-native"; |
3 |
| -import { useLocalSearchParams, useRouter } from "expo-router"; |
| 1 | +import React from "react"; |
| 2 | +import { StyleSheet, View } from "react-native"; |
| 3 | +import { useLocalSearchParams, useRouter, Stack } from "expo-router"; |
4 | 4 | import { useState } from "react";
|
5 | 5 | import { useFacade } from "@/data/facades";
|
| 6 | +import { Button, Card, Layout, Modal, Text } from "@ui-kitten/components"; |
| 7 | +import { RemoveAccount as RemoveAccountIcon } from "@/svgs/RemoveAccount"; |
6 | 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 |
|
17 | 16 | return (
|
18 |
| - <View style={styles.container}> |
19 |
| - <Modal visible={modalVisible} animationType="slide"> |
20 |
| - <View style={styles.container}> |
21 |
| - <Text>Are you sure?</Text> |
22 |
| - <Button |
23 |
| - title="Yes, remove account" |
24 |
| - onPress={async () => { |
25 |
| - await removeAccount.mutateAsync({ name: accountName }); |
26 |
| - setModalVisible(false); |
27 |
| - router.dismissAll(); |
28 |
| - }} |
29 |
| - /> |
30 |
| - <Button |
31 |
| - title="I changed my mind" |
32 |
| - onPress={() => setModalVisible(false)} |
33 |
| - /> |
34 |
| - </View> |
35 |
| - </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()} /> |
| 17 | + <> |
| 18 | + <Stack.Screen |
| 19 | + options={{ |
| 20 | + headerTitle: "Remove Account", |
| 21 | + headerBackTitle: "Back", |
| 22 | + }} |
| 23 | + /> |
| 24 | + |
| 25 | + <Layout style={styles.container} level="1"> |
| 26 | + <Modal |
| 27 | + visible={modalVisible} |
| 28 | + backdropStyle={styles.backdrop} |
| 29 | + onBackdropPress={() => setModalVisible(false)} |
| 30 | + > |
| 31 | + <Card disabled style={styles.modalCard}> |
| 32 | + <Text category="h6" style={styles.modalTitle}> |
| 33 | + Are you sure? |
| 34 | + </Text> |
| 35 | + <Button |
| 36 | + style={[styles.modalButton, styles.removeButton]} |
| 37 | + onPress={async () => { |
| 38 | + await removeAccount.mutateAsync({ name: accountName }); |
| 39 | + setModalVisible(false); |
| 40 | + router.dismissAll(); |
| 41 | + }} |
| 42 | + > |
| 43 | + Yes, remove account |
| 44 | + </Button> |
| 45 | + <Button |
| 46 | + style={styles.modalButton} |
| 47 | + appearance="ghost" |
| 48 | + onPress={() => setModalVisible(false)} |
| 49 | + > |
| 50 | + I changed my mind |
| 51 | + </Button> |
| 52 | + </Card> |
| 53 | + </Modal> |
| 54 | + |
| 55 | + <View style={styles.content}> |
| 56 | + <View style={styles.ctaContainer}> |
| 57 | + <RemoveAccountIcon /> |
| 58 | + <Text category="s1" style={styles.title}> |
| 59 | + Remove Account: |
| 60 | + </Text> |
| 61 | + <Text category="s1" style={styles.accountName}> |
| 62 | + {accountName} |
| 63 | + </Text> |
44 | 64 |
|
45 |
| - <StatusBar style="auto" /> |
46 |
| - </View> |
| 65 | + <Text style={styles.description} appearance="hint"> |
| 66 | + Even though you are removing this account, you're still able to |
| 67 | + import it at another time. Please be sure to backup your accounts. |
| 68 | + </Text> |
| 69 | + </View> |
| 70 | + |
| 71 | + <View style={styles.buttonContainer}> |
| 72 | + <Button |
| 73 | + style={[styles.button, styles.removeButton]} |
| 74 | + onPress={() => setModalVisible(true)} |
| 75 | + > |
| 76 | + Remove |
| 77 | + </Button> |
| 78 | + <Button |
| 79 | + style={styles.button} |
| 80 | + appearance="ghost" |
| 81 | + status="basic" |
| 82 | + onPress={() => router.dismiss()} |
| 83 | + > |
| 84 | + Cancel |
| 85 | + </Button> |
| 86 | + </View> |
| 87 | + </View> |
| 88 | + </Layout> |
| 89 | + </> |
47 | 90 | );
|
48 | 91 | }
|
49 | 92 |
|
50 | 93 | const styles = StyleSheet.create({
|
51 | 94 | container: {
|
52 | 95 | flex: 1,
|
53 |
| - backgroundColor: "#fff", |
| 96 | + }, |
| 97 | + content: { |
| 98 | + flex: 1, |
| 99 | + padding: 16, |
| 100 | + alignItems: "center", |
| 101 | + gap: 16, |
| 102 | + justifyContent: "space-between", |
| 103 | + }, |
| 104 | + ctaContainer: { |
54 | 105 | alignItems: "center",
|
55 |
| - justifyContent: "center", |
| 106 | + gap: 8, |
| 107 | + marginTop: 40, |
| 108 | + }, |
| 109 | + title: { |
| 110 | + textAlign: "center", |
| 111 | + letterSpacing: 0.8, |
| 112 | + fontSize: 24, |
| 113 | + }, |
| 114 | + accountName: { |
| 115 | + textAlign: "center", |
| 116 | + fontSize: 24, |
| 117 | + letterSpacing: 0.8, |
| 118 | + }, |
| 119 | + description: { |
| 120 | + textAlign: "center", |
| 121 | + paddingHorizontal: 20, |
| 122 | + fontSize: 16, |
| 123 | + lineHeight: 24, |
| 124 | + marginTop: 24, |
| 125 | + }, |
| 126 | + buttonContainer: { |
| 127 | + width: "100%", |
| 128 | + gap: 8, |
| 129 | + marginBottom: 16, |
| 130 | + }, |
| 131 | + button: { |
| 132 | + borderRadius: 8, |
| 133 | + }, |
| 134 | + removeButton: { |
| 135 | + backgroundColor: "#F15929", |
| 136 | + borderColor: "#F15929", |
| 137 | + }, |
| 138 | + backdrop: { |
| 139 | + backgroundColor: "rgba(0, 0, 0, 0.5)", |
| 140 | + }, |
| 141 | + modalCard: { |
| 142 | + borderRadius: 12, |
| 143 | + margin: 24, |
| 144 | + padding: 16, |
| 145 | + }, |
| 146 | + modalTitle: { |
| 147 | + textAlign: "center", |
| 148 | + marginBottom: 24, |
| 149 | + }, |
| 150 | + modalButton: { |
| 151 | + marginTop: 8, |
| 152 | + borderRadius: 8, |
56 | 153 | },
|
57 | 154 | });
|
0 commit comments