Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bottom sheet with save and send options not displayed after scanning wallet QR using universal scanner #18928 #19250

Merged
merged 71 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
3c4d5aa
convert wallet-select-address screen - draft
mmilad75 Mar 1, 2024
e488c70
add functionality
mmilad75 Mar 5, 2024
84c6f76
add comment
mmilad75 Mar 5, 2024
edbdb77
replace usage
mmilad75 Mar 5, 2024
ffbf034
add navigation back
mmilad75 Mar 6, 2024
f9fcf47
fix lint issues
mmilad75 Mar 6, 2024
f89ea86
create new namespace for flow config
mmilad75 Mar 12, 2024
8b4acd9
revert back changes
mmilad75 Mar 12, 2024
84ebeeb
re-add functionality
mmilad75 Mar 13, 2024
f9b774c
replace dispatch with fx
mmilad75 Mar 13, 2024
0e42390
add wizard-backward and its usage
mmilad75 Mar 13, 2024
d1810f2
rename is-first? to start-flow?
mmilad75 Mar 13, 2024
df249f6
rename navigation/wizard-send-flow to wallet/wizard.send-forward
mmilad75 Mar 13, 2024
d857563
rename navigate-wizard-next-screen to wizard-find-next-screen
mmilad75 Mar 13, 2024
4073123
refactor wizard-find-next-screen
mmilad75 Mar 13, 2024
fb8746d
fix lint issues
mmilad75 Mar 13, 2024
1cf6675
resolve comments
mmilad75 Mar 13, 2024
9d44709
rename send-assets to steps
mmilad75 Mar 15, 2024
5957dfe
rename wallet/wizard.send-forward to wallet/send-flow-navigate-forward
mmilad75 Mar 15, 2024
28b80c8
move wizard navigation to a new ns
mmilad75 Mar 18, 2024
e3c364e
remove wizard backward and replace it with navigate-back
mmilad75 Mar 18, 2024
1ad2683
fix lint issues
mmilad75 Mar 18, 2024
bcf6464
Merge branch 'develop' into milad/19059-create-new-navigation-flow
mmilad75 Mar 19, 2024
f07b826
Merge branch 'develop' into milad/19059-create-new-navigation-flow
mmilad75 Mar 19, 2024
57c7e88
Merge branch 'develop' into milad/19059-create-new-navigation-flow
mmilad75 Mar 20, 2024
107d3e9
move and rename wizard
mmilad75 Mar 20, 2024
5c22d1e
rename wizard
mmilad75 Mar 20, 2024
2eff897
remove :wallet/send-flow-navigate-forward and replace it with :wallet…
mmilad75 Mar 20, 2024
ba7ed1e
fix navigating to transaction progress
mmilad75 Mar 20, 2024
0680304
fix lint issues
mmilad75 Mar 20, 2024
88f9b5a
Merge branch 'develop' into milad/19059-create-new-navigation-flow
mmilad75 Mar 20, 2024
e0a98e2
add basics
mmilad75 Feb 28, 2024
1091e81
add send from screen
mmilad75 Feb 29, 2024
8fc2db0
add navigation
mmilad75 Feb 29, 2024
3b0d4b0
convert navigation to use wizard
mmilad75 Mar 14, 2024
4a1cda9
update address-text component
mmilad75 Mar 14, 2024
6596d11
add functionality
mmilad75 Mar 15, 2024
acf6a0d
fix lint issues
mmilad75 Mar 15, 2024
608ef41
add short network name to colors
mmilad75 Mar 15, 2024
3c4ce57
add address-text to share_qr_code screen
mmilad75 Mar 15, 2024
9f761de
fix lint issues
mmilad75 Mar 15, 2024
692b4be
remove watched accounts in from screen
mmilad75 Mar 15, 2024
3368bb7
finalize code
mmilad75 Mar 15, 2024
4b586e7
move on-close outside of the function body
mmilad75 Mar 18, 2024
2477f04
convert network param in colored-network-text to string
mmilad75 Mar 18, 2024
9b1da7b
fix lint issues
mmilad75 Mar 18, 2024
43cf9e6
fix running branch
mmilad75 Mar 20, 2024
1ec164e
resolve comments
mmilad75 Mar 20, 2024
09e865d
create new ns for scanned address
mmilad75 Mar 20, 2024
2b6f910
fix lint issues
mmilad75 Mar 20, 2024
9322e00
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Mar 26, 2024
98afa30
fix malli errors
mmilad75 Mar 26, 2024
b1792c9
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Mar 26, 2024
a8b5019
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Mar 26, 2024
32cd9ad
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Mar 27, 2024
f8f446b
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Mar 28, 2024
781263d
resolve comments
mmilad75 Mar 28, 2024
02db6d6
finalize code
mmilad75 Mar 28, 2024
15c9ae0
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Mar 28, 2024
82d106a
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Mar 28, 2024
58bf0d2
resolve comments
mmilad75 Mar 28, 2024
f8f2d3c
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Mar 28, 2024
16898b4
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Mar 29, 2024
ce57df5
remove extra codes
mmilad75 Mar 29, 2024
6b2a44f
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Mar 29, 2024
b3db159
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Apr 1, 2024
b4f104d
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Apr 1, 2024
091c91c
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Apr 2, 2024
fca6576
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Apr 2, 2024
8fa4740
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Apr 3, 2024
d2ecca8
Merge branch 'develop' into milad/18928-add-bottom-sheet-scan-qr-code
mmilad75 Apr 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/quo/components/drawers/drawer_top/component_spec.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
(h/is-truthy (h/get-by-text "Title"))
(h/is-truthy (h/get-by-text "Description")))

(h/test "component renders in address type"
(h/render-with-theme-provider [quo/drawer-top
{:title "0x1"
:type :address}]
theme)
(h/is-truthy (h/get-by-text "0x1")))

(h/test "component renders in info type"
(h/render-with-theme-provider [quo/drawer-top
{:title "Title"
Expand Down
15 changes: 10 additions & 5 deletions src/quo/components/drawers/drawer_top/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,16 @@
(defn- left-title
[{:keys [type label title title-icon theme blur?]}]
(case type
:label [text/text
{:weight :medium
:size :paragraph-2
:style (style/description theme blur?)}
label]
:label [text/text
{:weight :medium
:size :paragraph-2
:style (style/description theme blur?)}
label]
:address [address-text/view
{:address title
:full-address? true
:weight :semi-bold
:size :heading-2}]
[rn/view {:style style/title-container}
[text/text
{:size :heading-2
Expand Down
42 changes: 0 additions & 42 deletions src/quo/components/share/share_qr_code/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
:padding-top 12
:padding-bottom 8})

(def gradient-bg
{:position :absolute
:top 0
:left 0
:right 0})

;;; Header
(def header-container
{:flex-direction :row
Expand Down Expand Up @@ -71,41 +65,5 @@
:justify-content :space-between
:flex 1})

;;; Dashed line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please comment of why you are removing all of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were unused

(def ^:private padding-for-divider (+ padding-horizontal 4))
(def ^:private dashed-line-width 2)
(def ^:private dashed-line-space 4)

(def dashed-line
{:flex-direction :row
:margin-left -1})

(def line
{:background-color colors/white-opa-20
:width dashed-line-width
:height 1})

(def line-space
{:width dashed-line-space
:height 1})

(defn number-lines-and-spaces-to-fill
[component-width]
(let [line-and-space-width (+ dashed-line-width dashed-line-space)
width-to-fill (- component-width (* 2 padding-for-divider))
number-of-lines (* (/ width-to-fill line-and-space-width) 2)]
(inc (int number-of-lines))))

(def ^:private get-network-full-name
{"eth" :ethereum
"opt" :optimism
"arb1" :arbitrum})

(defn network-short-name-text
[network-short-name]
{:color (-> network-short-name
(get-network-full-name :unknown)
(colors/resolve-color nil))})

(def watched-account-icon
{:margin-left 4})
23 changes: 6 additions & 17 deletions src/quo/components/share/share_qr_code/view.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns quo.components.share.share-qr-code.view
(:require [clojure.set]
[clojure.string :as string]
[oops.core :as oops]
[quo.components.avatars.account-avatar.view :as account-avatar]
[quo.components.avatars.user-avatar.view :as user-avatar]
Expand All @@ -13,6 +12,7 @@
[quo.components.share.share-qr-code.schema :as component-schema]
[quo.components.share.share-qr-code.style :as style]
[quo.components.tabs.tab.view :as tab]
[quo.components.wallet.address-text.view :as address-text]
[quo.foundations.colors :as colors]
[quo.theme]
[react-native.core :as rn]
Expand Down Expand Up @@ -74,21 +74,6 @@
:on-press on-press}
:i/share]])

(defn- network-colored-text
[network-short-name]
[text/text {:style (style/network-short-name-text network-short-name)}
(str network-short-name ":")])

(defn- wallet-multichain-colored-address
[full-address]
(let [[networks address] (as-> full-address $
(string/split $ ":")
[(butlast $) (last $)])
->network-hiccup-xf (map #(vector network-colored-text %))]
(as-> networks $
(into [:<>] ->network-hiccup-xf $)
(conj $ address))))

(defn- profile-bottom
[{:keys [component-width qr-data on-text-press on-text-long-press share-qr-type]}]
[rn/view
Expand Down Expand Up @@ -116,7 +101,11 @@
{:width component-width
:on-press on-text-press
:on-long-press on-text-long-press}
[wallet-multichain-colored-address qr-data]]
[address-text/view
{:address qr-data
:full-address? true
:weight :regular
:size :paragraph-1}]]
[button/button
{:icon-only? true
:type :grey
Expand Down
7 changes: 6 additions & 1 deletion src/quo/components/wallet/address_text/schema.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
[:format {:optional true} [:enum :short :long]]
[:theme :schema.common/theme]
[:networks {:optional true}
[:maybe [:sequential [:map [:network-name :keyword] [:short-name :string]]]]]]]]
[:maybe [:sequential [:map [:network-name :keyword] [:short-name :string]]]]]
[:full-address? {:optional true} [:maybe :boolean]]
;; TODO: size and weight are text schemas and should be imported here
;; https://github.com/status-im/status-mobile/issues/19443
[:size {:optional true} [:maybe :keyword]]
[:weight {:optional true} [:maybe :keyword]]]]]
:any])
53 changes: 33 additions & 20 deletions src/quo/components/wallet/address_text/view.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns quo.components.wallet.address-text.view
(:require [quo.components.markdown.text :as text]
(:require [clojure.string :as string]
[quo.components.markdown.text :as text]
[quo.components.wallet.address-text.schema :as component-schema]
[quo.components.wallet.address-text.style :as style]
[quo.foundations.colors :as colors]
Expand All @@ -8,27 +9,39 @@
[utils.address :as utils]))

(defn- colored-network-text
[theme network]
(let [{:keys [network-name short-name]} network]
[text/text
{:size :paragraph-2
:style {:color (colors/resolve-color network-name theme)}}
(str short-name ":")]))
[{:keys [theme network size weight]}]
[text/text
{:size size
:weight weight
:style {:color (colors/resolve-color (keyword network) theme)}}
(str network ":")])

(defn- view-internal
[{:keys [networks address blur? theme format]}]
(let [network-text-xf (map #(colored-network-text theme %))
address-text [text/text
{:size :paragraph-2
;; TODO: monospace font
;; https://github.com/status-im/status-mobile/issues/17009
:weight :monospace
:style (style/address-text format blur? theme)}
(if (= format :short)
(utils/get-short-wallet-address address)
address)]]
(as-> networks $
(into [text/text] network-text-xf $)
[{:keys [networks address blur? theme format full-address? size weight]
:or {size :paragraph-2}}]
(let [network-colored-text (map #(colored-network-text {:theme theme
:network %
:weight weight
:size size}))
[splitted-networks splitted-address] (and full-address?
(as-> address $
(string/split $ ":")
[(butlast $) (last $)]))
address-internal (if full-address? splitted-address address)
networks-internal (if full-address?
splitted-networks
(map :short-name networks))
address-text [text/text
{:size size
;; TODO: monospace font
;; https://github.com/status-im/status-mobile/issues/17009
:weight (or weight :monospace)
:style (style/address-text format blur? theme)}
(if (= format :short)
(utils/get-short-wallet-address address-internal)
address-internal)]]
(as-> networks-internal $
(into [text/text] network-colored-text $)
(conj $ address-text))))

(def view
Expand Down
12 changes: 12 additions & 0 deletions src/quo/foundations/colors.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,17 @@
:polygon "#AD71F3"
:unknown "#EEF2F5"})

(def ^:private get-network-full-name
{:eth :ethereum
:opt :optimism
:arb1 :arbitrum})

(def ^:private networks-short-name
(reduce (fn [acc [k v]]
(assoc acc k (get networks v)))
{}
get-network-full-name))

(def socials
{:social/link "#647084"
:social/facebook "#1877F2"
Expand Down Expand Up @@ -293,6 +304,7 @@
60 warning-60}}
customization
networks
networks-short-name
socials))

(defn hex-string?
Expand Down
10 changes: 10 additions & 0 deletions src/status_im/contexts/shell/qr_reader/events.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(ns status-im.contexts.shell.qr-reader.events
(:require
[status-im.contexts.shell.qr-reader.sheets.scanned-address :as scanned-address]
[utils.re-frame :as rf]))

(rf/reg-event-fx
:generic-scanner/scan-success
(fn [_ [address]]
{:fx [[:dispatch [:navigate-back]]
[:dispatch [:show-bottom-sheet {:content #(scanned-address/view address)}]]]}))
26 changes: 26 additions & 0 deletions src/status_im/contexts/shell/qr_reader/sheets/scanned_address.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(ns status-im.contexts.shell.qr-reader.sheets.scanned-address
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we should discrimate somehow what this is related to.
status-im.contexts.shell.qr-reader.sheets.wallet-scanned-address
or
status-im.contexts.shell.qr-reader.sheets.scanned-wallet-address

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

(:require
[quo.core :as quo]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

(defn view
[address]
[:<>
[quo/drawer-top
{:title address
:type :address}]
[quo/action-drawer
[[{:icon :i/send
:accessibility-label :send-asset
:label (i18n/label :t/send-to-this-address)
:on-press (fn []
(rf/dispatch [:wallet/select-send-address
{:address address
:recipient address
:stack-id :wallet-select-address
:start-flow? true}]))}
{:icon :i/save
:accessibility-label :save-address
:label (i18n/label :t/save-address)
:on-press #(js/alert "feature not implemented")}]]]])
4 changes: 3 additions & 1 deletion src/status_im/contexts/shell/qr_reader/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@
(load-and-show-profile scanned-text)

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

(eip681-address? scanned-text)
(do
Expand Down
4 changes: 2 additions & 2 deletions src/status_im/contexts/wallet/common/asset_list/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
fiat-value (utils/total-token-fiat-value currency token)
fiat-formatted (utils/get-standard-fiat-format crypto-formatted currency-symbol fiat-value)]
[quo/token-network
{:token (:symbol token)
{:token (keyword (:symbol token))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should make this has no side effects on it's previous uses.
cc @briansztamfater / @OmarBasem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the schema to accept keyword and string

:label (:name token)
:token-value (str crypto-formatted " " (:symbol token))
:fiat-value fiat-formatted
:networks (:networks token)
:networks (seq (:networks token))
:on-press #(on-token-press token)}]))

(defn view
Expand Down
10 changes: 7 additions & 3 deletions src/status_im/contexts/wallet/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@
(fn [{:keys [db]} [address]]
{:db (assoc-in db [:wallet :current-viewing-account-address] address)}))

(rf/reg-event-fx :wallet/close-account-page
(rf/reg-event-fx :wallet/clean-current-viewing-account
(fn [{:keys [db]}]
{:db (update db :wallet dissoc :current-viewing-account-address)
:fx [[:dispatch [:pop-to-root :shell-stack]]]}))
{:db (update db :wallet dissoc :current-viewing-account-address)}))

(rf/reg-event-fx :wallet/close-account-page
(fn [_]
{:fx [[:dispatch [:wallet/clean-current-viewing-account]]
[:dispatch [:pop-to-root :shell-stack]]]}))

(rf/reg-event-fx
:wallet/get-accounts-success
Expand Down
10 changes: 10 additions & 0 deletions src/status_im/contexts/wallet/send/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,13 @@
{:id :send-transaction-error
:type :negative
:text (:message error)}]))}]})))

(rf/reg-event-fx
:wallet/select-from-account
(fn [_ [{:keys [address stack-id start-flow?]}]]
{:fx [[:dispatch [:wallet/switch-current-viewing-account address]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-flow}]]]}))
4 changes: 3 additions & 1 deletion src/status_im/contexts/wallet/send/flow_config.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
(ns status-im.contexts.wallet.send.flow-config)

(def steps
[{:screen-id :screen/wallet.select-address
[{:screen-id :screen/wallet.select-from
:skip-step? (fn [db] (some? (get-in db [:wallet :current-viewing-account-address])))}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

{:screen-id :screen/wallet.select-address
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :recipient])))}
{:screen-id :screen/wallet.select-asset
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :token])))}
Expand Down
7 changes: 7 additions & 0 deletions src/status_im/contexts/wallet/send/from/style.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(ns status-im.contexts.wallet.send.from.style)

(def accounts-list
{:padding-bottom 12})

(def accounts-list-container
{:padding-horizontal 8})
Loading