delete watch-only account

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2019-12-03 12:38:25 +01:00
parent 4bffdede81
commit a2f64bd544
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
6 changed files with 69 additions and 35 deletions

View File

@ -549,7 +549,8 @@
(toolbar/nav-button (toolbar/nav-button
(actions/back #(re-frame/dispatch [:intro-wizard/navigate-back]))) (actions/back #(re-frame/dispatch [:intro-wizard/navigate-back])))
nil] nil]
[react/view {:style {:flex 1 :justify-content :space-between}} [react/view {:style {:flex 1
:justify-content :space-between}}
[top-bar {:step :enter-phrase}] [top-bar {:step :enter-phrase}]
[enter-phrase wizard-state] [enter-phrase wizard-state]
[bottom-bar (merge {:step :enter-phrase [bottom-bar (merge {:step :enter-phrase

View File

@ -64,7 +64,8 @@
:border-bottom-right-radius 8 :border-bottom-left-radius 8 :flex-direction :row} :border-bottom-right-radius 8 :border-bottom-left-radius 8 :flex-direction :row}
(if (= type :watch) (if (= type :watch)
[react/view {:flex 1 :align-items :center :justify-content :center} [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 [button
(i18n/label :t/wallet-send) (i18n/label :t/wallet-send)
:main-icons/send :main-icons/send

View File

@ -11,7 +11,8 @@
[clojure.string :as string] [clojure.string :as string]
[status-im.ui.components.toolbar :as toolbar] [status-im.ui.components.toolbar :as toolbar]
[status-im.ui.components.copyable-text :as copyable-text] [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] (defview colors-popover [selected-color on-press]
(letsubs [width [:dimensions/window-width]] (letsubs [width [:dimensions/window-width]]
@ -92,7 +93,8 @@
(reset! new-account nil))}])] (reset! new-account nil))}])]
[react/scroll-view {:keyboard-should-persist-taps :handled [react/scroll-view {:keyboard-should-persist-taps :handled
:style {:flex 1}} :style {:flex 1}}
[react/view {:margin-horizontal 16 :padding-bottom 28 :padding-top 10} [react/view {:padding-bottom 28 :padding-top 10}
[react/view {:margin-horizontal 16}
[text-input/text-input-with-label [text-input/text-input-with-label
{:label (i18n/label :t/account-name) {:label (i18n/label :t/account-name)
:label-style {:color colors/gray} :label-style {:color colors/gray}
@ -111,7 +113,10 @@
:border-radius 8 :border-radius 8
:align-items :flex-end :justify-content :center :padding-right 12} :align-items :flex-end :justify-content :center :padding-right 12}
[icons/icon :main-icons/dropdown {:color colors/white}]]] [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/type)
(case type
:watch (i18n/label :t/watch-only)
(i18n/label :t/on-status-tree))]
[property (i18n/label :t/wallet-address) [property (i18n/label :t/wallet-address)
[copyable-text/copyable-text-view [copyable-text/copyable-text-view
{:copied-text address} {:copied-text address}
@ -122,4 +127,10 @@
{:copied-text path} {:copied-text path}
[react/text {:style {:margin-top 6 :font-family "monospace"}} path]]]) [react/text {:style {:margin-top 6 :font-family "monospace"}} path]]])
(when-not (= type :watch) (when-not (= type :watch)
[property (i18n/label :t/storage) (i18n/label :t/this-device)])]]])) [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])}]])]]]))

View File

@ -95,6 +95,16 @@
new-accounts (replace {account new-account} accounts)] new-accounts (replace {account new-account} accounts)]
(multiaccounts.update/multiaccount-update cofx {:accounts new-accounts} nil))) (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 (fx/defn save-generated-account
{:events [:wallet.accounts/save-generated-account]} {:events [:wallet.accounts/save-generated-account]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]

View File

@ -447,3 +447,12 @@
{:db (assoc-in db [:wallet/prepare-transaction :modal-opened?] true)} {:db (assoc-in db [:wallet/prepare-transaction :modal-opened?] true)}
(bottom-sheet/hide-bottom-sheet) (bottom-sheet/hide-bottom-sheet)
(navigation/navigate-to-cofx :contact-code nil))) (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 #()}})

View File

@ -1135,5 +1135,7 @@
"derivation-path": "Derivation path", "derivation-path": "Derivation path",
"storage": "Storage", "storage": "Storage",
"keycard-free-pairing-slots": "Keycard has {{n}} free pairing slots", "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"
} }