Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ccff087aa |
@@ -34,7 +34,7 @@
|
||||
nil)]
|
||||
[quo/top-nav
|
||||
{:avatar-on-press #(rf/dispatch [:open-modal :settings])
|
||||
:scan-on-press #(js/alert "to be implemented")
|
||||
:scan-on-press #(rf/dispatch [:open-modal :shell-scan-qr])
|
||||
:activity-center-on-press #(rf/dispatch [:activity-center/open])
|
||||
:qr-code-on-press #(dispatch-and-chill [:open-modal :share-shell] 1000)
|
||||
:container-style (merge style/top-nav-container container-style)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
(ns status-im.contexts.shell.scan.view
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[re-frame.core :as rf]
|
||||
[react-native.core :as rn]
|
||||
[react-native.hooks :as hooks]
|
||||
[status-im.common.scan-qr-code.view :as scan-qr-code]
|
||||
[status-im.contexts.wallet.common.validation :as wallet-validation]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[utils.i18n :as i18n]))
|
||||
|
||||
|
||||
(defn legacy-wallet?
|
||||
[qr-string]
|
||||
(wallet-validation/eth-address? qr-string))
|
||||
|
||||
|
||||
(defn profile-qr-code?
|
||||
[qr-string]
|
||||
(string/starts-with? qr-string "https://status.app/u/"))
|
||||
|
||||
|
||||
(defn extracted-id
|
||||
[qr-string]
|
||||
(let [index (string/index-of qr-string "#")]
|
||||
(prn (subs qr-string index))
|
||||
(subs qr-string index)))
|
||||
|
||||
|
||||
(defn qr-type [qr-string]
|
||||
(cond
|
||||
(legacy-wallet? qr-string)
|
||||
(navigation/change-tab :wallet-stack)
|
||||
|
||||
(profile-qr-code? qr-string)
|
||||
(rf/dispatch [:chat.ui/show-profile (extracted-id qr-string)])
|
||||
|
||||
:else
|
||||
#(rf/dispatch
|
||||
[:toasts/upsert
|
||||
{:type :negative
|
||||
:theme :dark
|
||||
:text (i18n/label :t/oops-qr-does-not-work)}])))
|
||||
|
||||
|
||||
(defn- f-internal-view
|
||||
[]
|
||||
(let [{:keys [keyboard-shown]} (hooks/use-keyboard)]
|
||||
[:<>
|
||||
(when keyboard-shown
|
||||
(rn/dismiss-keyboard!))
|
||||
[scan-qr-code/view
|
||||
{:title (i18n/label :t/scan-qr)
|
||||
:on-success-scan #(qr-type (string/trim %))}]]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
[:f> f-internal-view])
|
||||
@@ -247,10 +247,12 @@
|
||||
:zoom-mode :off
|
||||
:torch-mode torch-mode
|
||||
:scan-barcode true
|
||||
:on-read-code #(when scan-code?
|
||||
(check-qr-code-and-navigate {:event %
|
||||
:on-success-scan set-qr-code-succeeded
|
||||
:on-failed-scan set-rescan-timeout}))}]]
|
||||
:on-read-code (fn [a]
|
||||
(prn "=========")
|
||||
(when scan-code?
|
||||
(check-qr-code-and-navigate {:event a
|
||||
:on-success-scan set-qr-code-succeeded
|
||||
:on-failed-scan set-rescan-timeout})))}]]
|
||||
[hole-view/hole-view
|
||||
{:style style/hole
|
||||
:holes [(assoc qr-view-finder :borderRadius 16)]}
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
set-code]))]
|
||||
(fn []
|
||||
[rn/view {:style style/container-main}
|
||||
(prn @code)
|
||||
[:f> f-use-interval clock cleanup-clock @delay-ms]
|
||||
[rn/scroll-view {}
|
||||
[quo/page-nav
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
[status-im.contexts.profile.settings.view :as settings]
|
||||
[status-im.contexts.shell.activity-center.view :as activity-center]
|
||||
[status-im.contexts.shell.jump-to.view :as shell]
|
||||
[status-im.contexts.shell.scan.view :as shell-scan]
|
||||
[status-im.contexts.shell.share.view :as share]
|
||||
[status-im.contexts.syncing.find-sync-code.view :as find-sync-code]
|
||||
[status-im.contexts.syncing.how-to-pair.view :as how-to-pair]
|
||||
@@ -85,6 +86,12 @@
|
||||
{:name :shell-stack
|
||||
:component shell/shell-stack}
|
||||
|
||||
{:name :shell-scan-qr
|
||||
:options (merge
|
||||
options/dark-screen
|
||||
{:modalPresentationStyle :overCurrentContext})
|
||||
:component shell-scan/view}
|
||||
|
||||
{:name :chat
|
||||
:options {:insets {:top? true}
|
||||
:popGesture false}
|
||||
|
||||
@@ -2432,6 +2432,7 @@
|
||||
"est-time": "Est. time",
|
||||
"user-gets": "{{name}} gets",
|
||||
"slide-to-send": "Slide to send",
|
||||
"oops-qr-does-not-work": "Oops! This QR doesn’t work with Status",
|
||||
"this-address-has-activity": "This address has activity",
|
||||
"generate-new-keypair": "Generate new keypair",
|
||||
"import-using-phrase": "Import using recovery phrase",
|
||||
|
||||
Reference in New Issue
Block a user