Fix Android back button issues on intro screens
Signed-off-by: Vitaliy Vlasov <siphiuel@gmail.com>
This commit is contained in:
parent
c75d5b24f6
commit
8c9af1ab51
|
@ -75,7 +75,7 @@
|
|||
(navigation/navigate-to-cofx :intro-wizard nil))
|
||||
|
||||
(fx/merge {:db (dissoc db :intro-wizard)}
|
||||
(navigation/navigate-to-clean (if first-time-setup? :intro :multiaccounts) nil)))))
|
||||
(navigation/navigate-back)))))
|
||||
|
||||
(fx/defn exit-wizard [{:keys [db] :as cofx}]
|
||||
(fx/merge {:db (dissoc db :intro-wizard)}
|
||||
|
|
|
@ -210,8 +210,11 @@
|
|||
|
||||
(fx/defn cancel-pressed
|
||||
{:events [:recover.ui/cancel-pressed]}
|
||||
[cofx]
|
||||
(navigation/navigate-back cofx))
|
||||
[{:keys [db] :as cofx}]
|
||||
;; Workaround for multiple Cancel button clicks
|
||||
;; that can break navigation tree
|
||||
(when-not (#{:multiaccounts :login} (:view-id db))
|
||||
(navigation/navigate-back cofx)))
|
||||
|
||||
(fx/defn select-storage-next-pressed
|
||||
{:events [:recover.select-storage.ui/next-pressed]
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
(:require [status-im.ui.components.react :as react]
|
||||
[status-im.ui.screens.keycard.styles :as styles]
|
||||
[status-im.ui.screens.keycard.views :as views]
|
||||
[status-im.ui.components.toolbar.actions :as actions]
|
||||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||
|
@ -22,7 +23,9 @@
|
|||
[toolbar/toolbar
|
||||
{:transparent? true
|
||||
:style {:margin-top 32}}
|
||||
toolbar/default-nav-back
|
||||
(toolbar/nav-button
|
||||
(actions/back #(re-frame/dispatch
|
||||
[:recover.ui/cancel-pressed])))
|
||||
nil]
|
||||
[react/view {:flex 1
|
||||
:flex-direction :column
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
{:style {:border-bottom-width 0
|
||||
:margin-top 0}}
|
||||
(when can-navigate-back?
|
||||
[toolbar/nav-button (act/back #(re-frame/dispatch [:navigate-to-clean :multiaccounts]))])
|
||||
[toolbar/nav-button (act/back #(re-frame/dispatch [:navigate-reset :multiaccounts]))])
|
||||
nil])
|
||||
|
||||
(defn login-multiaccount [password-text-input]
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
:key-fn :address
|
||||
:render-fn (fn [multiaccount] [multiaccount-view multiaccount])}]]
|
||||
[react/view
|
||||
[components.common/button {:on-press #(re-frame/dispatch [:multiaccounts.create.ui/intro-wizard true])
|
||||
[components.common/button {:on-press #(re-frame/dispatch [:multiaccounts.create.ui/intro-wizard false])
|
||||
:button-style styles/bottom-button
|
||||
:label (i18n/label :t/generate-a-new-key)}]
|
||||
[react/view styles/bottom-button-container
|
||||
|
|
|
@ -14,16 +14,6 @@
|
|||
|
||||
;; public fns
|
||||
|
||||
(fx/defn navigate-to-clean
|
||||
[{:keys [db]} view-id screen-params]
|
||||
(log/debug "current view-id " (:view-id db)
|
||||
"changing to " view-id)
|
||||
(let [db (cond-> db
|
||||
(seq screen-params)
|
||||
(assoc-in [:navigation/screen-params view-id] screen-params))]
|
||||
{:db (push-view db view-id)
|
||||
::navigate-to-clean view-id}))
|
||||
|
||||
(fx/defn navigate-forget
|
||||
[{:keys [db]} view-id]
|
||||
{:db (assoc db :view-id view-id)})
|
||||
|
@ -57,9 +47,10 @@
|
|||
|
||||
(fx/defn navigate-reset
|
||||
[{:keys [db]} {:keys [index actions] :as config}]
|
||||
{:db (assoc db :view-id
|
||||
(:routeName (get actions index)))
|
||||
::navigate-reset config})
|
||||
(let [view-id (:routeName (get actions index))]
|
||||
{:db (assoc db :view-id view-id
|
||||
:navigation-stack (list view-id))
|
||||
::navigate-reset config}))
|
||||
|
||||
(def unload-data-interceptor
|
||||
(re-frame/->interceptor
|
||||
|
@ -92,14 +83,6 @@
|
|||
(log/debug :navigate-reset config)
|
||||
(navigation/navigate-reset config)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::navigate-to-clean
|
||||
(fn [view-id]
|
||||
(log/debug :navigate-to-clean view-id)
|
||||
(navigation/navigate-reset
|
||||
{:index 0
|
||||
:actions [{:routeName view-id}]})))
|
||||
|
||||
;; event handlers
|
||||
|
||||
(handlers/register-handler-fx
|
||||
|
@ -132,6 +115,12 @@
|
|||
(fn [cofx _]
|
||||
(navigate-back cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-reset
|
||||
(fn [cofx [_ view-id]]
|
||||
(navigate-reset cofx {:index 0
|
||||
:actions [{:routeName view-id}]})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-to-clean
|
||||
(fn [cofx [_ view-id params]]
|
||||
|
|
|
@ -48,15 +48,17 @@
|
|||
(defn login-stack [view-id]
|
||||
{:name :login-stack
|
||||
:screens (cond-> [:login
|
||||
:multiaccounts
|
||||
:intro-wizard
|
||||
:progress
|
||||
:keycard-recovery-intro
|
||||
:create-multiaccount
|
||||
:recover-multiaccount
|
||||
:recover-multiaccount-enter-phrase
|
||||
:recover-multiaccount-select-storage
|
||||
:recover-multiaccount-enter-password
|
||||
:recover-multiaccount-confirm-password
|
||||
:recover-multiaccount-success
|
||||
:multiaccounts]
|
||||
:recover-multiaccount-success]
|
||||
|
||||
config/hardwallet-enabled?
|
||||
(concat [:hardwallet-authentication-method
|
||||
|
@ -71,8 +73,8 @@
|
|||
:hardwallet-setup
|
||||
:hardwallet-success]))
|
||||
:config (if
|
||||
;; add view-id here if you'd like that view to be
|
||||
;; first view when app is started
|
||||
;; add view-id here if you'd like that view to be
|
||||
;; first view when app is started
|
||||
(#{:login :progress :multiaccounts :enter-pin-login :keycard-login-pin} view-id)
|
||||
{:initialRouteName view-id}
|
||||
{:initialRouteName :login})})
|
||||
|
|
Loading…
Reference in New Issue