fix NFC detection

Signed-off-by: Dmitry Novotochinov <dmitry.novot@gmail.com>
This commit is contained in:
Dmitry Novotochinov 2019-08-13 12:42:00 +03:00
parent c2e17698eb
commit c2f646b8bd
No known key found for this signature in database
GPG Key ID: 43D1DAF5AD39C927
4 changed files with 32 additions and 22 deletions

View File

@ -618,6 +618,19 @@
(navigation/navigate-to-cofx :keycard-onboarding-start nil))
(navigation/navigate-to-cofx :keycard-nfc-on nil)))))
(fx/defn proceed-to-login
[{:keys [db] :as cofx}]
(let [{:keys [card-connected? nfc-enabled?]} (:hardwallet db)]
(if nfc-enabled?
(if card-connected?
(login-with-keycard cofx)
(fx/merge cofx
{:db (-> db
(assoc-in [:hardwallet :on-card-connected] :hardwallet/get-application-info)
(assoc-in [:hardwallet :on-card-read] :hardwallet/login-with-keycard))}
(navigation/navigate-to-cofx :keycard-login-connect-card nil)))
(navigation/navigate-to-cofx cofx :keycard-nfc-on nil))))
(fx/defn open-nfc-settings-pressed
{:events [:keycard.onboarding.nfc-on/open-nfc-settings-pressed]}
[_]
@ -626,15 +639,19 @@
(fx/defn on-check-nfc-enabled-success
{:events [:hardwallet.callback/check-nfc-enabled-success]}
[{:keys [db] :as cofx} nfc-enabled?]
(let [flow (get-in db [:hardwallet :flow])]
(let [flow (get-in db [:hardwallet :flow])
login? (= :login (get-in db [:hardwallet :pin :enter-step]))]
(fx/merge cofx
{:db (assoc-in db [:hardwallet :nfc-enabled?] nfc-enabled?)}
(when (and nfc-enabled?
(= (:view-id db)
:keycard-nfc-on))
(if (= flow :import)
(navigation/navigate-to-cofx :keycard-recovery-start nil)
(navigation/navigate-to-cofx :keycard-onboarding-start nil))))))
(if flow
(if (= flow :import)
(navigation/navigate-to-cofx :keycard-recovery-start nil)
(navigation/navigate-to-cofx :keycard-onboarding-start nil))
(when login?
(proceed-to-login)))))))
(fx/defn success-button-pressed [cofx]
(navigation/navigate-to-cofx cofx :home nil))
@ -904,8 +921,10 @@
(pair)))))
(fx/defn return-back-from-nfc-settings [{:keys [db]}]
(when (= (:view-id db)
:keycard-onboarding-nfc-on)
(when (or (get-in db [:hardwallet :flow])
(get-in db [:hardwallet :pin :enter-step])
(get-in db [:hardwallet :on-card-connected])
(get-in db [:hardwallet :on-card-read]))
{:hardwallet/check-nfc-enabled nil}))
(defn- proceed-to-pin-confirmation [fx]
@ -1148,17 +1167,6 @@
:original []
:confirmation []}))
(fx/defn proceed-to-login
[{:keys [db] :as cofx}]
(let [card-connected? (get-in db [:hardwallet :card-connected?])]
(if card-connected?
(login-with-keycard cofx)
(fx/merge cofx
{:db (-> db
(assoc-in [:hardwallet :on-card-connected] :hardwallet/get-application-info)
(assoc-in [:hardwallet :on-card-read] :hardwallet/login-with-keycard))}
(navigation/navigate-to-cofx :keycard-login-connect-card nil)))))
(fx/defn navigate-to-connect-screen
[{:keys [db] :as cofx} screen-name]
(let [modal? (get-in db [:navigation/screen-params :wallet-send-modal-stack :modal?])]

View File

@ -15,8 +15,9 @@
{:component-did-mount (animations/animate-tooltip bottom-value bottom-anim-value opacity-value -10)}
[react/view (merge styles/tooltip-container container-style)
[react/animated-view {:style (styles/tooltip-animated bottom-anim-value opacity-value)}
[react/view (styles/tooltip-text-container color)
[react/text {:style (styles/tooltip-text font-size)} label]]
(when label
[react/view (styles/tooltip-text-container color)
[react/text {:style (styles/tooltip-text font-size)} label]])
[vector-icons/icon :icons/tooltip-triangle (assoc
styles/tooltip-triangle
:color color)]]]))

View File

@ -28,7 +28,8 @@
name]]
[react/text {:style styles/multiaccount-badge-pub-key-text}
(utils/get-shortened-address public-key)]]
(if keycard-instance-uid
[react/view {:flex 1}]
(when keycard-instance-uid
[react/view {:justify-content :center
:align-items :center
:margin-right 7
@ -40,8 +41,7 @@
:border-color (colors/alpha colors/black 0.1)}
[react/image {:source (resources/get-image :keycard-key)
:style {:width 11
:height 19}}]]
[react/view {:flex 1}])
:height 19}}]])
[icons/icon :main-icons/next {:color (colors/alpha colors/gray 0.4)}]]])
(defview multiaccounts []

View File

@ -63,6 +63,7 @@
:hardwallet-connect
:keycard-login-pin
:keycard-login-connect-card
:keycard-nfc-on
:keycard-blank
:keycard-wrong
:keycard-unpaired