Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarBasem committed Dec 19, 2023
1 parent aeba072 commit cad9ae2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 56 deletions.
16 changes: 1 addition & 15 deletions src/quo/components/share/share_qr_code/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@
(defn- line [] [rn/view {:style style/line}])
(defn- space [] [rn/view {:style style/line-space}])

(defn- dashed-line
[width]
(into [rn/view {:style style/dashed-line}]
(take (style/number-lines-and-spaces-to-fill width))
(cycle [[line] [space]])))

(defn- header
[{:keys [share-qr-type on-info-press on-legacy-press on-multichain-press]}]
[{:keys [share-qr-type on-legacy-press on-multichain-press]}]
[rn/view {:style style/header-container}
[tab/view
{:accessibility-label :share-qr-code-legacy-tab
Expand Down Expand Up @@ -114,12 +108,6 @@
:on-long-press on-text-long-press}
qr-data])

(def ^:private known-networks #{:ethereum :optimism :arbitrum})

(defn- get-network-image-source
[network]
{:source (quo.resources/get-network (get known-networks network :unknown))})

(defn wallet-multichain-bottom
[{:keys [component-width qr-data on-text-press on-text-long-press on-settings-press]}]
[rn/view
Expand Down Expand Up @@ -193,14 +181,12 @@
- profile-picture: map ({:source image-source}) or any image source.
`:wallet-legacy`
- emoji: Emoji in a string to show in the QR code.
- on-info-press: Callback for the info icon.
- on-legacy-press: Callback for the legacy tab.
- on-multichain-press: Callback for the multichain tab.
`:wallet-multichain`
- networks: A vector of network names as keywords (`[:ethereum, :my-net, ...]`).
- on-settings-press: Callback for the settings button.
- emoji: Emoji in a string to show in the QR code.
- on-info-press: Callback for the info icon.
- on-legacy-press: Callback for the legacy tab.
- on-multichain-press: Callback for the multichain tab.
Expand Down
2 changes: 1 addition & 1 deletion src/status_im2/common/qr_codes/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
:error-level :highest})]
[quo/qr-code (assoc props :qr-image-uri qr-media-server-uri)]))

(defn- get-network-short-name-url
(defn get-network-short-name-url
[network]
(case network
:ethereum "eth:"
Expand Down
6 changes: 3 additions & 3 deletions src/status_im2/contexts/wallet/common/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
[{:keys [wallet-type selected-networks address]}]
(if (= wallet-type :wallet-multichain)
(as-> selected-networks $
(map qr-codes/get-network-short-name-url $)
(apply str $)
(str $ address))
(map qr-codes/get-network-short-name-url $)
(apply str $)
(str $ address))
address))
24 changes: 12 additions & 12 deletions src/status_im2/contexts/wallet/common/utils_test.cljs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
(ns status-im2.contexts.wallet.common.utils-test
(:require [clojure.test :refer :all]
(:require [cljs.test :refer [deftest is testing]]
[status-im2.contexts.wallet.common.utils :as utils]))

(defn test-get-wallet-qr
(deftest test-get-wallet-qr
(testing "Test get-wallet-qr function"
(let [wallet-multichain {:wallet-type :wallet-multichain
:selected-networks [:ethereum :optimism]
:address "x000"}
wallet-singlechain {:wallet-type :wallet-singlechain
:selected-networks [:ethereum :optimism]
:address "x000"}]
(let [wallet-multichain {:wallet-type :wallet-multichain
:selected-networks [:ethereum :optimism]
:address "x000"}
wallet-singlechain {:wallet-type :wallet-singlechain
:selected-networks [:ethereum :optimism]
:address "x000"}]

(is (= (utils/get-wallet-qr wallet-multichain)
"eth:opt:x000"))
(is (= (utils/get-wallet-qr wallet-multichain)
"eth:opt:x000"))

(is (= (utils/get-wallet-qr wallet-singlechain)
"x000")))))
(is (= (utils/get-wallet-qr wallet-singlechain)
"x000")))))
51 changes: 26 additions & 25 deletions src/status_im2/contexts/wallet/receive/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
[react-native.safe-area :as safe-area]
[react-native.share :as share]
[reagent.core :as reagent]
[status-im2.common.qr-codes.view :as qr-codes]
[status-im2.constants :as constants]
[status-im2.contexts.wallet.common.sheets.network-preferences.view :as network-preferences]
[status-im2.contexts.wallet.common.utils :as utils]
[status-im2.contexts.wallet.receive.style :as style]
[utils.i18n :as i18n]
[utils.image-server :as image-server]
[utils.re-frame :as rf]
[status-im2.contexts.wallet.common.utils :as utils]))
[utils.re-frame :as rf]))

(def id-to-network
{constants/mainnet-chain-id :ethereum
Expand All @@ -23,16 +22,16 @@
(defn- share-action
[address share-title]
(share/open
(if platform/ios?
{:activity-item-sources [{:placeholder-item {:type "text"
:content address}
:item {:default {:type "text"
:content
address}}
:link-metadata {:title share-title}}]}
{:title share-title
:subject share-title
:message address})))
(if platform/ios?
{:activity-item-sources [{:placeholder-item {:type "text"
:content address}
:item {:default {:type "text"
:content
address}}
:link-metadata {:title share-title}}]}
{:title share-title
:subject share-title
:message address})))

(defn- open-preferences
[selected-networks]
Expand All @@ -46,7 +45,7 @@
(rf/dispatch [:hide-bottom-sheet])
(reset! selected-networks (map #(get id-to-network %)
chain-ids))
)}])}]))
)}])}]))


(defn view
Expand All @@ -56,18 +55,20 @@
selected-networks (reagent/atom [:ethereum :optimism :arbitrum])]
(fn []
(let [{:keys [address color emoji] :as account} (rf/sub [:wallet/current-viewing-account])
share-title (str (:name account) " " (i18n/label :t/address))
qr-url (utils/get-wallet-qr {:wallet-type @wallet-type
:selected-networks @selected-networks
:address address})
qr-media-server-uri (image-server/get-qr-image-uri-for-any-url
{:url qr-url
:port (rf/sub [:mediaserver/port])
:qr-size 500
:error-level :highest})]
share-title (str (:name account) " " (i18n/label :t/address))
qr-url (utils/get-wallet-qr {:wallet-type @wallet-type
:selected-networks
@selected-networks
:address address})
qr-media-server-uri (image-server/get-qr-image-uri-for-any-url
{:url qr-url
:port (rf/sub [:mediaserver/port])
:qr-size 500
:error-level :highest})]
[quo/overlay {:type :shell}
[rn/view {:flex 1
:padding-top padding-top}
[rn/view
{:flex 1
:padding-top padding-top}
[quo/page-nav
{:icon-name :i/close
:on-press #(rf/dispatch [:navigate-back])
Expand Down

0 comments on commit cad9ae2

Please sign in to comment.