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
(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

View File

@ -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

View File

@ -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)])]]]))
[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])}]])]]]))

View File

@ -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}]

View File

@ -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 #()}})

View File

@ -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"
}