2016-06-01 11:41:50 +03:00
|
|
|
(ns status-im.qr-scanner.screen
|
|
|
|
(:require-macros [status-im.utils.views :refer [defview]])
|
|
|
|
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
|
|
|
[status-im.components.react :refer [view
|
2016-06-03 15:47:52 +03:00
|
|
|
image]]
|
2016-06-01 11:41:50 +03:00
|
|
|
[status-im.components.camera :refer [camera]]
|
2016-06-03 15:47:52 +03:00
|
|
|
[status-im.components.styles :refer [toolbar-background1
|
2016-06-10 03:03:40 +03:00
|
|
|
icon-search]]
|
2016-06-01 11:41:50 +03:00
|
|
|
[status-im.components.toolbar :refer [toolbar]]
|
|
|
|
[status-im.qr-scanner.styles :as st]
|
2016-06-03 15:47:52 +03:00
|
|
|
[status-im.utils.types :refer [json->clj]]))
|
2016-06-01 11:41:50 +03:00
|
|
|
|
2016-06-03 15:47:52 +03:00
|
|
|
(defn qr-scanner-toolbar [title]
|
|
|
|
[toolbar {:title title
|
|
|
|
:background-color toolbar-background1
|
|
|
|
:action {:image {:source {:uri :icon_lock_white}
|
2016-06-10 03:03:40 +03:00
|
|
|
:style icon-search}
|
2016-06-03 15:47:52 +03:00
|
|
|
:handler #()}}])
|
2016-06-01 11:41:50 +03:00
|
|
|
|
|
|
|
(defview qr-scanner []
|
2016-06-02 17:39:26 +03:00
|
|
|
[identifier [:get :current-qr-context]]
|
2016-06-01 11:41:50 +03:00
|
|
|
[view st/barcode-scanner-container
|
2016-06-03 15:47:52 +03:00
|
|
|
[qr-scanner-toolbar (:toolbar-title identifier)]
|
2016-06-02 17:39:26 +03:00
|
|
|
[camera {;:on-bar-code-read #(js/alert "ok")
|
|
|
|
:onBarCodeRead #(let [data (json->clj (.-data %))]
|
|
|
|
(dispatch [:set-qr-code identifier data]))
|
|
|
|
:style st/barcode-scanner}]
|
2016-06-01 11:41:50 +03:00
|
|
|
[view st/rectangle-container
|
|
|
|
[view st/rectangle
|
|
|
|
[image {:source {:uri :corner_left_top}
|
|
|
|
:style st/corner-left-top}]
|
|
|
|
[image {:source {:uri :corner_right_top}
|
|
|
|
:style st/corner-right-top}]
|
|
|
|
[image {:source {:uri :corner_right_bottom}
|
|
|
|
:style st/corner-right-bottom}]
|
|
|
|
[image {:source {:uri :corner_left_bottom}
|
2016-06-02 17:39:26 +03:00
|
|
|
:style st/corner-left-bottom}]]]])
|