Skip to content

Commit

Permalink
chore(wallet): show activity tab after sending a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Son89 committed May 10, 2024
1 parent 03388f6 commit 7904672
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 58 deletions.
104 changes: 52 additions & 52 deletions src/status_im/contexts/wallet/account/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:require
[quo.core :as quo]
[react-native.core :as rn]
[reagent.core :as reagent]
[status-im.contexts.wallet.account.style :as style]
[status-im.contexts.wallet.account.tabs.view :as tabs]
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
Expand All @@ -23,54 +22,55 @@

(defn view
[]
(let [selected-tab (reagent/atom first-tab-id)]
(fn []
(let [{:keys [name color formatted-balance
watch-only?]} (rf/sub [:wallet/current-viewing-account])
customization-color (rf/sub [:profile/customization-color])]
[rn/view {:style {:flex 1}}
[account-switcher/view
{:type :wallet-networks
:on-press #(rf/dispatch [:wallet/close-account-page])}]
[quo/account-overview
{:current-value formatted-balance
:account-name name
:account (if watch-only? :watched-address :default)
:customization-color color}]
[quo/wallet-graph {:time-frame :empty}]
(when (not watch-only?)
[quo/wallet-ctas
{:container-style style/cta-buttons
:send-action (fn []
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:wallet/wizard-navigate-forward
{:start-flow? true
:flow-id :wallet-send-flow}]))
:receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address
{:status :receive}])
:buy-action #(rf/dispatch [:show-bottom-sheet
{:content buy-token/view}])
:bridge-action (fn []
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:wallet/wizard-navigate-forward
{:start-flow? true
:flow-id :wallet-bridge-flow}]))
:swap-action (when (ff/enabled? ::ff/wallet.swap)
#(rf/dispatch [:wallet/start-swap]))}])
[quo/tabs
{:style style/tabs
:size 32
:default-active @selected-tab
:data (tabs-data watch-only?)
:on-change (rn/use-callback (fn [tab]
(reset! selected-tab tab)))
:scrollable? true
:scroll-on-press? true}]
[tabs/view {:selected-tab @selected-tab}]
[quo/floating-shell-button
{:jump-to
{:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
{:position :absolute
:bottom 0}]]))))
(let [selected-tab (or (rf/sub [:wallet/account-tab]) first-tab-id)
{:keys [name color formatted-balance
watch-only?]} (rf/sub [:wallet/current-viewing-account])
customization-color (rf/sub [:profile/customization-color])]
[rn/view {:style {:flex 1}}
[account-switcher/view
{:type :wallet-networks
:on-press (fn []
(rf/dispatch [:wallet/close-account-page])
(rf/dispatch [:wallet/select-account-tab first-tab-id]))}]
[quo/account-overview
{:current-value formatted-balance
:account-name name
:account (if watch-only? :watched-address :default)
:customization-color color}]
[quo/wallet-graph {:time-frame :empty}]
(when (not watch-only?)
[quo/wallet-ctas
{:container-style style/cta-buttons
:send-action (fn []
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:wallet/wizard-navigate-forward
{:start-flow? true
:flow-id :wallet-send-flow}]))
:receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address
{:status :receive}])
:buy-action #(rf/dispatch [:show-bottom-sheet
{:content buy-token/view}])
:bridge-action (fn []
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:wallet/wizard-navigate-forward
{:start-flow? true
:flow-id :wallet-bridge-flow}]))
:swap-action (when (ff/enabled? ::ff/wallet.swap)
#(rf/dispatch [:wallet/start-swap]))}])
[quo/tabs
{:style style/tabs
:size 32
:default-active selected-tab
:data (tabs-data watch-only?)
:on-change #(rf/dispatch [:wallet/select-account-tab %])

:scrollable? true
:scroll-on-press? true}]
[tabs/view {:selected-tab selected-tab}]
[quo/floating-shell-button
{:jump-to
{:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
{:position :absolute
:bottom 0}]]))
4 changes: 4 additions & 0 deletions src/status_im/contexts/wallet/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
[:dispatch [:navigate-to :screen/wallet.accounts address]]
[:dispatch [:wallet/show-account-created-toast address]]]}))

(rf/reg-event-fx :wallet/select-account-tab
(fn [{:keys [db]} [tab]]
{:db (assoc-in db [:wallet :ui :account-page :active-tab] tab)}))

(rf/reg-event-fx :wallet/switch-current-viewing-account
(fn [{:keys [db]} [address]]
{:db (assoc-in db [:wallet :current-viewing-account-address] address)}))
Expand Down
10 changes: 5 additions & 5 deletions src/status_im/contexts/wallet/send/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,18 @@
(assoc-in [:wallet :transactions] transaction-details)
(assoc-in [:wallet :ui :send :transaction-ids] transaction-ids))
:fx [[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen :screen/wallet.transaction-confirmation
:flow-id :wallet-send-flow}]]]})))
[:wallet/end-transaction-flow]]]})))

(rf/reg-event-fx :wallet/close-transaction-progress-page
(rf/reg-event-fx :wallet/end-transaction-flow
(fn [_]
{:fx [[:dispatch [:wallet/clean-scanned-address]]
[:dispatch [:wallet/clean-local-suggestions]]
[:dispatch [:wallet/clean-send-address]]
[:dispatch [:wallet/clean-disabled-from-networks]]
[:dispatch [:wallet/select-address-tab nil]]
[:dispatch [:dismiss-modal :screen/wallet.transaction-progress]]]}))
[:dispatch [:wallet/fetch-activities]]
[:dispatch [:wallet/select-account-tab :activity]]
[:dispatch [:dismiss-modal :screen/wallet.transaction-confirmation]]]}))

(defn- transaction-data
[{:keys [from-address to-address token-address route data eth-transfer?]}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

(defn view
[]
(let [leave-page #(rf/dispatch [:wallet/close-transaction-progress-page])
(let [leave-page #(rf/dispatch [:wallet/end-transaction-flow])
{:keys [color]} (rf/sub [:wallet/current-viewing-account])]
(fn []
(rn/use-effect
Expand Down
6 changes: 6 additions & 0 deletions src/status_im/subs/wallet/wallet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@
(fn [accounts]
(remove :watch-only? accounts)))

(rf/reg-sub
:wallet/account-tab
:<- [:wallet/ui]
(fn [ui]
(get-in ui [:account-page :active-tab])))

(rf/reg-sub
:wallet/current-viewing-account-token-values
:<- [:wallet/current-viewing-account]
Expand Down

0 comments on commit 7904672

Please sign in to comment.