Add flashlight functionality to choose recipient screen
This commit is contained in:
parent
499cd393ad
commit
69a6baf09b
|
@ -0,0 +1,3 @@
|
|||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<path fill="" d="M12.2559385,5.07823738 L7.65424355,11.1734058 C7.64404466,11.1891311 7.63564653,11.2059534 7.62920748,11.2235556 C7.58177398,11.3532234 7.64843799,11.4967923 7.7781057,11.5442257 L9.96725492,12.3450342 C11.0857046,12.7541722 11.8136967,13.8367442 11.7707182,15.0269023 L11.6076877,18.5415284 L15.9083371,12.169203 C15.976325,12.0124611 15.9163264,11.8659814 15.7889745,11.8126415 L12.7760403,10.5507067 C12.0568154,10.2494672 11.6236676,10.5087149 11.7138462,9.73418434 L12.2559385,5.07823738 Z M9.45193925,13.7537392 L7.26279002,12.9529307 C6.35511602,12.6208963 5.888468,11.615914 6.22050249,10.70824 C6.26557584,10.5850241 6.32436272,10.4672679 6.39575494,10.3571911 L12.742556,1.57131376 C13.1741283,0.905889869 14.2084917,1.27835681 14.1167679,2.06615774 L13.2037815,8.90765762 C13.1908988,9.01830484 13.2527771,9.1241266 13.3555235,9.16716082 L16.3684577,10.4290956 C17.2599209,10.8024753 17.6799106,11.827833 17.3065309,12.7192962 C17.2768982,12.7900458 17.242646,12.8587707 17.2039958,12.9250261 L11.3982074,21.8775141 C11.0052004,22.5512206 9.97271936,22.2519867 10.0008666,21.4725365 L10.2716953,14.9727702 C10.291231,14.4317892 9.96032545,13.939711 9.45193925,13.7537392 Z" id="icon"></path>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
|
@ -16,7 +16,7 @@
|
|||
(def torch-modes (constants "TorchMode"))
|
||||
|
||||
(defn set-torch [state]
|
||||
(set! (.-torchMode default-camera) state))
|
||||
(set! (.-torchMode default-camera) (get torch-modes state)))
|
||||
|
||||
(defn request-access [callback]
|
||||
(if platform/android?
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
:icons/arrow-left (slurp-svg "./resources/icons/arrow_left.svg")
|
||||
:icons/arrow-right (slurp-svg "./resources/icons/arrow_right.svg")
|
||||
:icons/flash-active (slurp-svg "./resources/icons/flash_active.svg")
|
||||
:icons/flash-inactive (slurp-svg "./resources/icons/flash_inactive.svg")
|
||||
:icons/attach (slurp-svg "./resources/icons/attach.svg")
|
||||
:icons/back (slurp-svg "./resources/icons/back.svg")
|
||||
:icons/browse (slurp-svg "./resources/icons/browse.svg")
|
||||
|
|
|
@ -23,14 +23,15 @@
|
|||
:action :send
|
||||
:params {:hide-actions? true}}]))
|
||||
|
||||
(defn toolbar-view []
|
||||
(defn toolbar-view [camera-flashlight]
|
||||
[toolbar/toolbar2 {:style wallet.styles/toolbar
|
||||
:no-sync-bar? true}
|
||||
[toolbar/nav-button (act/back-white act/default-handler)]
|
||||
[toolbar/content-title {:color :white} (i18n/label :t/wallet-choose-recipient)]
|
||||
[toolbar/actions [{:icon :icons/flash-active
|
||||
[toolbar/actions [{:icon (if (= :on camera-flashlight) :icons/flash-active
|
||||
:icons/flash-inactive)
|
||||
:icon-opts {:color :white}
|
||||
:handler show-not-implemented!}]]])
|
||||
:handler #(re-frame/dispatch [:wallet/toggle-flashlight])}]]])
|
||||
|
||||
(defn recipient-buttons []
|
||||
[react/view {:style styles/recipient-buttons}
|
||||
|
@ -74,22 +75,24 @@
|
|||
:style (styles/corner-right-bottom min-dimension)}]]))
|
||||
|
||||
(defview choose-recipient []
|
||||
(letsubs [camera-dimensions [:camera-dimensions]]
|
||||
(letsubs [camera-dimensions [:camera-dimensions]
|
||||
camera-flashlight [:camera-flashlight]]
|
||||
[react/view {:style styles/wallet-container}
|
||||
[status-bar/status-bar {:type :wallet}]
|
||||
[toolbar-view]
|
||||
[toolbar-view camera-flashlight]
|
||||
[react/view {:style styles/qr-container
|
||||
:on-layout #(let [layout (.. % -nativeEvent -layout)]
|
||||
(re-frame/dispatch [:set-in [:wallet :camera-dimensions]
|
||||
(re-frame/dispatch [:set-in [:wallet/send-transaction :camera-dimensions]
|
||||
{:width (.-width layout)
|
||||
:height (.-height layout)}]))}
|
||||
[camera/camera {:style styles/preview
|
||||
:aspect :fill
|
||||
:captureAudio false
|
||||
:torchMode (camera/set-torch camera-flashlight)
|
||||
:onBarCodeRead (fn [code]
|
||||
(let [data (-> code
|
||||
.-data
|
||||
(string/replace #"ethereum:" ""))]
|
||||
(re-frame/dispatch [:choose-recipient data])))}]
|
||||
[viewfinder camera-dimensions]]
|
||||
[recipient-buttons]]))
|
||||
[recipient-buttons]]))
|
||||
|
|
|
@ -11,7 +11,11 @@
|
|||
(spec/def ::waiting-signal? (spec/nilable boolean?))
|
||||
(spec/def ::signing? (spec/nilable boolean?))
|
||||
(spec/def ::later? (spec/nilable boolean?))
|
||||
(spec/def ::height double?)
|
||||
(spec/def ::width double?)
|
||||
(spec/def ::camera-dimensions (spec/keys :req-un [::height ::width]))
|
||||
(spec/def ::camera-flashlight #{:on :off})
|
||||
|
||||
(spec/def :wallet/send-transaction (allowed-keys
|
||||
:opt-un [::amount ::to-address ::to-name ::amount-error ::password
|
||||
::waiting-signal? ::signing? ::transaction-id ::later?]))
|
||||
::waiting-signal? ::signing? ::transaction-id ::later? ::camera-dimensions ::camera-flashlight]))
|
||||
|
|
|
@ -120,4 +120,11 @@
|
|||
(when transaction-id
|
||||
;;TODO (andrey) use ::discard-transaction fx instead
|
||||
{:dispatch-n [[:deny-transaction transaction-id]
|
||||
[:status-im.transactions.handlers/remove-transaction transaction-id]]})))))
|
||||
[:status-im.transactions.handlers/remove-transaction transaction-id]]})))))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:wallet/toggle-flashlight
|
||||
(fn [db]
|
||||
(let [flashlight-state (get-in db [:wallet/send-transaction :camera-flashlight])
|
||||
toggled-state (if (= :on flashlight-state) :off :on)]
|
||||
(assoc-in db [:wallet/send-transaction :camera-flashlight] toggled-state))))
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
|
||||
(re-frame/reg-sub :camera-dimensions
|
||||
(fn [db]
|
||||
(get-in db [:wallet :camera-dimensions])))
|
||||
(get-in db [:wallet/send-transaction :camera-dimensions])))
|
||||
|
||||
(re-frame/reg-sub :camera-flashlight
|
||||
(fn [db]
|
||||
(get-in db [:wallet/send-transaction :camera-flashlight])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:wallet.send/sign-enabled?
|
||||
|
@ -20,4 +24,4 @@
|
|||
:wallet.send/sign-password-enabled?
|
||||
:<- [:get-in [:wallet/send-transaction :password]]
|
||||
(fn [password]
|
||||
(and (not (nil? password)) (not= password ""))))
|
||||
(and (not (nil? password)) (not= password ""))))
|
||||
|
|
Loading…
Reference in New Issue