[#11468] Hide/show option for accounts in the wallet

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2021-08-10 13:45:53 +02:00
parent 8ec46a0d78
commit ad9dc9913f
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
10 changed files with 90 additions and 19 deletions

View File

@ -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?

View File

@ -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])

View File

@ -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

View File

@ -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?])]

View File

@ -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)]

View File

@ -0,0 +1,34 @@
(ns status-im.ui.screens.wallet.accounts-manage.views
(:require [status-im.utils.handlers :refer [>evt <sub]]
[status-im.ui.components.list.views :as list]
[reagent.core :as reagent]
[quo.core :as quo]
[status-im.utils.utils :as utils]
[status-im.ui.components.icons.icons :as icons]
[status-im.ui.components.colors :as colors]))
(defn render-account [_]
(reagent/create-class
{:should-component-update
(fn [_ [_ old-item] [_ new-item]]
(not= (:hidden old-item) (:hidden new-item)))
:reagent-render
(fn [{:keys [hidden name address wallet] :as account}]
[quo/list-item
{:accessory [icons/icon
(if hidden :main-icos/hide :main-icos/show)
(merge {:accessibility-label (if hidden :hide-icon :show-icon)}
(when wallet {:color colors/gray}))]
:animated-accessory? false
:animated false
:disabled wallet
:title name
:subtitle (utils/get-shortened-checksum-address address)
:on-press #(>evt [:wallet.accounts/save-account account {:hidden (not hidden)}])}])}))
(defn manage []
(let [accounts (<sub [:multiaccount/accounts])]
[list/flat-list
{:key-fn :address
:data accounts
:render-fn render-account}]))

View File

@ -24,8 +24,8 @@
:on-press #(re-frame/dispatch [event field account])}])
(views/defview accounts-list [field event]
(views/letsubs [accounts [:multiaccount/accounts]
accounts-whithout-watch [:accounts-without-watch-only]]
(views/letsubs [accounts [:multiaccount/visible-accounts]
accounts-whithout-watch [:visible-accounts-without-watch-only]]
[list/flat-list {:data (if (= :to field) accounts accounts-whithout-watch)
:key-fn :address
:render-data {:field field

View File

@ -275,11 +275,12 @@
(fx/defn save-account
{:events [:wallet.accounts/save-account]}
[{:keys [db]} account {:keys [name color]}]
[{:keys [db]} account {:keys [name color hidden]}]
(let [accounts (:multiaccount/accounts db)
new-account (cond-> account
name (assoc :name name)
color (assoc :color color))
color (assoc :color color)
(not (nil? hidden)) (assoc :hidden hidden))
new-accounts (replace {account new-account} accounts)]
{::json-rpc/call [{:method "accounts_saveAccounts"
:params [[new-account]]

View File

@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im",
"repo": "status-go",
"version": "v0.83.9",
"commit-sha1": "7dfeda15110af8ae315f41d19db39476a8e28d62",
"src-sha256": "12v2k8679kl8gca6ihpn954rblpfdsi95kcaxpm39dahlg5ax2v9"
"version": "v0.83.11",
"commit-sha1": "fc16588cf1b37a6aea473404495782ca9e0cfff8",
"src-sha256": "0gh0v1v3hcxq99i0szwp8y5395xfcdj920wg2p707s8j3vwrb325"
}

View File

@ -1298,6 +1298,7 @@
"wallet-invalid-address-checksum": "Error in address: \n {{data}}",
"wallet-invalid-chain-id": "Network does not match: \n {{data}} but current chain is {{chain}}",
"wallet-manage-assets": "Manage assets",
"wallet-manage-accounts": "Manage accounts",
"wallet-request": "Request",
"wallet-send": "Send",
"wallet-send-min-units": "Min 21000 units",
@ -1645,5 +1646,6 @@
"suggested-price-limit": "Suggested price limit",
"include": "Include",
"category": "Category",
"edit-chats": "Edit chats"
"edit-chats": "Edit chats",
"hide": "Hide"
}