diff --git a/src/status_im/subs.cljs b/src/status_im/subs.cljs index 941a2b9f94..0f9f7d0329 100644 --- a/src/status_im/subs.cljs +++ b/src/status_im/subs.cljs @@ -624,6 +624,12 @@ (fn [accounts] (ethereum/get-default-account accounts))) +(re-frame/reg-sub + :multiaccount/visible-accounts + :<- [:multiaccount/accounts] + (fn [accounts] + (remove :hidden accounts))) + (re-frame/reg-sub :sign-in-enabled? :<- [:multiaccounts/login] @@ -710,13 +716,19 @@ (fn [accounts] (filter #(not= (:type %) :watch) accounts))) +(re-frame/reg-sub + :visible-accounts-without-watch-only + :<- [:multiaccount/accounts] + (fn [accounts] + (remove :hidden (filter #(not= (:type %) :watch) accounts)))) + (defn filter-recipient-accounts [search-filter {:keys [name]}] (string/includes? (string/lower-case (str name)) search-filter)) (re-frame/reg-sub :accounts-for-recipient - :<- [:multiaccount/accounts] + :<- [:multiaccount/visible-accounts] :<- [:wallet/prepare-transaction] :<- [:search/recipient-filter] (fn [[accounts {:keys [from]} search-filter]] @@ -1551,8 +1563,10 @@ (re-frame/reg-sub :balances :<- [:wallet] - (fn [wallet] - (map :balance (vals (:accounts wallet))))) + :<- [:multiaccount/visible-accounts] + (fn [[wallet accounts]] + (let [accounts (map :address accounts)] + (map :balance (vals (select-keys (:accounts wallet) accounts)))))) (re-frame/reg-sub :empty-balances? diff --git a/src/status_im/ui/screens/browser/views.cljs b/src/status_im/ui/screens/browser/views.cljs index 4c811821c8..0576744a85 100644 --- a/src/status_im/ui/screens/browser/views.cljs +++ b/src/status_im/ui/screens/browser/views.cljs @@ -65,7 +65,7 @@ (str desc)]])) (views/defview navigation [{:keys [url can-go-back? can-go-forward? dapps-account empty-tab browser-id name]}] - (views/letsubs [accounts [:accounts-without-watch-only]] + (views/letsubs [accounts [:visible-accounts-without-watch-only]] [react/view (styles/navbar) [react/touchable-highlight {:on-press #(if can-go-back? (re-frame/dispatch [:browser.ui/previous-page-button-pressed]) diff --git a/src/status_im/ui/screens/screens.cljs b/src/status_im/ui/screens/screens.cljs index 8375c3bde4..05b22dcef4 100644 --- a/src/status_im/ui/screens/screens.cljs +++ b/src/status_im/ui/screens/screens.cljs @@ -108,7 +108,8 @@ [status-im.ui.components.icons.icons :as icons] [status-im.ui.screens.chat.pinned-messages :as pin-messages] [status-im.ui.screens.communities.create-category :as create-category] - [status-im.ui.screens.communities.select-category :as select-category])) + [status-im.ui.screens.communities.select-category :as select-category] + [status-im.ui.screens.wallet.accounts-manage.views :as accounts-manage])) (def components [{:name :chat-toolbar @@ -376,6 +377,10 @@ :options {:topBar {:title {:text (i18n/label :t/main-currency)}}} :component currency-settings/currency-settings} + {:name :manage-accounts + :options {:topBar {:title {:text (i18n/label :t/wallet-manage-accounts)}}} + :component accounts-manage/manage} + ;;MY STATUS {:name :status diff --git a/src/status_im/ui/screens/wallet/accounts/sheets.cljs b/src/status_im/ui/screens/wallet/accounts/sheets.cljs index 58a3f5a9ce..1fa701e5e8 100644 --- a/src/status_im/ui/screens/wallet/accounts/sheets.cljs +++ b/src/status_im/ui/screens/wallet/accounts/sheets.cljs @@ -10,7 +10,14 @@ (defn accounts-options [mnemonic] (fn [] - [react/view + [:<> + [quo/list-item + {:theme :accent + :title (i18n/label :t/wallet-manage-accounts) + :icon :main-icons/account + :accessibility-label :wallet-manage-accounts + :on-press #(hide-sheet-and-dispatch + [:navigate-to :manage-accounts])}] [quo/list-item {:theme :accent :title (i18n/label :t/wallet-manage-assets) @@ -47,7 +54,7 @@ :on-press #(hide-sheet-and-dispatch [:navigate-to :backup-seed])}])])) -(defn account-card-actions [account type] +(defn account-card-actions [account type wallet] [react/view (when-not (= type :watch) [quo/list-item @@ -63,7 +70,15 @@ :icon :main-icons/share :accessibility-label :share-account-button :on-press #(hide-sheet-and-dispatch - [:wallet/share-popover (:address account)])}]]) + [:wallet/share-popover (:address account)])}] + (when-not wallet + [quo/list-item + {:theme :accent + :title (i18n/label :t/hide) + :icon :main-icons/hide + :accessibility-label :hide-account-button + :on-press #(hide-sheet-and-dispatch + [:wallet.accounts/save-account account {:hidden true}])}])]) (defn add-account [] (let [keycard? @(re-frame/subscribe [:keycard-multiaccount?])] diff --git a/src/status_im/ui/screens/wallet/accounts/views.cljs b/src/status_im/ui/screens/wallet/accounts/views.cljs index 48f7efa375..f8aa0bff53 100644 --- a/src/status_im/ui/screens/wallet/accounts/views.cljs +++ b/src/status_im/ui/screens/wallet/accounts/views.cljs @@ -17,7 +17,7 @@ [status-im.keycard.login :as keycard.login]) (:require-macros [status-im.utils.views :as views])) -(views/defview account-card [{:keys [name color address type] :as account} keycard? card-width] +(views/defview account-card [{:keys [name color address type wallet] :as account} keycard? card-width] (views/letsubs [currency [:wallet/currency] portfolio-value [:account-portfolio-value address] prices-loading? [:prices-loading?]] @@ -48,7 +48,7 @@ [react/touchable-highlight {:style styles/card-icon-more :on-press #(re-frame/dispatch [:bottom-sheet/show-sheet - {:content (fn [] [sheets/account-card-actions account type]) + {:content (fn [] [sheets/account-card-actions account type wallet]) :content-height 130}])} [icons/icon :main-icons/more {:color colors/white-persist}]]]]])) @@ -107,7 +107,7 @@ [dot {:selected (= selected i)}])]) (views/defview accounts [] - (views/letsubs [accounts [:multiaccount/accounts] + (views/letsubs [accounts [:multiaccount/visible-accounts] keycard? [:keycard-multiaccount?] window-width [:dimensions/window-width] index (reagent/atom 0)] diff --git a/src/status_im/ui/screens/wallet/accounts_manage/views.cljs b/src/status_im/ui/screens/wallet/accounts_manage/views.cljs new file mode 100644 index 0000000000..5d3f1de663 --- /dev/null +++ b/src/status_im/ui/screens/wallet/accounts_manage/views.cljs @@ -0,0 +1,34 @@ +(ns status-im.ui.screens.wallet.accounts-manage.views + (:require [status-im.utils.handlers :refer [>evt