Skip to content

Commit ad9dc99

Browse files
committed
[#11468] Hide/show option for accounts in the wallet
Signed-off-by: andrey <motor4ik@gmail.com>
1 parent 8ec46a0 commit ad9dc99

File tree

10 files changed

+90
-19
lines changed

10 files changed

+90
-19
lines changed

src/status_im/subs.cljs

+17-3
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,12 @@
624624
(fn [accounts]
625625
(ethereum/get-default-account accounts)))
626626

627+
(re-frame/reg-sub
628+
:multiaccount/visible-accounts
629+
:<- [:multiaccount/accounts]
630+
(fn [accounts]
631+
(remove :hidden accounts)))
632+
627633
(re-frame/reg-sub
628634
:sign-in-enabled?
629635
:<- [:multiaccounts/login]
@@ -710,13 +716,19 @@
710716
(fn [accounts]
711717
(filter #(not= (:type %) :watch) accounts)))
712718

719+
(re-frame/reg-sub
720+
:visible-accounts-without-watch-only
721+
:<- [:multiaccount/accounts]
722+
(fn [accounts]
723+
(remove :hidden (filter #(not= (:type %) :watch) accounts))))
724+
713725
(defn filter-recipient-accounts
714726
[search-filter {:keys [name]}]
715727
(string/includes? (string/lower-case (str name)) search-filter))
716728

717729
(re-frame/reg-sub
718730
:accounts-for-recipient
719-
:<- [:multiaccount/accounts]
731+
:<- [:multiaccount/visible-accounts]
720732
:<- [:wallet/prepare-transaction]
721733
:<- [:search/recipient-filter]
722734
(fn [[accounts {:keys [from]} search-filter]]
@@ -1551,8 +1563,10 @@
15511563
(re-frame/reg-sub
15521564
:balances
15531565
:<- [:wallet]
1554-
(fn [wallet]
1555-
(map :balance (vals (:accounts wallet)))))
1566+
:<- [:multiaccount/visible-accounts]
1567+
(fn [[wallet accounts]]
1568+
(let [accounts (map :address accounts)]
1569+
(map :balance (vals (select-keys (:accounts wallet) accounts))))))
15561570

15571571
(re-frame/reg-sub
15581572
:empty-balances?

src/status_im/ui/screens/browser/views.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
(str desc)]]))
6666

6767
(views/defview navigation [{:keys [url can-go-back? can-go-forward? dapps-account empty-tab browser-id name]}]
68-
(views/letsubs [accounts [:accounts-without-watch-only]]
68+
(views/letsubs [accounts [:visible-accounts-without-watch-only]]
6969
[react/view (styles/navbar)
7070
[react/touchable-highlight {:on-press #(if can-go-back?
7171
(re-frame/dispatch [:browser.ui/previous-page-button-pressed])

src/status_im/ui/screens/screens.cljs

+6-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@
108108
[status-im.ui.components.icons.icons :as icons]
109109
[status-im.ui.screens.chat.pinned-messages :as pin-messages]
110110
[status-im.ui.screens.communities.create-category :as create-category]
111-
[status-im.ui.screens.communities.select-category :as select-category]))
111+
[status-im.ui.screens.communities.select-category :as select-category]
112+
[status-im.ui.screens.wallet.accounts-manage.views :as accounts-manage]))
112113

113114
(def components
114115
[{:name :chat-toolbar
@@ -376,6 +377,10 @@
376377
:options {:topBar {:title {:text (i18n/label :t/main-currency)}}}
377378
:component currency-settings/currency-settings}
378379

380+
{:name :manage-accounts
381+
:options {:topBar {:title {:text (i18n/label :t/wallet-manage-accounts)}}}
382+
:component accounts-manage/manage}
383+
379384
;;MY STATUS
380385

381386
{:name :status

src/status_im/ui/screens/wallet/accounts/sheets.cljs

+18-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010

1111
(defn accounts-options [mnemonic]
1212
(fn []
13-
[react/view
13+
[:<>
14+
[quo/list-item
15+
{:theme :accent
16+
:title (i18n/label :t/wallet-manage-accounts)
17+
:icon :main-icons/account
18+
:accessibility-label :wallet-manage-accounts
19+
:on-press #(hide-sheet-and-dispatch
20+
[:navigate-to :manage-accounts])}]
1421
[quo/list-item
1522
{:theme :accent
1623
:title (i18n/label :t/wallet-manage-assets)
@@ -47,7 +54,7 @@
4754
:on-press #(hide-sheet-and-dispatch
4855
[:navigate-to :backup-seed])}])]))
4956

50-
(defn account-card-actions [account type]
57+
(defn account-card-actions [account type wallet]
5158
[react/view
5259
(when-not (= type :watch)
5360
[quo/list-item
@@ -63,7 +70,15 @@
6370
:icon :main-icons/share
6471
:accessibility-label :share-account-button
6572
:on-press #(hide-sheet-and-dispatch
66-
[:wallet/share-popover (:address account)])}]])
73+
[:wallet/share-popover (:address account)])}]
74+
(when-not wallet
75+
[quo/list-item
76+
{:theme :accent
77+
:title (i18n/label :t/hide)
78+
:icon :main-icons/hide
79+
:accessibility-label :hide-account-button
80+
:on-press #(hide-sheet-and-dispatch
81+
[:wallet.accounts/save-account account {:hidden true}])}])])
6782

6883
(defn add-account []
6984
(let [keycard? @(re-frame/subscribe [:keycard-multiaccount?])]

src/status_im/ui/screens/wallet/accounts/views.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
[status-im.keycard.login :as keycard.login])
1818
(:require-macros [status-im.utils.views :as views]))
1919

20-
(views/defview account-card [{:keys [name color address type] :as account} keycard? card-width]
20+
(views/defview account-card [{:keys [name color address type wallet] :as account} keycard? card-width]
2121
(views/letsubs [currency [:wallet/currency]
2222
portfolio-value [:account-portfolio-value address]
2323
prices-loading? [:prices-loading?]]
@@ -48,7 +48,7 @@
4848
[react/touchable-highlight
4949
{:style styles/card-icon-more
5050
:on-press #(re-frame/dispatch [:bottom-sheet/show-sheet
51-
{:content (fn [] [sheets/account-card-actions account type])
51+
{:content (fn [] [sheets/account-card-actions account type wallet])
5252
:content-height 130}])}
5353
[icons/icon :main-icons/more {:color colors/white-persist}]]]]]))
5454

@@ -107,7 +107,7 @@
107107
[dot {:selected (= selected i)}])])
108108

109109
(views/defview accounts []
110-
(views/letsubs [accounts [:multiaccount/accounts]
110+
(views/letsubs [accounts [:multiaccount/visible-accounts]
111111
keycard? [:keycard-multiaccount?]
112112
window-width [:dimensions/window-width]
113113
index (reagent/atom 0)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(ns status-im.ui.screens.wallet.accounts-manage.views
2+
(:require [status-im.utils.handlers :refer [>evt <sub]]
3+
[status-im.ui.components.list.views :as list]
4+
[reagent.core :as reagent]
5+
[quo.core :as quo]
6+
[status-im.utils.utils :as utils]
7+
[status-im.ui.components.icons.icons :as icons]
8+
[status-im.ui.components.colors :as colors]))
9+
10+
(defn render-account [_]
11+
(reagent/create-class
12+
{:should-component-update
13+
(fn [_ [_ old-item] [_ new-item]]
14+
(not= (:hidden old-item) (:hidden new-item)))
15+
:reagent-render
16+
(fn [{:keys [hidden name address wallet] :as account}]
17+
[quo/list-item
18+
{:accessory [icons/icon
19+
(if hidden :main-icos/hide :main-icos/show)
20+
(merge {:accessibility-label (if hidden :hide-icon :show-icon)}
21+
(when wallet {:color colors/gray}))]
22+
:animated-accessory? false
23+
:animated false
24+
:disabled wallet
25+
:title name
26+
:subtitle (utils/get-shortened-checksum-address address)
27+
:on-press #(>evt [:wallet.accounts/save-account account {:hidden (not hidden)}])}])}))
28+
29+
(defn manage []
30+
(let [accounts (<sub [:multiaccount/accounts])]
31+
[list/flat-list
32+
{:key-fn :address
33+
:data accounts
34+
:render-fn render-account}]))

src/status_im/ui/screens/wallet/send/sheets.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
:on-press #(re-frame/dispatch [event field account])}])
2525

2626
(views/defview accounts-list [field event]
27-
(views/letsubs [accounts [:multiaccount/accounts]
28-
accounts-whithout-watch [:accounts-without-watch-only]]
27+
(views/letsubs [accounts [:multiaccount/visible-accounts]
28+
accounts-whithout-watch [:visible-accounts-without-watch-only]]
2929
[list/flat-list {:data (if (= :to field) accounts accounts-whithout-watch)
3030
:key-fn :address
3131
:render-data {:field field

src/status_im/wallet/accounts/core.cljs

+3-2
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,12 @@
275275

276276
(fx/defn save-account
277277
{:events [:wallet.accounts/save-account]}
278-
[{:keys [db]} account {:keys [name color]}]
278+
[{:keys [db]} account {:keys [name color hidden]}]
279279
(let [accounts (:multiaccount/accounts db)
280280
new-account (cond-> account
281281
name (assoc :name name)
282-
color (assoc :color color))
282+
color (assoc :color color)
283+
(not (nil? hidden)) (assoc :hidden hidden))
283284
new-accounts (replace {account new-account} accounts)]
284285
{::json-rpc/call [{:method "accounts_saveAccounts"
285286
:params [[new-account]]

status-go-version.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
33
"owner": "status-im",
44
"repo": "status-go",
5-
"version": "v0.83.9",
6-
"commit-sha1": "7dfeda15110af8ae315f41d19db39476a8e28d62",
7-
"src-sha256": "12v2k8679kl8gca6ihpn954rblpfdsi95kcaxpm39dahlg5ax2v9"
5+
"version": "v0.83.11",
6+
"commit-sha1": "fc16588cf1b37a6aea473404495782ca9e0cfff8",
7+
"src-sha256": "0gh0v1v3hcxq99i0szwp8y5395xfcdj920wg2p707s8j3vwrb325"
88
}

translations/en.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,7 @@
12981298
"wallet-invalid-address-checksum": "Error in address: \n {{data}}",
12991299
"wallet-invalid-chain-id": "Network does not match: \n {{data}} but current chain is {{chain}}",
13001300
"wallet-manage-assets": "Manage assets",
1301+
"wallet-manage-accounts": "Manage accounts",
13011302
"wallet-request": "Request",
13021303
"wallet-send": "Send",
13031304
"wallet-send-min-units": "Min 21000 units",
@@ -1645,5 +1646,6 @@
16451646
"suggested-price-limit": "Suggested price limit",
16461647
"include": "Include",
16471648
"category": "Category",
1648-
"edit-chats": "Edit chats"
1649+
"edit-chats": "Edit chats",
1650+
"hide": "Hide"
16491651
}

0 commit comments

Comments
 (0)