mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-27 08:55:39 +00:00
parent
56492949f1
commit
df256bf2b4
@ -1,16 +1,18 @@
|
|||||||
(ns status-im.ui.screens.qr-scanner.views
|
(ns status-im.ui.screens.qr-scanner.views
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[react-native.camera-kit :as camera-kit]
|
[react-native.camera-kit :as camera-kit]
|
||||||
|
[react-native.core :as rn]
|
||||||
|
[reagent.core :as reagent]
|
||||||
[status-im.ui.components.colors :as colors]
|
[status-im.ui.components.colors :as colors]
|
||||||
[status-im.ui.components.core :as quo]
|
[status-im.ui.components.core :as quo]
|
||||||
[status-im.ui.components.react :as react]
|
[status-im.ui.components.react :as react]
|
||||||
[status-im.ui.components.topbar :as topbar]
|
[status-im.ui.components.topbar :as topbar]
|
||||||
[status-im.ui.screens.qr-scanner.styles :as styles]
|
[status-im.ui.screens.qr-scanner.styles :as styles]
|
||||||
[status-im2.config :as config]
|
[status-im2.config :as config]
|
||||||
[utils.i18n :as i18n]))
|
[utils.i18n :as i18n]
|
||||||
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn get-qr-code-data
|
(defn get-qr-code-data
|
||||||
[^js event]
|
[^js event]
|
||||||
@ -85,13 +87,18 @@
|
|||||||
[opts data]
|
[opts data]
|
||||||
(re-frame/dispatch [:qr-scanner.callback/scan-qr-code-success opts (get-qr-code-data data)]))
|
(re-frame/dispatch [:qr-scanner.callback/scan-qr-code-success opts (get-qr-code-data data)]))
|
||||||
|
|
||||||
(defview qr-scanner
|
(defn- navigate-back-handler
|
||||||
[]
|
[]
|
||||||
(letsubs [read-once? (atom false)
|
(re-frame/dispatch [:navigate-back])
|
||||||
{:keys [height width]} [:dimensions/window]
|
true)
|
||||||
camera-flashlight [:wallet-legacy.send/camera-flashlight]
|
|
||||||
opts [:get-screen-params]
|
(defn f-qr-scanner
|
||||||
camera-ref (atom nil)]
|
[]
|
||||||
|
(let [read-once? (reagent/atom false)
|
||||||
|
{:keys [height width]} (rf/sub [:dimensions/window])
|
||||||
|
camera-flashlight (rf/sub [:wallet-legacy.send/camera-flashlight])
|
||||||
|
opts (rf/sub [:get-screen-params])
|
||||||
|
camera-ref (reagent/atom nil)]
|
||||||
[react/view
|
[react/view
|
||||||
{:flex 1
|
{:flex 1
|
||||||
:background-color colors/black-persist}
|
:background-color colors/black-persist}
|
||||||
@ -111,3 +118,11 @@
|
|||||||
(reset! read-once? true)
|
(reset! read-once? true)
|
||||||
(on-barcode-read opts %))}]]
|
(on-barcode-read opts %))}]]
|
||||||
[viewfinder (int (* 2 (/ (min height width) 3)))]])]))
|
[viewfinder (int (* 2 (/ (min height width) 3)))]])]))
|
||||||
|
|
||||||
|
(defn qr-scanner
|
||||||
|
[]
|
||||||
|
(reagent/create-class
|
||||||
|
{:display-name "qr-scanner"
|
||||||
|
:component-did-mount #(rn/hw-back-add-listener navigate-back-handler)
|
||||||
|
:component-will-unmount #(rn/hw-back-remove-listener navigate-back-handler)
|
||||||
|
:reagent-render f-qr-scanner}))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user