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
This commit is contained in:
Lungu Cristian 2024-11-19 12:08:52 +02:00 committed by GitHub
parent 87483b1ef4
commit e59b782b86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 24 additions and 16 deletions

View File

@ -36,6 +36,7 @@
[rn/view {:style {:flex 1}}
[account-switcher/view
{:type :wallet-networks
:show-dapps-button? true
:on-press #(rf/dispatch [:pop-to-root :shell-stack])}]
[quo/account-overview
{:container-style style/account-overview

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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