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,34 +93,44 @@
(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}
[text-input/text-input-with-label [react/view {:margin-horizontal 16}
{:label (i18n/label :t/account-name) [text-input/text-input-with-label
:label-style {:color colors/gray} {:label (i18n/label :t/account-name)
:auto-focus false :label-style {:color colors/gray}
:default-value (:name account) :auto-focus false
:on-change-text #(swap! new-account assoc :name %)}] :default-value (:name account)
[react/text {:style {:margin-top 30 :color colors/gray}} (i18n/label :t/account-color)] :on-change-text #(swap! new-account assoc :name %)}]
[react/touchable-highlight [react/text {:style {:margin-top 30 :color colors/gray}} (i18n/label :t/account-color)]
{:on-press #(re-frame/dispatch [:show-popover [react/touchable-highlight
{:view [colors-popover color {:on-press #(re-frame/dispatch [:show-popover
(fn [new-color] {:view [colors-popover color
(swap! new-account assoc :color new-color) (fn [new-color]
(re-frame/dispatch [:hide-popover]))] (swap! new-account assoc :color new-color)
:style {:max-height "60%"}}])} (re-frame/dispatch [:hide-popover]))]
[react/view {:height 52 :margin-top 12 :background-color (or (:color @new-account) color) :style {:max-height "60%"}}])}
:border-radius 8 [react/view {:height 52 :margin-top 12 :background-color (or (:color @new-account) color)
:align-items :flex-end :justify-content :center :padding-right 12} :border-radius 8
[icons/icon :main-icons/dropdown {:color colors/white}]]] :align-items :flex-end :justify-content :center :padding-right 12}
[property (i18n/label :t/type) (case type :watch "Watch-only" (i18n/label :t/on-status-tree))] [icons/icon :main-icons/dropdown {:color colors/white}]]]
[property (i18n/label :t/wallet-address) [property (i18n/label :t/type)
[copyable-text/copyable-text-view (case type
{:copied-text address} :watch (i18n/label :t/watch-only)
[react/text {:style {:margin-top 6 :font-family "monospace"}} address]]] (i18n/label :t/on-status-tree))]
(when-not (= type :watch) [property (i18n/label :t/wallet-address)
[property (i18n/label :t/derivation-path) [copyable-text/copyable-text-view
[copyable-text/copyable-text-view {:copied-text address}
{:copied-text path} [react/text {:style {:margin-top 6 :font-family "monospace"}} address]]]
[react/text {:style {:margin-top 6 :font-family "monospace"}} path]]]) (when-not (= type :watch)
(when-not (= type :watch) [property (i18n/label :t/derivation-path)
[property (i18n/label :t/storage) (i18n/label :t/this-device)])]]])) [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)] 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"
} }