Skip to content

Commit 96845b4

Browse files
committed
Update send summary to show network in a separate card (#21616)
1 parent 8b21d6a commit 96845b4

File tree

8 files changed

+77
-61
lines changed

8 files changed

+77
-61
lines changed

src/quo/components/wallet/summary_info/component_spec.cljs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
(h/test "Type of `status-account` title renders"
1616
(h/render-with-theme-provider [summary-info/view
1717
{:type :status-account
18-
:networks? true
18+
:show-networks? true
1919
:values {:ethereum 150
2020
:optimism 50
2121
:arbitrum 25}
@@ -25,7 +25,7 @@
2525
(h/test "Type of `user` title renders"
2626
(h/render-with-theme-provider [summary-info/view
2727
{:type :user
28-
:networks? true
28+
:show-networks? true
2929
:values {:ethereum 150
3030
:optimism 50
3131
:arbitrum 25}
@@ -43,7 +43,7 @@
4343
(h/test "Networks true render"
4444
(h/render-with-theme-provider [summary-info/view
4545
{:type :status-account
46-
:networks? true
46+
:show-networks? true
4747
:values {:ethereum 150
4848
:optimism 50
4949
:arbitrum 25}
@@ -53,7 +53,7 @@
5353
(h/test "Networks false render"
5454
(h/render-with-theme-provider [summary-info/view
5555
{:type :status-account
56-
:networks? false
56+
:show-networks? false
5757
:values {:ethereum 150
5858
:optimism 50
5959
:arbitrum 25}

src/quo/components/wallet/summary_info/style.cljs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
[quo.foundations.colors :as colors]))
44

55
(defn container
6-
[networks? theme]
6+
[networks-to-show theme]
77
{:width "100%"
8-
:height (if networks? 90 56)
8+
:height (if networks-to-show 90 56)
99
:border-radius 16
1010
:border-width 1
1111
:border-color (colors/theme-colors colors/neutral-10 colors/neutral-80 theme)
12-
:margin-bottom (if networks? 4 8)})
12+
:margin-bottom (if networks-to-show 4 8)})
1313

1414
(def info-container
1515
{:flex-direction :row

src/quo/components/wallet/summary_info/view.cljs

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,50 +28,40 @@
2828
[rn/view
2929
{:style (style/dot-divider theme)}])])
3030

31+
(def default-token-symbols
32+
{:ethereum "ETH"
33+
:optimism "OETH"
34+
:arbitrum "ARB"
35+
:base "ETH"})
36+
37+
(defn prnt [data]
38+
(js/console.log "DATA: " (clj->js data))
39+
data)
40+
3141
(defn networks
32-
[values theme]
33-
(let [{:keys [ethereum optimism arbitrum base]} values
34-
show-optimism? (and optimism
35-
(or (pos? (:amount optimism))
36-
(= (:amount optimism) "<0.01")))
37-
show-arbitrum? (and arbitrum
38-
(or (pos? (:amount arbitrum))
39-
(= (:amount arbitrum) "<0.01")))
40-
show-base? (and base
41-
(or (pos? (:amount base))
42-
(= (:amount base) "<0.01")))]
43-
[rn/view
44-
{:style style/networks-container
45-
:accessibility-label :networks}
46-
(when (and ethereum (pos? (:amount ethereum)))
47-
[network-amount
48-
{:network :ethereum
49-
:amount (str (:amount ethereum) " " (or (:token-symbol ethereum) "ETH"))
50-
:divider? (or show-arbitrum? show-optimism?)
51-
:theme theme}])
52-
(when show-optimism?
53-
[network-amount
54-
{:network :optimism
55-
:amount (str (:amount optimism) " " (or (:token-symbol optimism) "OETH"))
56-
:divider? show-arbitrum?
57-
:theme theme}])
58-
(when show-arbitrum?
59-
[network-amount
60-
{:network :arbitrum
61-
:amount (str (:amount arbitrum) " " (or (:token-symbol arbitrum) "ARB"))
62-
:theme theme}])
63-
(when show-base?
64-
[network-amount
65-
{:network :base
66-
:amount (str (:amount base) " " (or (:token-symbol base) "ETH"))
67-
:theme theme}])]))
42+
[networks-to-show theme]
43+
(->> networks-to-show
44+
(map-indexed
45+
(fn [i [k {:keys [amount token-symbol]}]]
46+
(when (or (pos? amount)
47+
(= amount "<0.01"))
48+
[network-amount
49+
{:network k
50+
:amount (str amount " " (or token-symbol (get default-token-symbols k)))
51+
:divider? (not= (dec i) (-> networks-to-show keys count))
52+
:theme theme}])))
53+
(remove nil?)
54+
(prnt)
55+
(into [rn/view
56+
{:style style/networks-container
57+
:accessibility-label :networks}])))
6858

6959
(defn- view-internal
70-
[{:keys [type account-props token-props networks? values]}]
60+
[{:keys [type account-props token-props networks-to-show]}]
7161
(let [theme (quo.theme/use-theme)
7262
address (or (:address account-props) (:address token-props))]
7363
[rn/view
74-
{:style (style/container networks? theme)}
64+
{:style (style/container networks-to-show theme)}
7565
[rn/view
7666
{:style style/info-container}
7767
(case type
@@ -105,10 +95,10 @@
10595
:style {:color (when (not= type :account)
10696
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))}}
10797
address])]]]
108-
(when networks?
98+
(when networks-to-show
10999
[:<>
110100
[rn/view
111101
{:style (style/line-divider theme)}]
112-
[networks values theme]])]))
102+
[networks networks-to-show theme]])]))
113103

114104
(def view (schema/instrument #'view-internal summary-info-schema/?schema))

src/status_im/contexts/preview/quo/wallet/summary_info.cljs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212
:options [{:key :status-account}
1313
{:key :user}
1414
{:key :saved-account}
15-
{:key :account}]}
16-
{:key :networks? :type :boolean}])
15+
{:key :account}]}])
1716

1817

1918
(defn view
2019
[]
2120
(let [state (reagent/atom {:type :status-account
22-
:networks? true
23-
:values {:ethereum {:amount 150}
21+
:networks-to-show {:ethereum {:amount 150}
2422
:optimism {:amount 50}
2523
:arbitrum {:amount 25}}})
2624
status-account-props {:customization-color :purple

src/status_im/contexts/wallet/send/transaction_confirmation/style.cljs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@
2828
[theme]
2929
{:margin-bottom 8
3030
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)})
31+
32+
(def summary-container
33+
{:padding-horizontal 20
34+
:padding-bottom 16})

src/status_im/contexts/wallet/send/transaction_confirmation/view.cljs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,11 @@
129129

130130
(defn- user-summary
131131
[{:keys [account-props theme label accessibility-label summary-type recipient bridge-tx? account-to?]}]
132-
(let [network-values (rf/sub [:wallet/network-values account-to?])
133-
summary-info-type (case (:recipient-type recipient)
132+
(let [summary-info-type (case (:recipient-type recipient)
134133
:saved-address :saved-account
135134
:account :status-account
136135
summary-type)]
137-
[rn/view
138-
{:style {:padding-horizontal 20
139-
:padding-bottom 16}}
136+
[rn/view {:style style/summary-container}
140137
[quo/text
141138
{:size :paragraph-2
142139
:weight :medium
@@ -145,8 +142,6 @@
145142
label]
146143
[quo/summary-info
147144
{:type summary-info-type
148-
:networks? true
149-
:values (send-utils/network-values-for-ui network-values)
150145
:account-props (cond-> account-props
151146
(and account-to? (not bridge-tx?))
152147
(assoc
@@ -156,6 +151,21 @@
156151
:emoji (:emoji recipient)
157152
:customization-color (:customization-color recipient)))}]]))
158153

154+
(defn- network-summary
155+
[{:keys [theme label accessibility-label]}]
156+
(let [network (rf/sub [:wallet/send-selected-network])]
157+
(when network
158+
[rn/view {:style style/summary-container}
159+
[quo/text
160+
{:size :paragraph-2
161+
:weight :medium
162+
:style (style/section-label theme)
163+
:accessibility-label accessibility-label}
164+
label]
165+
[quo/summary-info
166+
{:type :network
167+
:network :ethereum}]])))
168+
159169
(defn- data-item
160170
[{:keys [title subtitle]}]
161171
[quo/data-item
@@ -336,4 +346,7 @@
336346
:recipient recipient
337347
:bridge-tx? (= transaction-type :tx/bridge)
338348
:account-to? true
349+
:theme theme}]
350+
[network-summary
351+
{:label (i18n/label :t/on)
339352
:theme theme}]]]]))

src/status_im/contexts/wallet/swap/swap_confirmation/view.cljs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,12 @@
7676
label]
7777
[quo/summary-info
7878
{:type :token
79-
:networks? true
80-
:values (send-utils/network-values-for-ui network-values)
8179
:token-props {:token token-symbol
8280
:label (str amount " " token-symbol)
8381
:address (when token-address
8482
(address-utils/get-shortened-compressed-key token-address))
85-
:size 32}}]]))
83+
:size 32}
84+
:networks-to-show (send-utils/network-values-for-ui network-values)}]]))
8685

8786
(defn- pay-section
8887
[]

src/status_im/subs/wallet/networks.cljs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,15 @@
7171
{:amount amount-fixed :token-symbol token-symbol})))
7272
{}
7373
network-values))))
74+
75+
(re-frame/reg-sub
76+
:wallet/send-selected-network
77+
:<- [:wallet/wallet-send]
78+
(fn [{:keys [to-values-by-chain]}]
79+
(let [network-name (-> to-values-by-chain
80+
keys
81+
first
82+
network-utils/id->network)]
83+
(if (= network-name :mainnet)
84+
:ethereum
85+
network-name))))

0 commit comments

Comments
 (0)