Skip to content

Commit 8ff7367

Browse files
authored
Merge branch 'develop' into share-community-qr-17993
2 parents ed38451 + f762cdc commit 8ff7367

File tree

12 files changed

+124
-51
lines changed

12 files changed

+124
-51
lines changed

src/quo/components/navigation/page_nav/view.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@
311311
- title
312312
- description
313313
- picture: a valid rn/image `:source` value
314-
`:wallet-network`
314+
`:wallet-networks`
315315
- networks: a vector of network image source
316316
- networks-on-press: a callback
317317
`:community`

src/quo/components/settings/category/style.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
:padding-bottom 8})
1212

1313
(defn settings-items
14-
[{:keys [blur? theme]}]
15-
{:margin-top 12
14+
[{:keys [label blur? theme]}]
15+
{:margin-top (if label 12 4)
1616
:border-radius 16
1717
:background-color (if blur?
1818
colors/white-opa-5

src/status_im/constants.cljs

+2
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,8 @@
432432
(def ^:const optimism-network-name :optimism)
433433
(def ^:const arbitrum-network-name :arbitrum)
434434

435+
(def ^:const default-network-names #{mainnet-network-name optimism-network-name arbitrum-network-name})
436+
435437
(def ^:const chain-id-separator ":")
436438

437439
(def ^:const account-default-customization-color :blue)

src/status_im/contexts/wallet/account/view.cljs

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
(let [{:keys [name color formatted-balance
3939
watch-only?]} (rf/sub [:wallet/current-viewing-account])]
4040
[rn/view {:style {:flex 1}}
41-
[account-switcher/view {:on-press #(rf/dispatch [:wallet/close-account-page])}]
41+
[account-switcher/view
42+
{:type :wallet-networks
43+
:on-press #(rf/dispatch [:wallet/close-account-page])}]
4244
[quo/account-overview
4345
{:current-value formatted-balance
4446
:account-name name

src/status_im/contexts/wallet/common/account_switcher/view.cljs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
(ns status-im.contexts.wallet.common.account-switcher.view
22
(:require [quo.core :as quo]
33
[status-im.contexts.wallet.common.sheets.account-options.view :as account-options]
4+
[status-im.contexts.wallet.common.sheets.network-filter.view :as network-filter]
45
[status-im.contexts.wallet.common.sheets.select-account.view :as select-account]
6+
[status-im.feature-flags :as ff]
57
[utils.re-frame :as rf]))
68

79
(defn get-bottom-sheet-args
@@ -13,20 +15,24 @@
1315
nil))
1416

1517
(defn view
16-
[{:keys [on-press accessibility-label icon-name switcher-type margin-top]
18+
[{:keys [type on-press accessibility-label icon-name switcher-type margin-top]
1719
:or {icon-name :i/close
1820
accessibility-label :top-bar
1921
switcher-type :account-options}}]
2022
(let [{:keys [color emoji watch-only?]} (rf/sub [:wallet/current-viewing-account])
2123
networks (rf/sub [:wallet/network-details])]
2224
[quo/page-nav
23-
{:icon-name icon-name
25+
{:type (or type :no-title)
26+
:icon-name icon-name
2427
:margin-top margin-top
2528
:background :blur
2629
:on-press on-press
2730
:accessibility-label accessibility-label
2831
:networks networks
29-
:networks-on-press #(js/alert "Pressed Networks")
32+
:networks-on-press #(ff/alert ::ff/wallet.network-filter
33+
(fn []
34+
(rf/dispatch [:show-bottom-sheet
35+
{:content network-filter/view}])))
3036
:right-side :account-switcher
3137
:account-switcher {:customization-color color
3238
:on-press #(rf/dispatch [:show-bottom-sheet
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
(ns status-im.contexts.wallet.common.sheets.network-filter.view
2+
(:require
3+
[quo.core :as quo]
4+
[reagent.core :as reagent]
5+
[status-im.constants :as constants]
6+
[status-im.contexts.wallet.common.utils :as utils]
7+
[utils.i18n :as i18n]
8+
[utils.re-frame :as rf]))
9+
10+
(defn view
11+
[]
12+
(let [state (reagent/atom :default)
13+
networks-selected (reagent/atom #{})
14+
toggle-network (fn [network-name]
15+
(reset! state :changed)
16+
(if (contains? @networks-selected
17+
network-name)
18+
(swap! networks-selected disj
19+
network-name)
20+
(swap! networks-selected conj
21+
network-name)))
22+
get-networks (fn []
23+
(if (= @state :default)
24+
constants/default-network-names
25+
@networks-selected))]
26+
(fn []
27+
(let [color (rf/sub [:profile/customization-color])
28+
network-details (rf/sub [:wallet/network-details])
29+
mainnet (first network-details)
30+
layer-2-networks (rest network-details)]
31+
[:<>
32+
[quo/drawer-top {:title (i18n/label :t/select-networks)}]
33+
[quo/category
34+
{:list-type :settings
35+
:data [(utils/make-network-item mainnet
36+
{:state @state
37+
:title (i18n/label :t/mainnet)
38+
:color color
39+
:networks (get-networks)
40+
:on-change #(toggle-network (:network-name
41+
mainnet))
42+
:label-props "$0.00"})]}]
43+
[quo/category
44+
{:list-type :settings
45+
:label (i18n/label :t/layer-2)
46+
:data (mapv (fn [network]
47+
(utils/make-network-item network
48+
{:state @state
49+
:color color
50+
:networks (get-networks)
51+
:on-change #(toggle-network (:network-name
52+
network))
53+
:label-props "$0.00"}))
54+
layer-2-networks)}]]))))

src/status_im/contexts/wallet/common/sheets/network_preferences/view.cljs

+17-35
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,14 @@
11
(ns status-im.contexts.wallet.common.sheets.network-preferences.view
2-
(:require [clojure.string :as string]
3-
[quo.core :as quo]
2+
(:require [quo.core :as quo]
43
[quo.foundations.colors :as colors]
5-
[quo.foundations.resources :as resources]
64
[quo.theme :as quo.theme]
75
[react-native.blur :as blur]
86
[reagent.core :as reagent]
97
[status-im.contexts.wallet.common.sheets.network-preferences.style :as style]
8+
[status-im.contexts.wallet.common.utils :as utils]
109
[utils.i18n :as i18n]
1110
[utils.re-frame :as rf]))
1211

13-
14-
(defn- make-network-item
15-
[{:keys [network-name] :as _network}
16-
{:keys [title color on-change network-preferences state blur?] :as _options}]
17-
{:title (or title (string/capitalize (name network-name)))
18-
:blur? blur?
19-
:image :icon-avatar
20-
:image-props {:icon (resources/get-network network-name)
21-
:size :size-20}
22-
:action :selector
23-
:action-props {:type (if (= :default state)
24-
:filled-checkbox
25-
:checkbox)
26-
:customization-color color
27-
:checked? (contains? network-preferences network-name)
28-
:on-change on-change}})
29-
3012
(defn- view-internal
3113
[{:keys [selected-networks watch-only?]}]
3214
(let [state (reagent/atom :default)
@@ -88,26 +70,26 @@
8870
[quo/category
8971
{:list-type :settings
9072
:blur? blur?
91-
:data [(make-network-item mainnet
92-
{:state @state
93-
:title (i18n/label :t/mainnet)
94-
:color color
95-
:blur? blur?
96-
:network-preferences (get-current-preferences-names)
97-
:on-change #(toggle-network (:network-name
98-
mainnet))})]}]
73+
:data [(utils/make-network-item mainnet
74+
{:state @state
75+
:title (i18n/label :t/mainnet)
76+
:color color
77+
:blur? blur?
78+
:networks (get-current-preferences-names)
79+
:on-change #(toggle-network (:network-name
80+
mainnet))})]}]
9981
[quo/category
10082
{:list-type :settings
10183
:blur? blur?
10284
:label (i18n/label :t/layer-2)
10385
:data (mapv (fn [network]
104-
(make-network-item network
105-
{:state @state
106-
:color color
107-
:blur? blur?
108-
:network-preferences (get-current-preferences-names)
109-
:on-change #(toggle-network (:network-name
110-
network))}))
86+
(utils/make-network-item network
87+
{:state @state
88+
:color color
89+
:blur? blur?
90+
:networks (get-current-preferences-names)
91+
:on-change #(toggle-network (:network-name
92+
network))}))
11193
layer-2-networks)}]
11294
[quo/bottom-actions
11395
{:actions :one-action

src/status_im/contexts/wallet/common/utils.cljs

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(ns status-im.contexts.wallet.common.utils
22
(:require [clojure.string :as string]
3+
[quo.foundations.resources :as resources]
34
[status-im.common.qr-codes.view :as qr-codes]
45
[status-im.constants :as constants]
56
[utils.money :as money]
@@ -274,3 +275,23 @@
274275
(defn get-balance-for-chain
275276
[data chain-id]
276277
(some #(when (= chain-id (:chain-id %)) %) (vals data)))
278+
279+
(defn make-network-item
280+
"This function generates props for quo/category component item"
281+
[{:keys [network-name] :as _network}
282+
{:keys [title color on-change networks state label-props] :as _options}]
283+
(cond-> {:title (or title (string/capitalize (name network-name)))
284+
:image :icon-avatar
285+
:image-props {:icon (resources/get-network network-name)
286+
:size :size-20}
287+
:action :selector
288+
:action-props {:type (if (= :default state)
289+
:filled-checkbox
290+
:checkbox)
291+
:customization-color color
292+
:checked? (contains? networks network-name)
293+
:on-change on-change}}
294+
295+
label-props
296+
(assoc :label :text
297+
:label-props label-props)))

src/status_im/contexts/wallet/events.cljs

-2
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,6 @@
280280
[])
281281
:wallet/valid-ens-or-address? (boolean result))}))
282282

283-
284-
285283
(rf/reg-event-fx :wallet/fetch-address-suggestions
286284
(fn [{:keys [db]} [_address]]
287285
{:db (assoc db

src/status_im/contexts/wallet/home/view.cljs

+11-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
[react-native.core :as rn]
55
[reagent.core :as reagent]
66
[status-im.common.home.top-nav.view :as common.top-nav]
7+
[status-im.contexts.wallet.common.sheets.network-filter.view :as network-filter]
78
[status-im.contexts.wallet.home.style :as style]
89
[status-im.contexts.wallet.home.tabs.view :as tabs]
10+
[status-im.feature-flags :as ff]
911
[utils.i18n :as i18n]
1012
[utils.re-frame :as rf]))
1113

@@ -48,11 +50,15 @@
4850
[common.top-nav/view]
4951
[rn/view {:style style/overview-container}
5052
[quo/wallet-overview
51-
{:state (if tokens-loading? :loading :default)
52-
:time-frame :none
53-
:metrics :none
54-
:balance formatted-balance
55-
:networks networks}]]
53+
{:state (if tokens-loading? :loading :default)
54+
:time-frame :none
55+
:metrics :none
56+
:balance formatted-balance
57+
:networks networks
58+
:dropdown-on-press #(ff/alert ::ff/wallet.network-filter
59+
(fn []
60+
(rf/dispatch [:show-bottom-sheet
61+
{:content network-filter/view}])))}]]
5662
[quo/wallet-graph {:time-frame :empty}]
5763
[rn/flat-list
5864
{:style style/accounts-list

src/status_im/feature_flags.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
(reagent/atom
1313
{::wallet.edit-default-keypair (enabled-in-env? :FLAG_EDIT_DEFAULT_KEYPAIR_ENABLED)
1414
::wallet.bridge-token (enabled-in-env? :FLAG_BRIDGE_TOKEN_ENABLED)
15-
::wallet.remove-account (enabled-in-env? :FLAG_REMOVE_ACCOUNT_ENABLED)}))
15+
::wallet.remove-account (enabled-in-env? :FLAG_REMOVE_ACCOUNT_ENABLED)
16+
::wallet.network-filter (enabled-in-env? :FLAG_NETWORK_FILTER_ENABLED)}))
1617

1718
(defn feature-flags [] @feature-flags-config)
1819

translations/en.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2505,5 +2505,6 @@
25052505
"origin-header": "Origin",
25062506
"origin-desc": "Origin is where your key pair (your private and public key) comes from. You can generate a new key pair or import an existing private key.",
25072507
"derivation-path-header": "Derivation path",
2508-
"derivation-path-desc": "Derivation paths are the routes your Status Wallet uses to generate addresses from your private key."
2508+
"derivation-path-desc": "Derivation paths are the routes your Status Wallet uses to generate addresses from your private key.",
2509+
"select-networks": "Select networks"
25092510
}

0 commit comments

Comments
 (0)