mirror of
https://github.com/status-im/status-react.git
synced 2025-03-03 03:51:01 +00:00
27 lines
825 B
Clojure
27 lines
825 B
Clojure
(ns status-im.qr-scanner.core
|
|
(:require [re-frame.core :as re-frame]
|
|
[status-im.i18n :as i18n]
|
|
[status-im.utils.utils :as utils]
|
|
[status-im.utils.fx :as fx]))
|
|
|
|
(fx/defn scan-qr-code
|
|
[_ opts]
|
|
{:request-permissions-fx
|
|
{:permissions [:camera]
|
|
:on-allowed #(re-frame/dispatch [:navigate-to :qr-scanner opts])
|
|
:on-denied (fn []
|
|
(utils/set-timeout
|
|
#(utils/show-popup (i18n/label :t/error)
|
|
(i18n/label :t/camera-access-error))
|
|
50))}})
|
|
|
|
(fx/defn set-qr-code
|
|
[{:keys [db]} opts data]
|
|
(when-let [handler (:handler opts)]
|
|
{:dispatch [handler data opts]}))
|
|
|
|
(fx/defn set-qr-code-cancel
|
|
[_ opts]
|
|
(when-let [handler (:cancel-handler opts)]
|
|
{:dispatch [handler opts]}))
|