Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboarding remove identifiers code and refactor create_or_sync_profile screen #21668

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns status-im.contexts.onboarding.create-or-sync-profile.style
(ns status-im.contexts.onboarding.create-profile.style
(:require
[quo.foundations.colors :as colors]))

Expand Down
100 changes: 100 additions & 0 deletions src/status_im/contexts/onboarding/create_profile/view.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
(ns status-im.contexts.onboarding.create-profile.view
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored the create-or-sync-profile screen and split it into two separate screens:
('Create Profile' and 'Log In - as per figma)

(:require
[quo.core :as quo]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.common.events-helper :as events-helper]
[status-im.common.resources :as resources]
[status-im.config :as config]
[status-im.contexts.onboarding.create-profile.style :as style]
[status-im.contexts.onboarding.getting-started-doc.view :as getting-started-doc]
[utils.debounce :as debounce]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

(defn- navigate-to-create-profile-password
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don we have this in every control ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @flexsurfer, for reviewing the PR.

Are you asking if we need the create-profile-password in both the create-profile and login flows? Yes, we do.

For the create profile flow, we are directly navigating to the create-profile-password screen here. However, for the login flow, navigation to the password screen occurs after the seed phrase is validated.

[]
(debounce/throttle-and-dispatch
[:onboarding/navigate-to-create-profile-password]
1000))

(defn- navigate-to-sign-in-by-recovery-phrase
[]
(rf/dispatch [:syncing/clear-syncing-fallback-flow])
(rf/dispatch [:onboarding/navigate-to-sign-in-by-seed-phrase :screen/onboarding.create-profile]))

(defn- option-card-max-height
[window-height]
(- window-height
(* 2 56) ;; two other list items
(* 2 16) ;; spacing between items
220)) ;; extra spacing (top bar)

(defn- start-fresh-main-card
[window-height]
[quo/small-option-card
{:variant :main
:title (i18n/label :t/start-fresh)
:subtitle (i18n/label :t/start-fresh-subtitle)
:button-label (i18n/label :t/lets-go)
:accessibility-label :start-fresh-main-card
:image (resources/get-image :generate-keys)
:max-height (option-card-max-height window-height)
:on-press navigate-to-create-profile-password}])

(defn- use-recovery-phrase-icon-card
[]
[quo/small-option-card
{:variant :icon
:title (i18n/label :t/use-a-recovery-phrase)
:subtitle (i18n/label :t/use-a-recovery-phrase-subtitle)
:accessibility-label :use-a-recovery-phrase-icon-card
:image (resources/get-image :ethereum-address)
:on-press navigate-to-sign-in-by-recovery-phrase}])

(defn- use-empty-keycard-icon-card
[]
[quo/small-option-card
{:variant :icon
:title (i18n/label :t/use-an-empty-keycard)
:subtitle (i18n/label :t/use-an-empty-keycard-subtitle)
:accessibility-label :use-an-empty-keycard-icon-card
:image (resources/get-image :use-keycard)
:on-press #(rf/dispatch [:open-modal :screen/keycard.create-profile])}])

(defn- navigate-to-quo-preview
[]
(rf/dispatch [:navigate-to :quo-preview]))

(defn view
[]
(let [{:keys [top]} (safe-area/get-insets)
window-height (rf/sub [:dimensions/window-height])]
[rn/view {:style style/content-container}
[quo/page-nav
{:margin-top top
:type :no-title
:background :blur
:icon-name :i/arrow-left
:on-press events-helper/navigate-back
:right-side [{:icon-name :i/info
:on-press getting-started-doc/show-as-bottom-sheet}
(when config/quo-preview-enabled?
{:icon-name :i/reveal-whitelist
:on-press navigate-to-quo-preview})]}]
[rn/view {:style style/options-container}
[quo/text
{:style style/title
:size :heading-1
:weight :semi-bold}
(i18n/label :t/create-profile)]
[start-fresh-main-card window-height]
[rn/view {:style style/subtitle-container}
[quo/text
{:style style/subtitle
:size :paragraph-2
:weight :medium}
(i18n/label :t/other-options)]]
[use-recovery-phrase-icon-card]
[rn/view {:style style/space-between-suboptions}]
[use-empty-keycard-icon-card]]]))
25 changes: 7 additions & 18 deletions src/status_im/contexts/onboarding/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
[:dispatch [:profile/show-testnet-mode-banner-if-enabled]]
[:dispatch [:universal-links/process-stored-event]]]}))

(rf/reg-event-fx
:onboarding/profile-data-set
(fn [{:keys [db]} [onboarding-data]]
(let [navigate-from-screen (get db
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]
{:db (update db :onboarding/profile merge onboarding-data)
:fx [[:dispatch
[:navigate-to-within-stack
[:screen/onboarding.create-profile-password navigate-from-screen]]]]})))

(rf/defn enable-biometrics
{:events [:onboarding/enable-biometrics]}
[_]
Expand Down Expand Up @@ -61,7 +50,7 @@
[:screen/onboarding.enable-notifications
(get db
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]]}))
:screen/onboarding.create-profile)]]}))

(rf/defn biometrics-done
{:events [:onboarding/biometrics-done]}
Expand Down Expand Up @@ -93,7 +82,7 @@
[:screen/onboarding.preparing-status
(get db
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]]]
:screen/onboarding.create-profile)]]]
(when-not syncing-account-recovered?
[:dispatch [:syncing/clear-syncing-installation-id]])
(if seed-phrase
Expand All @@ -115,7 +104,7 @@
(let [biometric-supported-type (get-in db [:biometrics :supported-type])
from-screen (get db
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]
:screen/onboarding.create-profile)]
{:db (-> db
(assoc-in [:onboarding/profile :password] masked-password)
(assoc-in [:onboarding/profile :auth-method] constants/auth-method-password))
Expand All @@ -138,7 +127,7 @@
(let [next-screen :screen/onboarding.create-profile-password
from-screen (get db
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]
:screen/onboarding.create-profile)]
(if (contains? (:profile/profiles-overview db) key-uid)
{:fx [[:effects.utils/show-confirmation
{:title (i18n/label :t/multiaccount-exists-title)
Expand All @@ -155,21 +144,21 @@
:fx [[:dispatch [:navigate-to-within-stack [next-screen from-screen]]]]}))))

(rf/reg-event-fx
:onboarding/navigate-to-create-profile
:onboarding/navigate-to-create-profile-password
(fn [{:keys [db]}]
{:db (-> db
(assoc-in [:onboarding/profile :color] (rand-nth colors/account-colors))
(update :onboarding/profile dissoc :image-path))
:fx [[:dispatch
[:navigate-to-within-stack
[:screen/onboarding.create-profile-password :screen/onboarding.new-to-status]]]]}))
[:screen/onboarding.create-profile-password :screen/onboarding.create-profile]]]]}))

(rf/reg-event-fx :onboarding/navigate-to-sign-in-by-syncing
(fn [{:keys [db]}]
;; Restart the flow
{:db (dissoc db :onboarding/profile)
:dispatch [:navigate-to-within-stack
[:screen/onboarding.sign-in-intro :screen/onboarding.sync-or-recover-profile]]}))
[:screen/onboarding.sign-in-intro :screen/onboarding.log-in]]}))

(rf/reg-event-fx :onboarding/set-auth-method
(fn [{:keys [db]} [auth-method]]
Expand Down

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions src/status_im/contexts/onboarding/identifiers/style.cljs

This file was deleted.

Loading