Skip to content

Commit

Permalink
Onboarding UI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Vlasov committed Sep 26, 2019
1 parent acd7e56 commit f97f6fd
Show file tree
Hide file tree
Showing 26 changed files with 671 additions and 645 deletions.
2 changes: 1 addition & 1 deletion src/status_im/biometric_auth/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@
(re-frame/reg-fx
:biometric-auth/authenticate
(fn [[cb options]]
(authenticate #(cb %) options)))
(authenticate #(cb %) options)))
75 changes: 46 additions & 29 deletions src/status_im/multiaccounts/create/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[re-frame.core :as re-frame]
[status-im.constants :as constants]
[status-im.ethereum.core :as ethereum]
[status-im.i18n :as i18n]
[status-im.multiaccounts.db :as db]
[status-im.native-module.core :as status]
[status-im.node.core :as node]
[status-im.ui.components.colors :as colors]
Expand All @@ -25,8 +27,7 @@
:select-key-storage 3
:create-code 4
:confirm-code 5
:enable-fingerprint 6
:enable-notifications 7})
:enable-notifications 6})

(defn dec-step [step]
(let [inverted (map-invert step-kw-to-num)]
Expand Down Expand Up @@ -58,35 +59,50 @@
(fx/defn intro-wizard
{:events [:multiaccounts.create.ui/intro-wizard]}
[{:keys [db] :as cofx} first-time-setup?]
(fx/merge {:db (assoc db :intro-wizard {:step :generate-key
(fx/merge cofx
{:db (assoc db :intro-wizard {:step :generate-key
:weak-password? true
:back-action :intro-wizard/step-back-pressed
:forward-action :intro-wizard/step-forward-pressed
:encrypt-with-password? true
:first-time-setup? first-time-setup?})}
(navigation/navigate-to-cofx :intro-wizard nil)))
:first-time-setup? first-time-setup?})
::navigation/add-wizard-back-listener :intro-wizard/step-back-pressed}
(navigation/navigate-to-cofx :create-multiaccount-generate-key nil)))

(fx/defn intro-step-back
{:events [:intro-wizard/step-back-pressed]}
[{:keys [db] :as cofx}]
[{:keys [db] :as cofx} show-alert?]
(let [step (get-in db [:intro-wizard :step])
first-time-setup? (get-in db [:intro-wizard :first-time-setup?])]
(if (not= :generate-key step)
(fx/merge {:db (cond-> (assoc-in db [:intro-wizard :step] (dec-step step))
(#{:create-code :confirm-code} step)
(update :intro-wizard assoc :weak-password? true :key-code nil)
(= step :confirm-code)
(assoc-in [:intro-wizard :confirm-failure?] false))}
(navigation/navigate-to-cofx :intro-wizard nil))

(fx/merge {:db (dissoc db :intro-wizard)}
(navigation/navigate-back)))))
;; Cannot go back after account has been created
;; and we're on "Enable notifications" step
(when-not (= :enable-notifications step)
(if show-alert?
(utils/show-question
(i18n/label :t/are-you-sure-to-cancel)
(i18n/label :t/you-will-start-from-scratch)
#(re-frame/dispatch [:intro-wizard/step-back-pressed]))
(fx/merge cofx
(when-not (= :generate-key step)
{:db (cond-> (assoc-in db [:intro-wizard :step] (dec-step step))
(#{:create-code :confirm-code} step)
(update :intro-wizard assoc :weak-password? true :key-code nil)
(= step :confirm-code)
(assoc-in [:intro-wizard :confirm-failure?] false))})
(when (= :generate-key-step)
{:db (dissoc db :intro-wizard)
::navigation/remove-wizard-back-listener :intro-wizard/step-back-pressed})
navigation/navigate-back)))))

(fx/defn exit-wizard [{:keys [db] :as cofx}]
(fx/merge {:db (dissoc db :intro-wizard)}
(fx/merge cofx
{:db (dissoc db :intro-wizard)
::navigation/remove-wizard-back-listener :intro-wizard/step-back-pressed}
(navigation/navigate-to-cofx :home nil)))

(fx/defn init-key-generation
[{:keys [db] :as cofx}]
{:db (assoc-in db [:intro-wizard :generating-keys?] true)
{:db (assoc-in db [:intro-wizard :processing?] true)
:intro-wizard/start-onboarding nil})

(fx/defn on-confirm-failure [{:keys [db] :as cofx}]
Expand All @@ -105,8 +121,7 @@
(let [key-code (get-in db [:intro-wizard :key-code])]
{:db (update db :intro-wizard
assoc :stored-key-code key-code
:key-code nil
:step :confirm-code)}))
:key-code nil)}))

(fx/defn intro-step-forward
{:events [:intro-wizard/step-forward-pressed]}
Expand All @@ -126,9 +141,6 @@
(= step :generate-key)
(init-key-generation cofx)

(= step :create-code)
(store-key-code cofx)

(and (= step :confirm-code)
(not (:multiaccounts/login db))
(not processing?))
Expand All @@ -140,9 +152,14 @@
(= :advanced selected-storage-type))
{:dispatch [:keycard/start-onboarding-flow]}

:else {:db (update db :intro-wizard
assoc :processing? false
:step (inc-step step))})))
:else (let [next-step (inc-step step)]
(fx/merge cofx
{:db (update db :intro-wizard
assoc :processing? false
:step next-step)}
(when (= step :create-code)
store-key-code)
(navigation/navigate-to-cofx (->> next-step name (str "create-multiaccount-") keyword) nil))))))

(defn prepare-accounts-data
[multiaccount]
Expand Down Expand Up @@ -243,12 +260,12 @@
{:db (update db :intro-wizard
(fn [data]
(-> data
(dissoc :generating-keys?)
(dissoc :processing?)
(assoc :multiaccounts result
:selected-storage-type :default
:selected-id (-> result first :id)
:step :choose-key))))}
(navigation/navigate-to-cofx :intro-wizard nil)))
(navigation/navigate-to-cofx :create-multiaccount-choose-key nil)))

(fx/defn on-key-selected
{:events [:intro-wizard/on-key-selected]}
Expand Down Expand Up @@ -285,7 +302,7 @@
(let [encrypt-with-password? (get-in db [:intro-wizard :encrypt-with-password?])]
{:db (update db :intro-wizard assoc :key-code new-key-code
:confirm-failure? false
:weak-password? (< (count new-key-code) 6))}))
:weak-password? (not (db/valid-length? new-key-code)))}))

(re-frame/reg-cofx
::get-signing-phrase
Expand Down
7 changes: 1 addition & 6 deletions src/status_im/multiaccounts/login/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@
(when platform/desktop?
(chat-model/update-dock-badge-label)))))

(defn- recovering-multiaccount? [cofx]
(boolean (get-in cofx [:db :multiaccounts/recover])))

(fx/defn create-only-events
[{:keys [db] :as cofx} address password]
(let [{:keys [multiaccount :networks/networks :networks/current-network]} db]
Expand Down Expand Up @@ -213,7 +210,6 @@
:mailserver-ranges {}
:mailserver-topics {}
:default-mailserver true})
(mobile-network/on-network-status-change)
(chaos-mode/check-chaos-mode)
(when-not platform/desktop?
(initialize-wallet)))))
Expand All @@ -224,8 +220,7 @@
(fx/defn multiaccount-login-success
[{:keys [db] :as cofx}]
(let [{:keys [address password save-password? name photo-path creating?]} (:multiaccounts/login db)
step (get-in db [:intro-wizard :step])
recovering? (recovering-multiaccount? cofx)
recovering? (get-in db [:intro-wizard :recovering?])
login-only? (not (or creating?
recovering?
(keycard-setup? cofx)))
Expand Down
Loading

0 comments on commit f97f6fd

Please sign in to comment.