From a2f64bd544faaddcaf7f3340c2f64f8f8a5abb7e Mon Sep 17 00:00:00 2001 From: Andrey Shovkoplyas Date: Tue, 3 Dec 2019 12:38:25 +0100 Subject: [PATCH] delete watch-only account Signed-off-by: Andrey Shovkoplyas --- src/status_im/ui/screens/intro/views.cljs | 3 +- .../ui/screens/wallet/account/views.cljs | 3 +- .../wallet/account_settings/views.cljs | 75 +++++++++++-------- src/status_im/wallet/accounts/core.cljs | 10 +++ src/status_im/wallet/core.cljs | 9 +++ translations/en.json | 4 +- 6 files changed, 69 insertions(+), 35 deletions(-) diff --git a/src/status_im/ui/screens/intro/views.cljs b/src/status_im/ui/screens/intro/views.cljs index ae1ab52763..2559cd4758 100644 --- a/src/status_im/ui/screens/intro/views.cljs +++ b/src/status_im/ui/screens/intro/views.cljs @@ -549,7 +549,8 @@ (toolbar/nav-button (actions/back #(re-frame/dispatch [:intro-wizard/navigate-back]))) nil] - [react/view {:style {:flex 1 :justify-content :space-between}} + [react/view {:style {:flex 1 + :justify-content :space-between}} [top-bar {:step :enter-phrase}] [enter-phrase wizard-state] [bottom-bar (merge {:step :enter-phrase diff --git a/src/status_im/ui/screens/wallet/account/views.cljs b/src/status_im/ui/screens/wallet/account/views.cljs index 8e3464806c..b819e1b942 100644 --- a/src/status_im/ui/screens/wallet/account/views.cljs +++ b/src/status_im/ui/screens/wallet/account/views.cljs @@ -64,7 +64,8 @@ :border-bottom-right-radius 8 :border-bottom-left-radius 8 :flex-direction :row} (if (= type :watch) [react/view {:flex 1 :align-items :center :justify-content :center} - [react/text {:style {:margin-left 8 :color colors/white}} "Watch-only"]] + [react/text {:style {:margin-left 8 :color colors/white}} + (i18n/label :t/watch-only)]] [button (i18n/label :t/wallet-send) :main-icons/send diff --git a/src/status_im/ui/screens/wallet/account_settings/views.cljs b/src/status_im/ui/screens/wallet/account_settings/views.cljs index 2b2815e695..17db5210ff 100644 --- a/src/status_im/ui/screens/wallet/account_settings/views.cljs +++ b/src/status_im/ui/screens/wallet/account_settings/views.cljs @@ -11,7 +11,8 @@ [clojure.string :as string] [status-im.ui.components.toolbar :as toolbar] [status-im.ui.components.copyable-text :as copyable-text] - [reagent.core :as reagent])) + [reagent.core :as reagent] + [status-im.ui.components.list-item.views :as list-item])) (defview colors-popover [selected-color on-press] (letsubs [width [:dimensions/window-width]] @@ -92,34 +93,44 @@ (reset! new-account nil))}])] [react/scroll-view {:keyboard-should-persist-taps :handled :style {:flex 1}} - [react/view {:margin-horizontal 16 :padding-bottom 28 :padding-top 10} - [text-input/text-input-with-label - {:label (i18n/label :t/account-name) - :label-style {:color colors/gray} - :auto-focus false - :default-value (:name account) - :on-change-text #(swap! new-account assoc :name %)}] - [react/text {:style {:margin-top 30 :color colors/gray}} (i18n/label :t/account-color)] - [react/touchable-highlight - {:on-press #(re-frame/dispatch [:show-popover - {:view [colors-popover color - (fn [new-color] - (swap! new-account assoc :color new-color) - (re-frame/dispatch [:hide-popover]))] - :style {:max-height "60%"}}])} - [react/view {:height 52 :margin-top 12 :background-color (or (:color @new-account) color) - :border-radius 8 - :align-items :flex-end :justify-content :center :padding-right 12} - [icons/icon :main-icons/dropdown {:color colors/white}]]] - [property (i18n/label :t/type) (case type :watch "Watch-only" (i18n/label :t/on-status-tree))] - [property (i18n/label :t/wallet-address) - [copyable-text/copyable-text-view - {:copied-text address} - [react/text {:style {:margin-top 6 :font-family "monospace"}} address]]] - (when-not (= type :watch) - [property (i18n/label :t/derivation-path) - [copyable-text/copyable-text-view - {:copied-text path} - [react/text {:style {:margin-top 6 :font-family "monospace"}} path]]]) - (when-not (= type :watch) - [property (i18n/label :t/storage) (i18n/label :t/this-device)])]]])) \ No newline at end of file + [react/view {:padding-bottom 28 :padding-top 10} + [react/view {:margin-horizontal 16} + [text-input/text-input-with-label + {:label (i18n/label :t/account-name) + :label-style {:color colors/gray} + :auto-focus false + :default-value (:name account) + :on-change-text #(swap! new-account assoc :name %)}] + [react/text {:style {:margin-top 30 :color colors/gray}} (i18n/label :t/account-color)] + [react/touchable-highlight + {:on-press #(re-frame/dispatch [:show-popover + {:view [colors-popover color + (fn [new-color] + (swap! new-account assoc :color new-color) + (re-frame/dispatch [:hide-popover]))] + :style {:max-height "60%"}}])} + [react/view {:height 52 :margin-top 12 :background-color (or (:color @new-account) color) + :border-radius 8 + :align-items :flex-end :justify-content :center :padding-right 12} + [icons/icon :main-icons/dropdown {:color colors/white}]]] + [property (i18n/label :t/type) + (case type + :watch (i18n/label :t/watch-only) + (i18n/label :t/on-status-tree))] + [property (i18n/label :t/wallet-address) + [copyable-text/copyable-text-view + {:copied-text address} + [react/text {:style {:margin-top 6 :font-family "monospace"}} address]]] + (when-not (= type :watch) + [property (i18n/label :t/derivation-path) + [copyable-text/copyable-text-view + {:copied-text path} + [react/text {:style {:margin-top 6 :font-family "monospace"}} path]]]) + (when-not (= type :watch) + [property (i18n/label :t/storage) (i18n/label :t/this-device)])] + (when (= type :watch) + [react/view + [react/view {:margin-bottom 8 :margin-top 28 :height 1 :background-color colors/gray-lighter}] + [list-item/list-item + {:theme :action-destructive :title :t/delete-account + :on-press #(re-frame/dispatch [:wallet.settings/show-delete-account-confirmation account])}]])]]])) \ No newline at end of file diff --git a/src/status_im/wallet/accounts/core.cljs b/src/status_im/wallet/accounts/core.cljs index 2e2350803d..709c2b362b 100644 --- a/src/status_im/wallet/accounts/core.cljs +++ b/src/status_im/wallet/accounts/core.cljs @@ -95,6 +95,16 @@ new-accounts (replace {account new-account} accounts)] (multiaccounts.update/multiaccount-update cofx {:accounts new-accounts} nil))) +(fx/defn delete-account + {:events [:wallet.accounts/delete-account]} + [{:keys [db] :as cofx} account] + (let [{:keys [accounts]} (:multiaccount db) + new-accounts (vec (remove #(= account %) accounts))] + (println account new-accounts) + (fx/merge cofx + (multiaccounts.update/multiaccount-update {:accounts new-accounts} nil) + (navigation/navigate-to-cofx :wallet nil)))) + (fx/defn save-generated-account {:events [:wallet.accounts/save-generated-account]} [{:keys [db] :as cofx}] diff --git a/src/status_im/wallet/core.cljs b/src/status_im/wallet/core.cljs index b06b1fdb72..a68042310e 100644 --- a/src/status_im/wallet/core.cljs +++ b/src/status_im/wallet/core.cljs @@ -447,3 +447,12 @@ {:db (assoc-in db [:wallet/prepare-transaction :modal-opened?] true)} (bottom-sheet/hide-bottom-sheet) (navigation/navigate-to-cofx :contact-code nil))) + +(fx/defn show-delete-account-confirmation + {:events [:wallet.settings/show-delete-account-confirmation]} + [_ account] + {:ui/show-confirmation {:title (i18n/label :t/are-you-sure?) + :confirm-button-text (i18n/label :t/yes) + :cancel-button-text (i18n/label :t/no) + :on-accept #(re-frame/dispatch [:wallet.accounts/delete-account account]) + :on-cancel #()}}) \ No newline at end of file diff --git a/translations/en.json b/translations/en.json index e867fdb71f..afa4d3bd55 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1135,5 +1135,7 @@ "derivation-path": "Derivation path", "storage": "Storage", "keycard-free-pairing-slots": "Keycard has {{n}} free pairing slots", - "public-chat-description": "A public chat is where you get to hang out with others, make friends and talk about subjects of your interest." + "public-chat-description": "A public chat is where you get to hang out with others, make friends and talk about subjects of your interest.", + "delete-account": "Delete account", + "watch-only": "Watch-only" }