feat(wallet): add ability to remove wallet account (#19121)
This commit is contained in:
parent
219dd7cb46
commit
d0d7310e82
|
@ -9,7 +9,6 @@
|
||||||
[status-im.contexts.wallet.sheets.network-preferences.view
|
[status-im.contexts.wallet.sheets.network-preferences.view
|
||||||
:as network-preferences]
|
:as network-preferences]
|
||||||
[status-im.contexts.wallet.sheets.remove-account.view :as remove-account]
|
[status-im.contexts.wallet.sheets.remove-account.view :as remove-account]
|
||||||
[status-im.feature-flags :as ff]
|
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
@ -67,13 +66,10 @@
|
||||||
[create-or-edit-account/view
|
[create-or-edit-account/view
|
||||||
{:page-nav-right-side [(when-not default-account?
|
{:page-nav-right-side [(when-not default-account?
|
||||||
{:icon-name :i/delete
|
{:icon-name :i/delete
|
||||||
:on-press
|
:on-press #(rf/dispatch [:show-bottom-sheet
|
||||||
#(ff/alert ::ff/wallet.remove-account
|
{:content
|
||||||
(fn []
|
(fn []
|
||||||
(rf/dispatch [:show-bottom-sheet
|
[remove-account/view])}])})]
|
||||||
{:content
|
|
||||||
(fn []
|
|
||||||
[remove-account/view])}])))})]
|
|
||||||
:account-name account-name
|
:account-name account-name
|
||||||
:account-emoji emoji
|
:account-emoji emoji
|
||||||
:account-color color
|
:account-color color
|
||||||
|
|
|
@ -95,10 +95,16 @@
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/remove-account-success
|
:wallet/remove-account-success
|
||||||
(fn [_ [toast-message _]]
|
(fn [_ [toast-message _]]
|
||||||
{:fx [[:dispatch [:hide-bottom-sheet]]
|
{:fx [[:dispatch [:wallet/get-accounts]]
|
||||||
[:dispatch [:pop-to-root :shell-stack]]
|
[:dispatch-later
|
||||||
[:dispatch [:wallet/get-accounts]]
|
{:ms 100
|
||||||
[:dispatch [:wallet/show-account-deleted-toast toast-message]]]}))
|
:dispatch [:hide-bottom-sheet]}]
|
||||||
|
[:dispatch-later
|
||||||
|
{:ms 100
|
||||||
|
:dispatch [:pop-to-root :shell-stack]}]
|
||||||
|
[:dispatch-later
|
||||||
|
{:ms 100
|
||||||
|
:dispatch [:wallet/show-account-deleted-toast toast-message]}]]}))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/remove-account
|
:wallet/remove-account
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
(:require
|
(:require
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[reagent.core :as reagent]
|
|
||||||
[status-im.common.home.top-nav.view :as common.top-nav]
|
[status-im.common.home.top-nav.view :as common.top-nav]
|
||||||
[status-im.contexts.wallet.home.style :as style]
|
[status-im.contexts.wallet.home.style :as style]
|
||||||
[status-im.contexts.wallet.home.tabs.view :as tabs]
|
[status-im.contexts.wallet.home.tabs.view :as tabs]
|
||||||
|
@ -39,39 +38,49 @@
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [selected-tab (reagent/atom (:id (first tabs-data)))]
|
(let [[selected-tab set-selected-tab] (rn/use-state (:id (first tabs-data)))
|
||||||
(fn []
|
account-list-ref (rn/use-ref-atom nil)
|
||||||
(let [tokens-loading? (rf/sub [:wallet/tokens-loading?])
|
tokens-loading? (rf/sub [:wallet/tokens-loading?])
|
||||||
networks (rf/sub [:wallet/network-details])
|
networks (rf/sub [:wallet/network-details])
|
||||||
account-cards-data (rf/sub [:wallet/account-cards-data])
|
account-cards-data (rf/sub [:wallet/account-cards-data])
|
||||||
cards (conj account-cards-data (new-account-card-data))
|
cards (conj account-cards-data (new-account-card-data))
|
||||||
{:keys [formatted-balance]} (rf/sub [:wallet/aggregated-tokens-and-balance])]
|
|
||||||
[rn/view {:style (style/home-container)}
|
{:keys [formatted-balance]} (rf/sub [:wallet/aggregated-tokens-and-balance])]
|
||||||
[common.top-nav/view]
|
(rn/use-effect (fn []
|
||||||
[rn/view {:style style/overview-container}
|
(when (and @account-list-ref (pos? (count cards)))
|
||||||
[quo/wallet-overview
|
(.scrollToOffset ^js @account-list-ref
|
||||||
{:state (if tokens-loading? :loading :default)
|
#js
|
||||||
:time-frame :none
|
{:animated true
|
||||||
:metrics :none
|
:offset 0}
|
||||||
:balance formatted-balance
|
)))
|
||||||
:networks networks
|
[(count cards)])
|
||||||
:dropdown-on-press #(ff/alert ::ff/wallet.network-filter
|
[rn/view {:style (style/home-container)}
|
||||||
(fn []
|
[common.top-nav/view]
|
||||||
(rf/dispatch [:show-bottom-sheet
|
[rn/view {:style style/overview-container}
|
||||||
{:content network-filter/view}])))}]]
|
[quo/wallet-overview
|
||||||
[quo/wallet-graph {:time-frame :empty}]
|
{:state (if tokens-loading? :loading :default)
|
||||||
[rn/flat-list
|
:time-frame :none
|
||||||
{:style style/accounts-list
|
:metrics :none
|
||||||
:content-container-style style/accounts-list-container
|
:balance formatted-balance
|
||||||
:data cards
|
:networks networks
|
||||||
:horizontal true
|
:dropdown-on-press #(ff/alert ::ff/wallet.network-filter
|
||||||
:separator [rn/view {:style style/separator}]
|
(fn []
|
||||||
:render-fn (fn [item] [quo/account-card item])
|
(rf/dispatch [:show-bottom-sheet
|
||||||
:shows-horizontal-scroll-indicator false}]
|
{:content network-filter/view}])))}]]
|
||||||
[quo/tabs
|
[quo/wallet-graph {:time-frame :empty}]
|
||||||
{:style style/tabs
|
[rn/flat-list
|
||||||
:size 32
|
{:ref #(reset! account-list-ref %)
|
||||||
:default-active @selected-tab
|
:style style/accounts-list
|
||||||
:data tabs-data
|
:content-container-style style/accounts-list-container
|
||||||
:on-change #(reset! selected-tab %)}]
|
:data cards
|
||||||
[tabs/view {:selected-tab @selected-tab}]]))))
|
:horizontal true
|
||||||
|
:separator [rn/view {:style style/separator}]
|
||||||
|
:render-fn (fn [item] [quo/account-card item])
|
||||||
|
:shows-horizontal-scroll-indicator false}]
|
||||||
|
[quo/tabs
|
||||||
|
{:style style/tabs
|
||||||
|
:size 32
|
||||||
|
:default-active selected-tab
|
||||||
|
:data tabs-data
|
||||||
|
:on-change #(set-selected-tab %)}]
|
||||||
|
[tabs/view {:selected-tab selected-tab}]]))
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
[status-im.contexts.wallet.common.utils :as utils]
|
[status-im.contexts.wallet.common.utils :as utils]
|
||||||
[status-im.contexts.wallet.sheets.account-options.style :as style]
|
[status-im.contexts.wallet.sheets.account-options.style :as style]
|
||||||
[status-im.contexts.wallet.sheets.remove-account.view :as remove-account]
|
[status-im.contexts.wallet.sheets.remove-account.view :as remove-account]
|
||||||
[status-im.feature-flags :as ff]
|
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
@ -99,12 +98,8 @@
|
||||||
:accessibility-label :remove-account
|
:accessibility-label :remove-account
|
||||||
:label (i18n/label :t/remove-account)
|
:label (i18n/label :t/remove-account)
|
||||||
:danger? true
|
:danger? true
|
||||||
:on-press #(ff/alert ::ff/wallet.remove-account
|
:on-press #(rf/dispatch [:show-bottom-sheet
|
||||||
(fn []
|
{:content remove-account/view}])})]]]
|
||||||
(rf/dispatch [:show-bottom-sheet
|
|
||||||
{:content
|
|
||||||
(fn []
|
|
||||||
[remove-account/view])}])))})]]]
|
|
||||||
(when show-account-selector?
|
(when show-account-selector?
|
||||||
[:<>
|
[:<>
|
||||||
[quo/divider-line {:container-style style/divider-label}]
|
[quo/divider-line {:container-style style/divider-label}]
|
||||||
|
|
|
@ -13,19 +13,18 @@
|
||||||
(defn- footer
|
(defn- footer
|
||||||
[{:keys [address submit-disabled? toast-message]}]
|
[{:keys [address submit-disabled? toast-message]}]
|
||||||
[quo/bottom-actions
|
[quo/bottom-actions
|
||||||
{:actions :2-actions
|
{:actions :two-actions
|
||||||
:customization-color :danger
|
:button-one-label (i18n/label :t/remove)
|
||||||
:button-one-label (i18n/label :t/remove)
|
:button-one-props {:on-press
|
||||||
:button-one-props {:on-press
|
(fn []
|
||||||
(fn []
|
(rf/dispatch [:wallet/remove-account
|
||||||
(rf/dispatch [:wallet/remove-account
|
{:address address
|
||||||
{:address address
|
:toast-message toast-message}]))
|
||||||
:toast-message toast-message}]))
|
:type :danger
|
||||||
:type :danger
|
:disabled? submit-disabled?}
|
||||||
:disabled? submit-disabled?}
|
:button-two-label (i18n/label :t/cancel)
|
||||||
:button-two-label (i18n/label :t/cancel)
|
:button-two-props {:on-press #(rf/dispatch [:hide-bottom-sheet])
|
||||||
:button-two-props {:on-press #(rf/dispatch [:hide-bottom-sheet])
|
:type :grey}}])
|
||||||
:type :grey}}])
|
|
||||||
|
|
||||||
(defn- recovery-phase-flow
|
(defn- recovery-phase-flow
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
(reagent/atom
|
(reagent/atom
|
||||||
{::wallet.edit-default-keypair true
|
{::wallet.edit-default-keypair true
|
||||||
::wallet.bridge-token (enabled-in-env? :FLAG_BRIDGE_TOKEN_ENABLED)
|
::wallet.bridge-token (enabled-in-env? :FLAG_BRIDGE_TOKEN_ENABLED)
|
||||||
::wallet.remove-account (enabled-in-env? :FLAG_REMOVE_ACCOUNT_ENABLED)
|
|
||||||
::wallet.network-filter (enabled-in-env? :FLAG_NETWORK_FILTER_ENABLED)
|
::wallet.network-filter (enabled-in-env? :FLAG_NETWORK_FILTER_ENABLED)
|
||||||
::profile.new-contact-ui (enabled-in-env? :FLAG_NEW_CONTACT_UI_ENABLED)}))
|
::profile.new-contact-ui (enabled-in-env? :FLAG_NEW_CONTACT_UI_ENABLED)}))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue