Skip to content

Commit b0d2e6e

Browse files
authored
Bottom sheet with save and send options not displayed after scanning wallet QR using universal scanner #18928 (#19250)
1 parent df0e931 commit b0d2e6e

File tree

22 files changed

+200
-95
lines changed

22 files changed

+200
-95
lines changed

src/quo/components/drawers/drawer_top/component_spec.cljs

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
(h/is-truthy (h/get-by-text "Title"))
2323
(h/is-truthy (h/get-by-text "Description")))
2424

25+
(h/test "component renders in address type"
26+
(h/render-with-theme-provider [quo/drawer-top
27+
{:title "0x1"
28+
:type :address}]
29+
theme)
30+
(h/is-truthy (h/get-by-text "0x1")))
31+
2532
(h/test "component renders in info type"
2633
(h/render-with-theme-provider [quo/drawer-top
2734
{:title "Title"

src/quo/components/drawers/drawer_top/view.cljs

+10-5
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,16 @@
168168
(defn- left-title
169169
[{:keys [type label title title-icon theme blur?]}]
170170
(case type
171-
:label [text/text
172-
{:weight :medium
173-
:size :paragraph-2
174-
:style (style/description theme blur?)}
175-
label]
171+
:label [text/text
172+
{:weight :medium
173+
:size :paragraph-2
174+
:style (style/description theme blur?)}
175+
label]
176+
:address [address-text/view
177+
{:address title
178+
:full-address? true
179+
:weight :semi-bold
180+
:size :heading-2}]
176181
[rn/view {:style style/title-container}
177182
[text/text
178183
{:size :heading-2

src/quo/components/list_items/token_network/schema.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[:=>
55
[:cat
66
[:map
7-
[:token :keyword]
7+
[:token [:or :string :keyword]]
88
[:label :string]
99
[:token-value :string]
1010
[:fiat-value :string]

src/quo/components/share/share_qr_code/style.cljs

-42
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
:padding-top 12
1717
:padding-bottom 8})
1818

19-
(def gradient-bg
20-
{:position :absolute
21-
:top 0
22-
:left 0
23-
:right 0})
24-
2519
;;; Header
2620
(def header-container
2721
{:flex-direction :row
@@ -71,41 +65,5 @@
7165
:justify-content :space-between
7266
:flex 1})
7367

74-
;;; Dashed line
75-
(def ^:private padding-for-divider (+ padding-horizontal 4))
76-
(def ^:private dashed-line-width 2)
77-
(def ^:private dashed-line-space 4)
78-
79-
(def dashed-line
80-
{:flex-direction :row
81-
:margin-left -1})
82-
83-
(def line
84-
{:background-color colors/white-opa-20
85-
:width dashed-line-width
86-
:height 1})
87-
88-
(def line-space
89-
{:width dashed-line-space
90-
:height 1})
91-
92-
(defn number-lines-and-spaces-to-fill
93-
[component-width]
94-
(let [line-and-space-width (+ dashed-line-width dashed-line-space)
95-
width-to-fill (- component-width (* 2 padding-for-divider))
96-
number-of-lines (* (/ width-to-fill line-and-space-width) 2)]
97-
(inc (int number-of-lines))))
98-
99-
(def ^:private get-network-full-name
100-
{"eth" :ethereum
101-
"opt" :optimism
102-
"arb1" :arbitrum})
103-
104-
(defn network-short-name-text
105-
[network-short-name]
106-
{:color (-> network-short-name
107-
(get-network-full-name :unknown)
108-
(colors/resolve-color nil))})
109-
11068
(def watched-account-icon
11169
{:margin-left 4})

src/quo/components/share/share_qr_code/view.cljs

+6-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns quo.components.share.share-qr-code.view
22
(:require [clojure.set]
3-
[clojure.string :as string]
43
[oops.core :as oops]
54
[quo.components.avatars.account-avatar.view :as account-avatar]
65
[quo.components.avatars.user-avatar.view :as user-avatar]
@@ -13,6 +12,7 @@
1312
[quo.components.share.share-qr-code.schema :as component-schema]
1413
[quo.components.share.share-qr-code.style :as style]
1514
[quo.components.tabs.tab.view :as tab]
15+
[quo.components.wallet.address-text.view :as address-text]
1616
[quo.foundations.colors :as colors]
1717
[quo.theme]
1818
[react-native.core :as rn]
@@ -74,21 +74,6 @@
7474
:on-press on-press}
7575
:i/share]])
7676

77-
(defn- network-colored-text
78-
[network-short-name]
79-
[text/text {:style (style/network-short-name-text network-short-name)}
80-
(str network-short-name ":")])
81-
82-
(defn- wallet-multichain-colored-address
83-
[full-address]
84-
(let [[networks address] (as-> full-address $
85-
(string/split $ ":")
86-
[(butlast $) (last $)])
87-
->network-hiccup-xf (map #(vector network-colored-text %))]
88-
(as-> networks $
89-
(into [:<>] ->network-hiccup-xf $)
90-
(conj $ address))))
91-
9277
(defn- profile-bottom
9378
[{:keys [component-width qr-data on-text-press on-text-long-press share-qr-type]}]
9479
[rn/view
@@ -116,7 +101,11 @@
116101
{:width component-width
117102
:on-press on-text-press
118103
:on-long-press on-text-long-press}
119-
[wallet-multichain-colored-address qr-data]]
104+
[address-text/view
105+
{:address qr-data
106+
:full-address? true
107+
:weight :regular
108+
:size :paragraph-1}]]
120109
[button/button
121110
{:icon-only? true
122111
:type :grey

src/quo/components/wallet/address_text/schema.cljs

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
[:format {:optional true} [:enum :short :long]]
1111
[:theme :schema.common/theme]
1212
[:networks {:optional true}
13-
[:maybe [:sequential [:map [:network-name :keyword] [:short-name :string]]]]]]]]
13+
[:maybe [:sequential [:map [:network-name :keyword] [:short-name :string]]]]]
14+
[:full-address? {:optional true} [:maybe :boolean]]
15+
;; TODO: size and weight are text schemas and should be imported here
16+
;; https://github.com/status-im/status-mobile/issues/19443
17+
[:size {:optional true} [:maybe :keyword]]
18+
[:weight {:optional true} [:maybe :keyword]]]]]
1419
:any])

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

+33-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(ns quo.components.wallet.address-text.view
2-
(:require [quo.components.markdown.text :as text]
2+
(:require [clojure.string :as string]
3+
[quo.components.markdown.text :as text]
34
[quo.components.wallet.address-text.schema :as component-schema]
45
[quo.components.wallet.address-text.style :as style]
56
[quo.foundations.colors :as colors]
@@ -8,27 +9,39 @@
89
[utils.address :as utils]))
910

1011
(defn- colored-network-text
11-
[theme network]
12-
(let [{:keys [network-name short-name]} network]
13-
[text/text
14-
{:size :paragraph-2
15-
:style {:color (colors/resolve-color network-name theme)}}
16-
(str short-name ":")]))
12+
[{:keys [theme network size weight]}]
13+
[text/text
14+
{:size size
15+
:weight weight
16+
:style {:color (colors/resolve-color (keyword network) theme)}}
17+
(str network ":")])
1718

1819
(defn- view-internal
19-
[{:keys [networks address blur? theme format]}]
20-
(let [network-text-xf (map #(colored-network-text theme %))
21-
address-text [text/text
22-
{:size :paragraph-2
23-
;; TODO: monospace font
24-
;; https://github.com/status-im/status-mobile/issues/17009
25-
:weight :monospace
26-
:style (style/address-text format blur? theme)}
27-
(if (= format :short)
28-
(utils/get-short-wallet-address address)
29-
address)]]
30-
(as-> networks $
31-
(into [text/text] network-text-xf $)
20+
[{:keys [networks address blur? theme format full-address? size weight]
21+
:or {size :paragraph-2}}]
22+
(let [network-colored-text (map #(colored-network-text {:theme theme
23+
:network %
24+
:weight weight
25+
:size size}))
26+
[splitted-networks splitted-address] (and full-address?
27+
(as-> address $
28+
(string/split $ ":")
29+
[(butlast $) (last $)]))
30+
address-internal (if full-address? splitted-address address)
31+
networks-internal (if full-address?
32+
splitted-networks
33+
(map :short-name networks))
34+
address-text [text/text
35+
{:size size
36+
;; TODO: monospace font
37+
;; https://github.com/status-im/status-mobile/issues/17009
38+
:weight (or weight :monospace)
39+
:style (style/address-text format blur? theme)}
40+
(if (= format :short)
41+
(utils/get-short-wallet-address address-internal)
42+
address-internal)]]
43+
(as-> networks-internal $
44+
(into [text/text] network-colored-text $)
3245
(conj $ address-text))))
3346

3447
(def view

src/quo/components/wallet/token_input/schema.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
[:catn
66
[:props
77
[:map
8-
[:token {:optional true} [:maybe :keyword]]
9-
[:currency {:optional true} [:maybe :keyword]]
8+
[:token {:optional true} [:maybe :string :keyword]]
9+
[:currency {:optional true} [:maybe :string :keyword]]
1010
[:error? {:optional true} [:maybe :boolean]]
1111
[:title {:optional true} [:maybe :string]]
1212
[:conversion {:optional true} [:maybe :double]]

src/quo/foundations/colors.cljs

+12
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@
254254
:polygon "#AD71F3"
255255
:unknown "#EEF2F5"})
256256

257+
(def ^:private get-network-full-name
258+
{:eth :ethereum
259+
:opt :optimism
260+
:arb1 :arbitrum})
261+
262+
(def ^:private networks-short-name
263+
(reduce (fn [acc [k v]]
264+
(assoc acc k (get networks v)))
265+
{}
266+
get-network-full-name))
267+
257268
(def socials
258269
{:social/link "#647084"
259270
:social/facebook "#1877F2"
@@ -294,6 +305,7 @@
294305
60 warning-60}}
295306
customization
296307
networks
308+
networks-short-name
297309
socials))
298310

299311
(defn hex-string?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(ns status-im.contexts.shell.qr-reader.events
2+
(:require
3+
[status-im.contexts.shell.qr-reader.sheets.scanned-wallet-address :as scanned-address]
4+
[utils.re-frame :as rf]))
5+
6+
(rf/reg-event-fx
7+
:generic-scanner/scan-success
8+
(fn [_ [address]]
9+
{:fx [[:dispatch [:navigate-back]]
10+
[:dispatch [:show-bottom-sheet {:content #(scanned-address/view address)}]]]}))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
(ns status-im.contexts.shell.qr-reader.sheets.scanned-wallet-address
2+
(:require
3+
[quo.core :as quo]
4+
[utils.i18n :as i18n]
5+
[utils.re-frame :as rf]))
6+
7+
(defn view
8+
[address]
9+
[:<>
10+
[quo/drawer-top
11+
{:title address
12+
:type :address}]
13+
[quo/action-drawer
14+
[[{:icon :i/send
15+
:accessibility-label :send-asset
16+
:label (i18n/label :t/send-to-this-address)
17+
:on-press (fn []
18+
(rf/dispatch [:wallet/select-send-address
19+
{:address address
20+
:recipient address
21+
:stack-id :wallet-select-address
22+
:start-flow? true}]))}
23+
{:icon :i/save
24+
:accessibility-label :save-address
25+
:label (i18n/label :t/save-address)
26+
:on-press #(js/alert "feature not implemented")}]]]])

src/status_im/contexts/shell/qr_reader/view.cljs

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@
8888
(load-and-show-profile scanned-text)
8989

9090
(eth-address? scanned-text)
91-
(debounce/debounce-and-dispatch [:navigate-to :screen/wallet.accounts scanned-text] 300)
91+
(do
92+
(debounce/debounce-and-dispatch [:generic-scanner/scan-success scanned-text] 300)
93+
(debounce/debounce-and-dispatch [:navigate-change-tab :wallet-stack] 300))
9294

9395
(eip681-address? scanned-text)
9496
(do

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
:label (:name token)
1717
:token-value (str crypto-formatted " " (:symbol token))
1818
:fiat-value fiat-formatted
19-
:networks (:networks token)
19+
:networks (seq (:networks token))
2020
:on-press #(on-token-press token)}]))
2121

2222
(defn view

src/status_im/contexts/wallet/events.cljs

+7-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@
4343
(fn [{:keys [db]} [address]]
4444
{:db (assoc-in db [:wallet :current-viewing-account-address] address)}))
4545

46-
(rf/reg-event-fx :wallet/close-account-page
46+
(rf/reg-event-fx :wallet/clean-current-viewing-account
4747
(fn [{:keys [db]}]
48-
{:db (update db :wallet dissoc :current-viewing-account-address)
49-
:fx [[:dispatch [:pop-to-root :shell-stack]]]}))
48+
{:db (update db :wallet dissoc :current-viewing-account-address)}))
49+
50+
(rf/reg-event-fx :wallet/close-account-page
51+
(fn [_]
52+
{:fx [[:dispatch [:wallet/clean-current-viewing-account]]
53+
[:dispatch [:pop-to-root :shell-stack]]]}))
5054

5155
(rf/reg-event-fx
5256
:wallet/get-accounts-success

src/status_im/contexts/wallet/send/events.cljs

+10
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,13 @@
357357
{:id :send-transaction-error
358358
:type :negative
359359
:text (:message error)}]))}]})))
360+
361+
(rf/reg-event-fx
362+
:wallet/select-from-account
363+
(fn [_ [{:keys [address stack-id start-flow?]}]]
364+
{:fx [[:dispatch [:wallet/switch-current-viewing-account address]]
365+
[:dispatch
366+
[:wallet/wizard-navigate-forward
367+
{:current-screen stack-id
368+
:start-flow? start-flow?
369+
:flow-id :wallet-flow}]]]}))

src/status_im/contexts/wallet/send/flow_config.cljs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
(ns status-im.contexts.wallet.send.flow-config)
22

33
(def steps
4-
[{:screen-id :screen/wallet.select-address
4+
[{:screen-id :screen/wallet.select-from
5+
:skip-step? (fn [db] (some? (get-in db [:wallet :current-viewing-account-address])))}
6+
{:screen-id :screen/wallet.select-address
57
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :recipient])))}
68
{:screen-id :screen/wallet.select-asset
79
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :token])))}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(ns status-im.contexts.wallet.send.from.style)
2+
3+
(def accounts-list
4+
{:padding-bottom 12})
5+
6+
(def accounts-list-container
7+
{:padding-horizontal 8})

0 commit comments

Comments
 (0)