[FIX #148] Disable back button on QR code reader page until camera is available.
This commit is contained in:
parent
41429cf1ed
commit
90c26570f8
|
@ -12,26 +12,30 @@
|
||||||
[status-im.components.toolbar.styles :refer [toolbar-background1]]
|
[status-im.components.toolbar.styles :refer [toolbar-background1]]
|
||||||
[status-im.ui.screens.qr-scanner.styles :as st]
|
[status-im.ui.screens.qr-scanner.styles :as st]
|
||||||
[status-im.utils.types :refer [json->clj]]
|
[status-im.utils.types :refer [json->clj]]
|
||||||
[clojure.string :as str]))
|
[clojure.string :as str]
|
||||||
|
[reagent.core :as r]))
|
||||||
|
|
||||||
(defview qr-scanner-toolbar [title]
|
(defview qr-scanner-toolbar [title hide-nav?]
|
||||||
(letsubs [modal [:get :modal]]
|
(letsubs [modal [:get :modal]]
|
||||||
[view
|
[view
|
||||||
[status-bar]
|
[status-bar]
|
||||||
[toolbar {:title title
|
[toolbar {:title title
|
||||||
:background-color toolbar-background1
|
:background-color toolbar-background1
|
||||||
|
:hide-nav? hide-nav?
|
||||||
:nav-action (when modal
|
:nav-action (when modal
|
||||||
(act/back #(dispatch [:navigate-back])))}]]))
|
(act/back #(dispatch [:navigate-back])))}]]))
|
||||||
|
|
||||||
(defview qr-scanner []
|
(defview qr-scanner []
|
||||||
(letsubs [identifier [:get :current-qr-context]]
|
(letsubs [identifier [:get :current-qr-context]
|
||||||
|
camera-initialized? (r/atom false)]
|
||||||
[view st/barcode-scanner-container
|
[view st/barcode-scanner-container
|
||||||
[qr-scanner-toolbar (:toolbar-title identifier)]
|
[qr-scanner-toolbar (:toolbar-title identifier) (not @camera-initialized?)]
|
||||||
[camera {:onBarCodeRead (fn [code]
|
[camera {:onBarCodeRead (fn [code]
|
||||||
(let [data (-> (.-data code)
|
(let [data (-> (.-data code)
|
||||||
(str/replace #"ethereum:" ""))]
|
(str/replace #"ethereum:" ""))]
|
||||||
(dispatch [:set-qr-code identifier data])))
|
(dispatch [:set-qr-code identifier data])))
|
||||||
;:barCodeTypes [:qr]
|
;:barCodeTypes [:qr]
|
||||||
|
:ref #(reset! camera-initialized? true)
|
||||||
:captureAudio false
|
:captureAudio false
|
||||||
:style st/barcode-scanner}]
|
:style st/barcode-scanner}]
|
||||||
[view st/rectangle-container
|
[view st/rectangle-container
|
||||||
|
|
Loading…
Reference in New Issue