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