feat(wallet): Hide account switcher in send flow (#20892)
* Fix input amount step skipped while sending a token * Rename events to remove the `wallet` unnecessary suffix * Code style fixes * Fix React warnings: 1. About unique key in `select-address.tabs.view` along with a refactor 2. The deprecated `:keyboard-should-persist-taps` as `true` in `send.select-address.view` * Hide account switcher while sending a collectible * Fix tests
This commit is contained in:
parent
337ec963b7
commit
8f94332d59
|
@ -26,7 +26,8 @@
|
|||
switcher-type :account-options
|
||||
type :no-title}}]
|
||||
(let [{:keys [color emoji watch-only?]} (rf/sub [:wallet/current-viewing-account])
|
||||
networks (rf/sub [:wallet/selected-network-details])]
|
||||
networks (rf/sub [:wallet/selected-network-details])
|
||||
sending-collectible? (rf/sub [:wallet/sending-collectible?])]
|
||||
[quo/page-nav
|
||||
{:type type
|
||||
:icon-name icon-name
|
||||
|
@ -41,8 +42,9 @@
|
|||
(not watch-only?))
|
||||
{:icon-name :i/dapps
|
||||
:on-press #(rf/dispatch [:navigate-to :screen/wallet.connected-dapps])})
|
||||
{:content-type :account-switcher
|
||||
:customization-color color
|
||||
:on-press #(on-dapps-press switcher-type)
|
||||
:emoji emoji
|
||||
:type (when watch-only? :watch-only)}]}]))
|
||||
(when-not sending-collectible?
|
||||
{:content-type :account-switcher
|
||||
:customization-color color
|
||||
:on-press #(on-dapps-press switcher-type)
|
||||
:emoji emoji
|
||||
:type (when watch-only? :watch-only)})]}]))
|
||||
|
|
|
@ -85,8 +85,9 @@
|
|||
(rf/reg-event-fx :wallet/close-account-page
|
||||
(fn [{:keys [db]}]
|
||||
(let [just-completed-transaction? (get-in db [:wallet :ui :send :just-completed-transaction?])]
|
||||
(when-not just-completed-transaction?
|
||||
{:fx [[:dispatch [:wallet/clear-account-tab]]]}))))
|
||||
{:db (update db :wallet dissoc :current-viewing-account-address)
|
||||
:fx [(when-not just-completed-transaction?
|
||||
[:dispatch [:wallet/clear-account-tab]])]})))
|
||||
|
||||
(defn log-rpc-error
|
||||
[_ [{:keys [event params]} error]]
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
:size 32
|
||||
:default-active default-active
|
||||
:data data
|
||||
:on-change #(on-change %)}])
|
||||
:on-change on-change}])
|
||||
|
||||
(defn view
|
||||
[]
|
||||
|
|
|
@ -263,9 +263,12 @@
|
|||
|
||||
(rf/reg-event-fx
|
||||
:wallet/set-collectible-to-send
|
||||
(fn [{db :db} [{:keys [collectible current-screen start-flow?]}]]
|
||||
(fn [{db :db} [{:keys [collectible current-screen start-flow? entry-point]}]]
|
||||
(let [viewing-account? (some? (-> db :wallet :current-viewing-account-address))
|
||||
entry-point (when-not viewing-account? :wallet-stack)
|
||||
entry-point (cond
|
||||
entry-point entry-point
|
||||
viewing-account? :account-collectible-tab
|
||||
:else :wallet-stack)
|
||||
collection-data (:collection-data collectible)
|
||||
collectible-data (:collectible-data collectible)
|
||||
contract-type (:contract-type collectible)
|
||||
|
@ -702,3 +705,27 @@
|
|||
{:current-screen stack-id
|
||||
:start-flow? start-flow?
|
||||
:flow-id flow-id}]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/transaction-confirmation-navigate-back
|
||||
(fn [{db :db} [{:keys []}]]
|
||||
(let [tx-type (-> db :wallet :ui :send :tx-type)
|
||||
keep-tx-data? (#{:account-collectible-tab :wallet-stack}
|
||||
(-> db :wallet :ui :send :entry-point))]
|
||||
{:db (cond-> db
|
||||
(and (= tx-type :tx/collectible-erc-721) (not keep-tx-data?))
|
||||
(update-in [:wallet :ui :send] dissoc :tx-type :amount :route :suggested-routes)
|
||||
|
||||
(= tx-type :tx/collectible-erc-1155)
|
||||
(update-in [:wallet :ui :send] dissoc :route :suggested-routes))
|
||||
:fx [[:dispatch [:navigate-back]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/collectible-amount-navigate-back
|
||||
(fn [{db :db} [{:keys []}]]
|
||||
(let [keep-tx-data? (#{:account-collectible-tab :wallet-stack}
|
||||
(-> db :wallet :ui :send :entry-point))]
|
||||
{:db (cond-> db
|
||||
:always (update-in [:wallet :ui :send] dissoc :amount :route)
|
||||
(not keep-tx-data?) (update-in [:wallet :ui :send] dissoc :tx-type))
|
||||
:fx [[:dispatch [:navigate-back]]]})))
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
:skip-step? (fn [db] (or (token-selected? db) (collectible-selected? db)))}
|
||||
{:screen-id :screen/wallet.send-input-amount
|
||||
:skip-step? (fn [db]
|
||||
(send-utils/tx-type-collectible? (get-in db [:wallet :ui :send :tx-type])))}
|
||||
(-> db :wallet :ui :send :tx-type send-utils/tx-type-collectible?))}
|
||||
{:screen-id :screen/wallet.select-collectible-amount
|
||||
:skip-step? (fn [db]
|
||||
(or (not (collectible-selected? db))
|
||||
|
|
|
@ -98,9 +98,10 @@
|
|||
:related-chain-id 1
|
||||
:layer 1}]
|
||||
:wallet/wallet-send-enabled-from-chain-ids [1]
|
||||
:wallet/wallet-send-amount nil
|
||||
:wallet/send-amount nil
|
||||
:wallet/wallet-send-tx-type :tx/send
|
||||
:wallet/wallet-send-fee-fiat-formatted "$5,00"
|
||||
:wallet/sending-collectible? false
|
||||
:wallet/total-amount (money/bignumber "250")})
|
||||
|
||||
(h/describe "Send > input amount screen"
|
||||
|
|
|
@ -9,6 +9,25 @@
|
|||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn other-account-item
|
||||
[{:keys [address color emoji network-preferences-names]
|
||||
account-name :name
|
||||
:as account}]
|
||||
(let [full-address (rf/sub [:wallet/account-address address network-preferences-names])]
|
||||
[quo/account-item
|
||||
{:account-props (assoc account
|
||||
:customization-color color
|
||||
:address full-address
|
||||
:full-address? true)
|
||||
:on-press (fn []
|
||||
(rf/dispatch [:wallet/select-send-address
|
||||
{:address address
|
||||
:recipient {:recipient-type :account
|
||||
:label account-name
|
||||
:customization-color color
|
||||
:emoji emoji}
|
||||
:stack-id :screen/wallet.select-address}]))}]))
|
||||
|
||||
(defn- my-accounts
|
||||
[theme]
|
||||
(let [other-accounts (rf/sub [:wallet/accounts-without-current-viewing-account])]
|
||||
|
@ -20,22 +39,8 @@
|
|||
:container-style style/empty-container-style}]
|
||||
[rn/view {:style style/my-accounts-container}
|
||||
(doall
|
||||
(for [{:keys [color address] :as account} other-accounts]
|
||||
^{:key (str address)}
|
||||
(let [transformed-address (rf/sub [:wallet/account-address address
|
||||
(:network-preferences-names account)])]
|
||||
[quo/account-item
|
||||
{:account-props (assoc account
|
||||
:customization-color color
|
||||
:address transformed-address
|
||||
:full-address? true)
|
||||
:on-press #(rf/dispatch [:wallet/select-send-address
|
||||
{:address address
|
||||
:recipient {:recipient-type :account
|
||||
:label (:name account)
|
||||
:customization-color (:color account)
|
||||
:emoji (:emoji account)}
|
||||
:stack-id :screen/wallet.select-address}])}])))])))
|
||||
(for [{:keys [address] :as account} other-accounts]
|
||||
^{:key (str address)} [other-account-item account]))])))
|
||||
|
||||
(defn- recent-transactions
|
||||
[theme]
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
(let [current-screen-id (rf/sub [:view-id])
|
||||
scanned-address (rf/sub [:wallet/scanned-address])
|
||||
send-address (rf/sub [:wallet/wallet-send-to-address])
|
||||
recipient (rf/sub [:wallet/wallet-send-recipient])
|
||||
recipient (rf/sub [:wallet/send-recipient])
|
||||
recipient-plain-address? (= send-address recipient)
|
||||
valid-ens-or-address? (rf/sub [:wallet/valid-ens-or-address?])
|
||||
contacts (rf/sub [:contacts/active])]
|
||||
|
@ -191,7 +191,7 @@
|
|||
[floating-button-page/view
|
||||
{:content-container-style {:flex 1}
|
||||
:footer-container-padding 0
|
||||
:keyboard-should-persist-taps true
|
||||
:keyboard-should-persist-taps :always
|
||||
:header [account-switcher/view
|
||||
{:on-press #(rf/dispatch [:navigate-back])
|
||||
:margin-top (safe-area/get-top)
|
||||
|
|
|
@ -36,7 +36,8 @@
|
|||
:on-collectible-press (fn [{:keys [collectible]}]
|
||||
(rf/dispatch [:wallet/set-collectible-to-send
|
||||
{:collectible collectible
|
||||
:current-screen :screen/wallet.select-asset}]))}]))
|
||||
:current-screen :screen/wallet.select-asset
|
||||
:entry-point :account-send-button}]))}]))
|
||||
|
||||
(defn- tab-view
|
||||
[search-text selected-tab on-change-text]
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
|
||||
(defn view
|
||||
[]
|
||||
(let [on-close (rn/use-callback #(rf/dispatch [:navigate-back]))
|
||||
(let [on-close (rn/use-callback
|
||||
#(rf/dispatch [:wallet/collectible-amount-navigate-back]))
|
||||
send-transaction-data (rf/sub [:wallet/wallet-send])
|
||||
collectible (:collectible send-transaction-data)
|
||||
balance (utils/collectible-balance collectible)
|
||||
|
@ -23,8 +24,9 @@
|
|||
increase-value (rn/use-callback #(set-value controlled-input/increase))
|
||||
decrease-value (rn/use-callback #(set-value controlled-input/decrease))
|
||||
delete-character (rn/use-callback #(set-value controlled-input/delete-last))
|
||||
add-character (rn/use-callback (fn [c]
|
||||
(set-value #(controlled-input/add-character % c))))]
|
||||
add-character (rn/use-callback
|
||||
(fn [c]
|
||||
(set-value #(controlled-input/add-character % c))))]
|
||||
(rn/use-effect
|
||||
(fn []
|
||||
(set-value #(controlled-input/set-upper-limit % balance)))
|
||||
|
|
|
@ -195,7 +195,7 @@
|
|||
|
||||
(defn view
|
||||
[_]
|
||||
(let [on-close #(rf/dispatch [:navigate-back])]
|
||||
(let [on-close #(rf/dispatch [:wallet/transaction-confirmation-navigate-back])]
|
||||
(fn []
|
||||
(let [theme (quo.theme/use-theme)
|
||||
send-transaction-data (rf/sub [:wallet/wallet-send])
|
||||
|
|
|
@ -43,8 +43,7 @@
|
|||
|
||||
(rf/reg-event-fx :wallet.swap/set-default-slippage
|
||||
(fn [{:keys [db]}]
|
||||
{:db
|
||||
(assoc-in db [:wallet :ui :swap :max-slippage] constants/default-slippage)}))
|
||||
{:db (assoc-in db [:wallet :ui :swap :max-slippage] constants/default-slippage)}))
|
||||
|
||||
(rf/reg-event-fx :wallet.swap/set-max-slippage
|
||||
(fn [{:keys [db]} [max-slippage]]
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
(:require
|
||||
[re-frame.core :as rf]
|
||||
[status-im.contexts.wallet.common.activity-tab.constants :as constants]
|
||||
[status-im.contexts.wallet.send.utils :as send-utils]
|
||||
[utils.number]))
|
||||
|
||||
(rf/reg-sub
|
||||
|
@ -16,7 +17,7 @@
|
|||
:-> :send)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/wallet-send-recipient
|
||||
:wallet/send-recipient
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :recipient)
|
||||
|
||||
|
@ -31,10 +32,20 @@
|
|||
:-> :just-completed-transaction?)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/wallet-send-amount
|
||||
:wallet/send-amount
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :amount)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/send-tx-type
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :tx-type)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/sending-collectible?
|
||||
:<- [:wallet/send-tx-type]
|
||||
#(send-utils/tx-type-collectible? %))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/send-transaction-progress
|
||||
:<- [:wallet/send-transaction-ids]
|
||||
|
|
Loading…
Reference in New Issue