From 5300adcf02475ab412bcf87d676d1957f66fc193 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Mon, 13 May 2024 20:32:01 +0300 Subject: [PATCH] [#19921] feat: remove key pair action --- .../text_combinations/page_top/style.cljs | 5 ++- .../text_combinations/page_top/view.cljs | 5 ++- .../standard_title/view.cljs | 4 +- .../keypairs_and_accounts/actions/view.cljs | 26 ++++++++++--- .../keypairs_and_accounts/remove/style.cljs | 7 ++++ .../keypairs_and_accounts/remove/view.cljs | 38 +++++++++++++++++++ translations/en.json | 3 ++ 7 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 src/status_im/contexts/settings/wallet/keypairs_and_accounts/remove/style.cljs create mode 100644 src/status_im/contexts/settings/wallet/keypairs_and_accounts/remove/view.cljs diff --git a/src/quo/components/text_combinations/page_top/style.cljs b/src/quo/components/text_combinations/page_top/style.cljs index 77c288c47849..bbb1baaea9b2 100644 --- a/src/quo/components/text_combinations/page_top/style.cljs +++ b/src/quo/components/text_combinations/page_top/style.cljs @@ -6,10 +6,11 @@ :padding-horizontal 20 :row-gap 8}) -(def header +(defn header + [title-size] {:flex-direction :row :justify-content :space-between - :height 32}) + :height (if title-size :auto 32)}) (def header-title {:flex 1 diff --git a/src/quo/components/text_combinations/page_top/view.cljs b/src/quo/components/text_combinations/page_top/view.cljs index d10109a8fe5d..527494233f06 100644 --- a/src/quo/components/text_combinations/page_top/view.cljs +++ b/src/quo/components/text_combinations/page_top/view.cljs @@ -34,14 +34,15 @@ (format-counter counter-bottom))]]) (defn- header - [{:keys [title title-accessibility-label input counter-top counter-bottom + [{:keys [title title-size title-accessibility-label input counter-top counter-bottom title-right title-right-props] avatar-props :avatar}] (let [title-props (assoc title-right-props :title title + :title-size title-size :right title-right :accessibility-label title-accessibility-label)] - [rn/view {:style style/header} + [rn/view {:style (style/header title-size)} [rn/view {:style style/header-title} (when avatar-props (let [avatar-props (assoc avatar-props :size :size-32)] diff --git a/src/quo/components/text_combinations/standard_title/view.cljs b/src/quo/components/text_combinations/standard_title/view.cljs index cbc049d93222..c3609aa9a552 100644 --- a/src/quo/components/text_combinations/standard_title/view.cljs +++ b/src/quo/components/text_combinations/standard_title/view.cljs @@ -55,10 +55,10 @@ :icon-color (style/right-tag-icon-color blur? theme)}])) (defn view - [{:keys [title right accessibility-label container-style] :as props}] + [{:keys [title title-size right accessibility-label container-style] :as props}] [rn/view {:style (merge style/container container-style)} [text/text - {:size :heading-1 + {:size (or title-size :heading-1) :weight :semi-bold :accessibility-label accessibility-label} title] diff --git a/src/status_im/contexts/settings/wallet/keypairs_and_accounts/actions/view.cljs b/src/status_im/contexts/settings/wallet/keypairs_and_accounts/actions/view.cljs index 1222dfc6bb30..9a770939b699 100644 --- a/src/status_im/contexts/settings/wallet/keypairs_and_accounts/actions/view.cljs +++ b/src/status_im/contexts/settings/wallet/keypairs_and_accounts/actions/view.cljs @@ -1,18 +1,26 @@ (ns status-im.contexts.settings.wallet.keypairs-and-accounts.actions.view (:require [quo.core :as quo] + [status-im.contexts.settings.wallet.keypairs-and-accounts.remove.view :as remove-key-pair] [utils.i18n :as i18n] [utils.re-frame :as rf])) -(defn on-rename-request - [data] - (rf/dispatch [:open-modal :screen/settings.rename-keypair data])) +(defn on-rename-key-pair + [key-pair] + (rf/dispatch [:open-modal :screen/settings.rename-keypair key-pair])) + +(defn on-remove-key-pair + [key-pair] + (rf/dispatch [:show-bottom-sheet + {:theme :dark + :content (fn [] + [remove-key-pair/view key-pair])}])) (defn on-show-qr [data] (rf/dispatch [:open-modal :screen/settings.encrypted-key-pair-qr data])) (defn view - [props data] + [props key-pair] (let [has-paired-device (rf/sub [:pairing/has-paired-devices])] [:<> [quo/drawer-top props] @@ -21,9 +29,15 @@ [{:icon :i/qr-code :accessibility-label :show-key-pr-qr :label (i18n/label :t/show-encrypted-qr-of-key-pairs) - :on-press #(on-show-qr data)}]) + :on-press #(on-show-qr key-pair)}]) (when (= (:type props) :keypair) [{:icon :i/edit :accessibility-label :rename-key-pair :label (i18n/label :t/rename-key-pair) - :on-press #(on-rename-request data)}])]]])) + :on-press #(on-rename-key-pair key-pair)}] + [{:icon :i/delete + :accessibility-label :remove-key-pair + :add-divider? true + :danger? true + :label (i18n/label :t/remove-key-pair-and-derived-accounts) + :on-press #(on-remove-key-pair key-pair)}])]]])) diff --git a/src/status_im/contexts/settings/wallet/keypairs_and_accounts/remove/style.cljs b/src/status_im/contexts/settings/wallet/keypairs_and_accounts/remove/style.cljs new file mode 100644 index 000000000000..ffc2f00aef89 --- /dev/null +++ b/src/status_im/contexts/settings/wallet/keypairs_and_accounts/remove/style.cljs @@ -0,0 +1,7 @@ +(ns status-im.contexts.settings.wallet.keypairs-and-accounts.remove.style) + +(def header-container + {:margin-bottom 8}) + +(def content + {:margin-horizontal 20}) diff --git a/src/status_im/contexts/settings/wallet/keypairs_and_accounts/remove/view.cljs b/src/status_im/contexts/settings/wallet/keypairs_and_accounts/remove/view.cljs new file mode 100644 index 000000000000..69dc004b7e41 --- /dev/null +++ b/src/status_im/contexts/settings/wallet/keypairs_and_accounts/remove/view.cljs @@ -0,0 +1,38 @@ +(ns status-im.contexts.settings.wallet.keypairs-and-accounts.remove.view + (:require [quo.core :as quo] + [quo.foundations.colors :as colors] + [react-native.core :as rn] + [status-im.common.standard-authentication.core :as standard-auth] + [status-im.contexts.settings.wallet.keypairs-and-accounts.remove.style :as style] + [utils.i18n :as i18n] + [utils.re-frame :as rf])) + +(defn view + [{:keys [name key-uid]}] + (let [customization-color (rf/sub [:profile/customization-color]) + on-remove (rn/use-callback #() + [key-uid])] + [:<> + [quo/page-top + {:container-style style/header-container + :title (i18n/label :t/remove-key-pair-and-derived-accounts) + :title-size :heading-2 + :description :context-tag + :context-tag {:type :icon + :size 24 + :context name + :icon :i/seed-phrase}}] + [rn/view {:style style/content} + [quo/text + {:style {:margin-top 4} + :weight :regular + :size :paragraph-1} + (i18n/label :t/the-key-pair-and-derived-accounts-will-be-removed)] + [standard-auth/slide-button + {:size :size-48 + :track-text (i18n/label :t/slide-to-remove-key-pair) + :container-style {:margin-top 34} + :customization-color colors/danger-50 + :on-auth-success on-remove + :auth-button-label (i18n/label :t/confirm)}]]])) + diff --git a/translations/en.json b/translations/en.json index 021d277a88dc..844d34691b39 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1259,6 +1259,8 @@ "remove-network": "Remove network", "remove-token": "Remove token", "removed": "removed", + "remove-key-pair-and-derived-accounts": "Remove key pair and derived accounts", + "the-key-pair-and-derived-accounts-will-be-removed": "The key pair and derived accounts will be removed from all of your synced devices. Make sure you have a backup of your keys or seed phrase before proceeding.", "rename-key-pair": "Rename key pair", "repeat-pin": "Repeat new 6-digit passcode", "repeat-puk": "Repeat new 12-digit PUK", @@ -1975,6 +1977,7 @@ "slide-to-request-to-join": "Slide to request to join", "slide-to-reveal-code": "Slide to reveal code", "slide-to-create-account": "Slide to create account", + "slide-to-remove-key-pair": "Slide to remove key pair", "slide-to-reveal-qr-code": "Slide to reveal QR code", "minimum-received": "Minimum received", "powered-by-paraswap": "Powered by Paraswap",