Skip to content

Commit

Permalink
chore(wallet): add common page-nav component for account switcher (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Son89 authored Nov 27, 2023
1 parent 1385e27 commit f124ca4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 38 deletions.
16 changes: 4 additions & 12 deletions src/status_im2/contexts/wallet/account/bridge/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[quo.foundations.resources :as quo.resources]
[react-native.core :as rn]
[status-im2.contexts.wallet.account.bridge.style :as style]
[status-im2.contexts.wallet.common.sheets.account-options.view :as account-options]
[status-im2.contexts.wallet.common.account-switcher.view :as account-switcher]
[status-im2.contexts.wallet.common.temp :as temp]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
Expand All @@ -18,17 +18,9 @@
(let [networks (rf/sub [:wallet/network-details])
networks-logos (map network-logo networks)]
[rn/view {:style {:flex 1}}
[quo/page-nav
{:icon-name :i/close
:on-press #(rf/dispatch [:navigate-back])
:accessibility-label :top-bar
:right-side :account-switcher
:account-switcher {:customization-color :purple
:on-press #(rf/dispatch [:show-bottom-sheet
{:content account-options/view
:gradient-cover? true
:customization-color :purple}])
:emoji "🍑"}}]
[account-switcher/view
{:on-press #(rf/dispatch [:navigate-back])
:accessibility-label :top-bar}]
[quo/text-combinations
{:container-style style/header-container
:title (i18n/label :t/bridge)}]
Expand Down
21 changes: 4 additions & 17 deletions src/status_im2/contexts/wallet/account/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[reagent.core :as reagent]
[status-im2.contexts.wallet.account.style :as style]
[status-im2.contexts.wallet.account.tabs.view :as tabs]
[status-im2.contexts.wallet.common.sheets.account-options.view :as account-options]
[status-im2.contexts.wallet.common.account-switcher.view :as account-switcher]
[status-im2.contexts.wallet.common.temp :as temp]
[status-im2.contexts.wallet.common.utils :as utils]
[utils.i18n :as i18n]
Expand All @@ -32,23 +32,10 @@
[]
(let [selected-tab (reagent/atom (:id (first tabs-data)))]
(fn []
(let [{:keys [name color emoji balance]} (rf/sub [:wallet/current-viewing-account])
networks (rf/sub [:wallet/network-details])]
(let [{:keys [name color balance]} (rf/sub [:wallet/current-viewing-account])
]
[rn/view {:style {:flex 1}}
[quo/page-nav
{:type :wallet-networks
:background :blur
:icon-name :i/close
:on-press #(rf/dispatch [:wallet/close-account-page])
:networks networks
:networks-on-press #(js/alert "Pressed Networks")
:right-side :account-switcher
:account-switcher {:customization-color color
:on-press #(rf/dispatch [:show-bottom-sheet
{:content account-options/view
:gradient-cover? true
:customization-color color}])
:emoji emoji}}]
[account-switcher/view {:on-press #(rf/dispatch [:wallet/close-account-page])}]
[quo/account-overview
{:current-value (utils/prettify-balance balance)
:account-name name
Expand Down
22 changes: 22 additions & 0 deletions src/status_im2/contexts/wallet/common/account_switcher/view.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(ns status-im2.contexts.wallet.common.account-switcher.view
(:require [quo.core :as quo]
[status-im2.contexts.wallet.common.sheets.account-options.view :as account-options]
[utils.re-frame :as rf]))

(defn view
[{:keys [on-press accessibility-label] :or {accessibility-label :top-bar}}]
(let [{:keys [color emoji]} (rf/sub [:wallet/current-viewing-account])
networks (rf/sub [:wallet/network-details])]
[quo/page-nav
{:icon-name :i/close
:on-press on-press
:accessibility-label accessibility-label
:networks networks
:networks-on-press #(js/alert "Pressed Networks")
:right-side :account-switcher
:account-switcher {:customization-color color
:on-press #(rf/dispatch [:show-bottom-sheet
{:content account-options/view
:gradient-cover? true
:customization-color color}])
:emoji emoji}}]))
11 changes: 2 additions & 9 deletions src/status_im2/contexts/wallet/send/select_address/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[react-native.safe-area :as safe-area]
[reagent.core :as reagent]
[status-im2.constants :as constants]
[status-im2.contexts.wallet.common.account-switcher.view :as account-switcher]
[status-im2.contexts.wallet.item-types :as types]
[status-im2.contexts.wallet.send.select-address.style :as style]
[utils.debounce :as debounce]
Expand Down Expand Up @@ -146,15 +147,7 @@
{:content-container-style (style/container margin-top)
:keyboard-should-persist-taps :handled
:scroll-enabled false}
[quo/page-nav
{:icon-name :i/close
:on-press on-close
:accessibility-label :top-bar
:right-side :account-switcher
:account-switcher {:customization-color :purple
:on-press #(js/alert "Not implemented yet")
:state :default
:emoji "🍑"}}]
[account-switcher/view {:on-press on-close}]
[quo/text-combinations
{:title (i18n/label :t/send-to)
:container-style style/title-container
Expand Down

0 comments on commit f124ca4

Please sign in to comment.