From e59b782b86e5a1272b0fd8522a296b8ddf0f6aa8 Mon Sep 17 00:00:00 2001 From: Lungu Cristian Date: Tue, 19 Nov 2024 12:08:52 +0200 Subject: [PATCH] Wallet design review fixes (#21542) * feat: hide token price-change info if no token balance * fix: show dapps header button only on account screen * ref: renamed to above-zero? and using it where needed * fix: removed bridge icon from submit button --- src/status_im/contexts/wallet/account/view.cljs | 5 +++-- .../contexts/wallet/bridge/input_amount/view.cljs | 1 - .../contexts/wallet/common/account_switcher/view.cljs | 11 +++++++---- .../contexts/wallet/common/token_value/view.cljs | 2 +- src/status_im/contexts/wallet/common/utils.cljs | 5 ++--- .../contexts/wallet/common/utils/networks.cljs | 2 +- src/status_im/contexts/wallet/send/utils.cljs | 4 ++-- .../wallet/sheets/slippage_settings/view.cljs | 3 +-- src/utils/money.cljs | 7 +++++++ 9 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/status_im/contexts/wallet/account/view.cljs b/src/status_im/contexts/wallet/account/view.cljs index 3728591102..0c045a534a 100644 --- a/src/status_im/contexts/wallet/account/view.cljs +++ b/src/status_im/contexts/wallet/account/view.cljs @@ -35,8 +35,9 @@ #(rf/dispatch [:wallet/fetch-activities-for-current-account])) [rn/view {:style {:flex 1}} [account-switcher/view - {:type :wallet-networks - :on-press #(rf/dispatch [:pop-to-root :shell-stack])}] + {:type :wallet-networks + :show-dapps-button? true + :on-press #(rf/dispatch [:pop-to-root :shell-stack])}] [quo/account-overview {:container-style style/account-overview :current-value formatted-balance diff --git a/src/status_im/contexts/wallet/bridge/input_amount/view.cljs b/src/status_im/contexts/wallet/bridge/input_amount/view.cljs index 5dc7738fda..f8b3f04a64 100644 --- a/src/status_im/contexts/wallet/bridge/input_amount/view.cljs +++ b/src/status_im/contexts/wallet/bridge/input_amount/view.cljs @@ -12,7 +12,6 @@ [input-amount/view {:current-screen-id :screen/wallet.bridge-input-amount :button-one-label (i18n/label :t/review-bridge) - :button-one-props {:icon-left :i/bridge} :enabled-from-chain-ids (rf/sub [:wallet/bridge-from-chain-ids]) :from-enabled-networks (rf/sub [:wallet/bridge-from-networks]) diff --git a/src/status_im/contexts/wallet/common/account_switcher/view.cljs b/src/status_im/contexts/wallet/common/account_switcher/view.cljs index b5f99300fe..df8c7874d5 100644 --- a/src/status_im/contexts/wallet/common/account_switcher/view.cljs +++ b/src/status_im/contexts/wallet/common/account_switcher/view.cljs @@ -16,15 +16,17 @@ [select-account/view params])} nil)) -(defn- on-dapps-press +(defn- on-switcher-press [switcher-type params] (rf/dispatch [:show-bottom-sheet (get-bottom-sheet-args switcher-type params)])) (defn view - [{:keys [type on-press accessibility-label icon-name switcher-type margin-top params] + [{:keys [type on-press accessibility-label icon-name switcher-type margin-top params + show-dapps-button?] :or {icon-name :i/close accessibility-label :top-bar switcher-type :account-options + show-dapps-button? false type :no-title}}] (let [{:keys [color emoji watch-only?]} (rf/sub [:wallet/current-viewing-account]) networks (rf/sub [:wallet/selected-network-details]) @@ -40,12 +42,13 @@ :align-center? true :networks-on-press #(rf/dispatch [:show-bottom-sheet {:content network-filter/view}]) :right-side [(when (and (ff/enabled? ::ff/wallet.wallet-connect) - (not watch-only?)) + (not watch-only?) + show-dapps-button?) {:icon-name :i/dapps :on-press #(rf/dispatch [:navigate-to :screen/wallet.connected-dapps])}) (when-not sending-collectible? {:content-type :account-switcher :customization-color color - :on-press #(on-dapps-press switcher-type params) + :on-press #(on-switcher-press switcher-type params) :emoji emoji :type (when watch-only? :watch-only)})]}])) diff --git a/src/status_im/contexts/wallet/common/token_value/view.cljs b/src/status_im/contexts/wallet/common/token_value/view.cljs index 36330a1656..c9a5bef886 100644 --- a/src/status_im/contexts/wallet/common/token_value/view.cljs +++ b/src/status_im/contexts/wallet/common/token_value/view.cljs @@ -93,7 +93,7 @@ (assoc :token token-data :stack-id :screen/wallet.accounts :has-balance? (-> (get-in token [:values :fiat-unformatted-value]) - (money/greater-than (money/bignumber "0")))) + money/above-zero?)) (not selected-account) (assoc :token-symbol token-symbol :stack-id :wallet-stack))] diff --git a/src/status_im/contexts/wallet/common/utils.cljs b/src/status_im/contexts/wallet/common/utils.cljs index c6055d5445..a51c3e6361 100644 --- a/src/status_im/contexts/wallet/common/utils.cljs +++ b/src/status_im/contexts/wallet/common/utils.cljs @@ -187,8 +187,7 @@ (money/bignumber 0)) amount-fixed-decimals (number/to-fixed number display-decimals)] (if (and (= amount-fixed-decimals "0") - (money/greater-than amount - (money/bignumber 0))) + (money/above-zero? amount)) (number/small-number-threshold display-decimals) (str amount-fixed-decimals)))) @@ -286,7 +285,7 @@ {:token (:symbol token) :token-name (:name token) :state :default - :metrics? true + :metrics? (money/above-zero? balance) :status (cond (pos? change-pct-24hour) :positive (neg? change-pct-24hour) :negative diff --git a/src/status_im/contexts/wallet/common/utils/networks.cljs b/src/status_im/contexts/wallet/common/utils/networks.cljs index a907831df9..6d60bc8d46 100644 --- a/src/status_im/contexts/wallet/common/utils/networks.cljs +++ b/src/status_im/contexts/wallet/common/utils/networks.cljs @@ -61,7 +61,7 @@ "Same as `network-list`, but only returns the networks that have a positive token balance" [{:keys [balances-per-chain] :as token} networks] (as-> balances-per-chain $ - (filter #(-> % second :raw-balance (money/greater-than 0)) $) + (filter #(-> % second :raw-balance money/above-zero?) $) (assoc token :balances-per-chain $) (network-list $ networks))) diff --git a/src/status_im/contexts/wallet/send/utils.cljs b/src/status_im/contexts/wallet/send/utils.cljs index 7ac6c3ec47..062402248f 100644 --- a/src/status_im/contexts/wallet/send/utils.cljs +++ b/src/status_im/contexts/wallet/send/utils.cljs @@ -130,7 +130,7 @@ (or (not only-with-balance?) (and only-with-balance? (money/bignumber? raw-balance) - (money/greater-than raw-balance (money/bignumber "0"))))))) + (money/above-zero? raw-balance)))))) (map first)))) (def ^:private network-priority-score @@ -220,7 +220,7 @@ (fn [network-amount] (or (and receiver? (or (contains? receiver-networks-set (:chain-id network-amount)) - (money/greater-than (:total-amount network-amount) (money/bignumber "0")))) + (money/above-zero? (:total-amount network-amount)))) (not receiver?)))) (vec)) (and receiver? diff --git a/src/status_im/contexts/wallet/sheets/slippage_settings/view.cljs b/src/status_im/contexts/wallet/sheets/slippage_settings/view.cljs index a2767eb416..3cd2121038 100644 --- a/src/status_im/contexts/wallet/sheets/slippage_settings/view.cljs +++ b/src/status_im/contexts/wallet/sheets/slippage_settings/view.cljs @@ -51,8 +51,7 @@ amount-out-minus-slippage (money/sub (money/bignumber amount-out-num) slippage-num) display-decimals (min receive-token-decimals constants/min-token-decimals-to-display) - receive-amount (if (money/greater-than amount-out-minus-slippage - (money/bignumber 0)) + receive-amount (if (money/above-zero? amount-out-minus-slippage) (str (utils/sanitized-token-amount-to-display amount-out-minus-slippage display-decimals)) diff --git a/src/utils/money.cljs b/src/utils/money.cljs index 3a3bee1b50..cb523bedb4 100644 --- a/src/utils/money.cljs +++ b/src/utils/money.cljs @@ -245,6 +245,13 @@ (.times fiat-price-bn) (with-precision 2))))) +(defn above-zero? + [^js balance] + (when balance + (->> 0 + bignumber + (greater-than balance)))) + (defn sufficient-funds? [^js amount ^js balance] (when (and amount balance)