Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
711bca5451 | ||
|
|
ddefb9c0a0 | ||
|
|
22c4f87a37 |
@@ -204,7 +204,7 @@
|
|||||||
(.startSearchForLocalPairingPeers ^js (network) callback))
|
(.startSearchForLocalPairingPeers ^js (network) callback))
|
||||||
|
|
||||||
(defn local-pairing-preflight-outbound-check
|
(defn local-pairing-preflight-outbound-check
|
||||||
"Checks whether the device has allows connecting to the local server"
|
"Checks whether the device has allowed connecting to the local server"
|
||||||
[callback]
|
[callback]
|
||||||
(log/info "[native-module] Performing local pairing preflight check")
|
(log/info "[native-module] Performing local pairing preflight check")
|
||||||
(when platform/ios?
|
(when platform/ios?
|
||||||
|
|||||||
@@ -50,7 +50,8 @@
|
|||||||
[quo/text
|
[quo/text
|
||||||
{:weight :semi-bold
|
{:weight :semi-bold
|
||||||
:size :heading-2
|
:size :heading-2
|
||||||
:style style/header} (i18n/label :t/check-before-syncing)]
|
:style style/header}
|
||||||
|
(i18n/label :t/check-before-syncing)]
|
||||||
[quo/text {:style style/description} (i18n/label :t/check-before-syncing-doc-description)]
|
[quo/text {:style style/description} (i18n/label :t/check-before-syncing-doc-description)]
|
||||||
|
|
||||||
(into
|
(into
|
||||||
@@ -69,6 +70,5 @@
|
|||||||
:disabled? (not= checked-count (count checks))
|
:disabled? (not= checked-count (count checks))
|
||||||
:customization-color (or customization-color :blue)
|
:customization-color (or customization-color :blue)
|
||||||
:accessibility-label :continue-button
|
:accessibility-label :continue-button
|
||||||
|
|
||||||
:on-press on-continue}
|
:on-press on-continue}
|
||||||
(i18n/label :t/continue)]]]))
|
(i18n/label :t/continue)]]]))
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
(ns status-im.common.enable-access-to-local-network.style)
|
||||||
|
|
||||||
|
(def header {:margin-bottom 8})
|
||||||
|
|
||||||
|
(def description {:padding-bottom 8
|
||||||
|
:padding-horizontal 20})
|
||||||
|
|
||||||
|
(def list-container {:padding-horizontal 20
|
||||||
|
:padding-bottom 12})
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
(ns status-im.common.enable-access-to-local-network.view
|
||||||
|
(:require
|
||||||
|
[quo.core :as quo]
|
||||||
|
[react-native.core :as rn]
|
||||||
|
[status-im.common.enable-access-to-local-network.style :as style]
|
||||||
|
[utils.i18n :as i18n]
|
||||||
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(defn- step [{:keys [number text]} button]
|
||||||
|
[rn/view {:style {:flex-direction :row
|
||||||
|
:align-items :center
|
||||||
|
:column-gap 8
|
||||||
|
:padding-vertical 4}}
|
||||||
|
[quo/step {:in-blur-view? true} number]
|
||||||
|
[rn/view {:style {:flex-direction :row
|
||||||
|
:align-items :center
|
||||||
|
:column-gap 4}}
|
||||||
|
[quo/text {:weight :regular
|
||||||
|
:size :paragraph-2}
|
||||||
|
text]
|
||||||
|
button]])
|
||||||
|
|
||||||
|
(defn- hide-bottom-sheet
|
||||||
|
[]
|
||||||
|
(rf/dispatch [:hide-bottom-sheet]))
|
||||||
|
|
||||||
|
(defn view
|
||||||
|
"This implementation must be only used on iOS since we need to request the networking
|
||||||
|
permission, on Android we already have the permission granted."
|
||||||
|
[]
|
||||||
|
(let [[permission-granted?
|
||||||
|
set-permission-granted] (rn/use-state false)
|
||||||
|
verify-permission (rn/use-callback
|
||||||
|
#(rf/dispatch
|
||||||
|
[:syncing/preflight-outbound-check set-permission-granted])
|
||||||
|
[])
|
||||||
|
verifying-permission? nil]
|
||||||
|
(prn "permission-granted?:" permission-granted?)
|
||||||
|
[:<>
|
||||||
|
[quo/drawer-top {:container-style {:padding-bottom 8}
|
||||||
|
:title (i18n/label :t/enable-access-to-local-network)
|
||||||
|
:type :default
|
||||||
|
:blur? true}]
|
||||||
|
[quo/text {:style style/description
|
||||||
|
:weight :regular
|
||||||
|
:size :paragraph-1}
|
||||||
|
(i18n/label :t/enable-access-to-local-network-description)]
|
||||||
|
[rn/view {:style style/list-container}
|
||||||
|
[step {:number 1 :text "Open"}
|
||||||
|
[quo/button {:type :primary
|
||||||
|
:size 24
|
||||||
|
:on-press (fn [] (js/alert "a"))}
|
||||||
|
"Settings / Privacy / Local Network"]]
|
||||||
|
[step {:number 2 :text "Find"}
|
||||||
|
[quo/button {:type :grey
|
||||||
|
:size 24
|
||||||
|
:blur? true}
|
||||||
|
"Status"]]
|
||||||
|
[step {:number 3 :text "Toggle the switch to grant access"}]
|
||||||
|
[step {:number 4 :text "Tap"}
|
||||||
|
[quo/button {:type (if verifying-permission? :grey :primary)
|
||||||
|
:size 24
|
||||||
|
:on-press verify-permission}
|
||||||
|
(if verifying-permission?
|
||||||
|
"Verifying local network access..."
|
||||||
|
"Verify local network access")]]]]))
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[react-native.safe-area :as safe-area]
|
[react-native.safe-area :as safe-area]
|
||||||
[status-im.common.check-before-syncing.view :as check-before-syncing]
|
[status-im.common.check-before-syncing.view :as check-before-syncing]
|
||||||
|
[status-im.common.enable-access-to-local-network.view :as enable-access-to-local-network]
|
||||||
[status-im.common.events-helper :as events-helper]
|
[status-im.common.events-helper :as events-helper]
|
||||||
[status-im.common.resources :as resources]
|
[status-im.common.resources :as resources]
|
||||||
[status-im.config :as config]
|
[status-im.config :as config]
|
||||||
@@ -24,8 +25,10 @@
|
|||||||
[]
|
[]
|
||||||
(rf/dispatch
|
(rf/dispatch
|
||||||
[:show-bottom-sheet
|
[:show-bottom-sheet
|
||||||
{:content (fn [] [check-before-syncing/view
|
{:content (fn []
|
||||||
{:on-submit navigate-to-sign-in-by-syncing}])
|
[enable-access-to-local-network/view]
|
||||||
|
;[check-before-syncing/view {:on-submit navigate-to-sign-in-by-syncing}]
|
||||||
|
)
|
||||||
:shell? true}]))
|
:shell? true}]))
|
||||||
|
|
||||||
(defn- navigate-to-sign-in-by-recovery-phrase
|
(defn- navigate-to-sign-in-by-recovery-phrase
|
||||||
|
|||||||
@@ -53,4 +53,3 @@
|
|||||||
|
|
||||||
(def login-profile-card
|
(def login-profile-card
|
||||||
{:margin-bottom 20})
|
{:margin-bottom 20})
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
[status-im.contexts.profile.config :as profile.config]
|
[status-im.contexts.profile.config :as profile.config]
|
||||||
[status-im.contexts.syncing.utils :as sync-utils]
|
[status-im.contexts.syncing.utils :as sync-utils]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
|
[oops.core :as oops]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]
|
[utils.re-frame :as rf]
|
||||||
[utils.security.core :as security]
|
[utils.security.core :as security]
|
||||||
@@ -67,19 +68,48 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx :syncing/clear-syncing-fallback-flow clear-syncing-fallback-flow)
|
(re-frame/reg-event-fx :syncing/clear-syncing-fallback-flow clear-syncing-fallback-flow)
|
||||||
|
|
||||||
(rf/defn preflight-outbound-check-for-local-pairing
|
#_(rf/defn preflight-outbound-check-for-local-pairing
|
||||||
{:events [:syncing/preflight-outbound-check]}
|
{:events [:syncing/preflight-outbound-check]}
|
||||||
[_ set-checks-passed]
|
[_ set-checks-passed]
|
||||||
(let [callback
|
(let [callback (fn [raw-response]
|
||||||
(fn [raw-response]
|
(log/info "Local pairing preflight check"
|
||||||
(log/info "Local pairing preflight check"
|
{:response raw-response
|
||||||
{:response raw-response
|
:event :syncing/preflight-outbound-check})
|
||||||
:event :syncing/preflight-outbound-check})
|
(let [^js response-js (transforms/json->js raw-response)
|
||||||
(let [^js response-js (transforms/json->js raw-response)
|
error (transforms/js->clj (.-error response-js))]
|
||||||
error (transforms/js->clj (.-error response-js))]
|
(set-checks-passed (empty? error))))]
|
||||||
(set-checks-passed (empty? error))))]
|
|
||||||
(native-module/local-pairing-preflight-outbound-check callback)))
|
(native-module/local-pairing-preflight-outbound-check callback)))
|
||||||
|
|
||||||
|
(rf/reg-fx
|
||||||
|
:effects/ios-local-pairing-preflight-outbound-check
|
||||||
|
native-module/local-pairing-preflight-outbound-check)
|
||||||
|
|
||||||
|
(defn- outbound-check [set-permission-granted raw-response]
|
||||||
|
(log/debug "Local pairing preflight check"
|
||||||
|
{:response raw-response
|
||||||
|
:event :syncing/preflight-outbound-check})
|
||||||
|
(def --x raw-response)
|
||||||
|
(let [error? (-> raw-response transforms/json->js (oops/oget :error) seq)]
|
||||||
|
(if error?
|
||||||
|
(rf/dispatch [:toasts/upsert
|
||||||
|
{:type :negative
|
||||||
|
:theme :dark
|
||||||
|
:text "Failed to verify local network access"}])
|
||||||
|
(set-permission-granted true))
|
||||||
|
(rf/dispatch [:syncing/set-preflight-outbound-checked])))
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
:syncing/preflight-outbound-check
|
||||||
|
(fn [{db :db} [set-permission-granted]]
|
||||||
|
{:db (assoc db :syncing/checking-preflight-outbound? true)
|
||||||
|
:fx [[:effects/ios-local-pairing-preflight-outbound-check
|
||||||
|
(partial outbound-check set-permission-granted)]]}))
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
:syncing/set-preflight-outbound-checked
|
||||||
|
(fn [{db :db}]
|
||||||
|
{:db (dissoc db :syncing/checking-preflight-outbound?)}))
|
||||||
|
|
||||||
(rf/defn initiate-local-pairing-with-connection-string
|
(rf/defn initiate-local-pairing-with-connection-string
|
||||||
{:events [:syncing/input-connection-string-for-bootstrapping]}
|
{:events [:syncing/input-connection-string-for-bootstrapping]}
|
||||||
[_ connection-string]
|
[_ connection-string]
|
||||||
|
|||||||
@@ -194,7 +194,7 @@
|
|||||||
|
|
||||||
(defn- scan-qr-code-tab
|
(defn- scan-qr-code-tab
|
||||||
[qr-view-finder]
|
[qr-view-finder]
|
||||||
(if (and @preflight-check-passed?
|
(if (and ;@preflight-check-passed?
|
||||||
@camera-permission-granted?
|
@camera-permission-granted?
|
||||||
(boolean (not-empty qr-view-finder)))
|
(boolean (not-empty qr-view-finder)))
|
||||||
[viewfinder qr-view-finder]
|
[viewfinder qr-view-finder]
|
||||||
@@ -276,7 +276,7 @@
|
|||||||
app-state-listener (.addEventListener rn/app-state "change" set-torch-off-fn)]
|
app-state-listener (.addEventListener rn/app-state "change" set-torch-off-fn)]
|
||||||
#(.remove app-state-listener)))
|
#(.remove app-state-listener)))
|
||||||
|
|
||||||
(defn f-view
|
(defn view
|
||||||
[_]
|
[_]
|
||||||
(let [insets (safe-area/get-insets)
|
(let [insets (safe-area/get-insets)
|
||||||
qr-code-succeed? (reagent/atom false)
|
qr-code-succeed? (reagent/atom false)
|
||||||
@@ -358,7 +358,7 @@
|
|||||||
(set-rescan-timeout))
|
(set-rescan-timeout))
|
||||||
:set-rescan-timeout set-rescan-timeout}])
|
:set-rescan-timeout set-rescan-timeout}])
|
||||||
[rn/view {:style (style/root-container (:top insets))}
|
[rn/view {:style (style/root-container (:top insets))}
|
||||||
[:f> header
|
[header
|
||||||
{:active-tab active-tab
|
{:active-tab active-tab
|
||||||
:title title
|
:title title
|
||||||
:title-opacity title-opacity
|
:title-opacity title-opacity
|
||||||
@@ -392,7 +392,3 @@
|
|||||||
:container-style (style/camera-flash-button @qr-view-finder)
|
:container-style (style/camera-flash-button @qr-view-finder)
|
||||||
:on-press #(swap! torch? not)}
|
:on-press #(swap! torch? not)}
|
||||||
flashlight-icon])]]))))
|
flashlight-icon])]]))))
|
||||||
|
|
||||||
(defn view
|
|
||||||
[props]
|
|
||||||
[:f> f-view props])
|
|
||||||
|
|||||||
@@ -884,6 +884,7 @@
|
|||||||
"enable": "Enable",
|
"enable": "Enable",
|
||||||
"enable-access-to-camera": "Enable access to camera",
|
"enable-access-to-camera": "Enable access to camera",
|
||||||
"enable-access-to-local-network": "Enable access to local network",
|
"enable-access-to-local-network": "Enable access to local network",
|
||||||
|
"enable-access-to-local-network-description": "To pair with your other device in the network",
|
||||||
"enable-all": "Enable all",
|
"enable-all": "Enable all",
|
||||||
"enable-biometrics": "Enable biometrics",
|
"enable-biometrics": "Enable biometrics",
|
||||||
"enable-camera": "Enable camera",
|
"enable-camera": "Enable camera",
|
||||||
|
|||||||
Reference in New Issue
Block a user