Bring the seedphrase backup flow to the new settings #19554 (#19887)

This commit is contained in:
flexsurfer 2024-05-07 13:44:31 +02:00 committed by GitHub
parent 0c6bb61ebe
commit 45129b8244
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 58 additions and 50 deletions

View File

@ -2,7 +2,6 @@
(:require (:require
[legacy.status-im.multiaccounts.reset-password.core :as reset-password] [legacy.status-im.multiaccounts.reset-password.core :as reset-password]
[legacy.status-im.multiaccounts.update.core :as multiaccounts.update] [legacy.status-im.multiaccounts.update.core :as multiaccounts.update]
[legacy.status-im.ui.components.common.common :as components.common]
[legacy.status-im.ui.components.core :as components] [legacy.status-im.ui.components.core :as components]
[legacy.status-im.ui.components.list.item :as list.item] [legacy.status-im.ui.components.list.item :as list.item]
[legacy.status-im.ui.components.react :as react] [legacy.status-im.ui.components.react :as react]
@ -29,8 +28,7 @@
(views/defview privacy-and-security (views/defview privacy-and-security
[] []
(views/letsubs [{:keys [mnemonic (views/letsubs [{:keys [preview-privacy?
preview-privacy?
messages-from-contacts-only messages-from-contacts-only
webview-allow-permission-requests? webview-allow-permission-requests?
opensea-enabled? opensea-enabled?
@ -45,16 +43,6 @@
:icon-name :i/close :icon-name :i/close
:on-press #(rf/dispatch [:navigate-back])}] :on-press #(rf/dispatch [:navigate-back])}]
[react/scroll-view {:padding-vertical 8} [react/scroll-view {:padding-vertical 8}
[components/list-header (i18n/label :t/security)]
[list.item/list-item
{:size :small
:title (i18n/label :t/back-up-seed-phrase)
:accessibility-label :back-up-recovery-phrase-button
:disabled (not mnemonic)
:chevron (boolean mnemonic)
:accessory (when mnemonic [components.common/counter {:size 22} 1])
:on-press #(re-frame/dispatch [:navigate-to :backup-seed])}]
[separator]
[components/list-header (i18n/label :t/privacy)] [components/list-header (i18n/label :t/privacy)]
[list.item/list-item [list.item/list-item
{:size :small {:size :small

View File

@ -12,8 +12,12 @@
[legacy.status-im.ui.screens.profile.seed.styles :as styles] [legacy.status-im.ui.screens.profile.seed.styles :as styles]
[legacy.status-im.utils.utils :as utils] [legacy.status-im.utils.utils :as utils]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[utils.i18n :as i18n])) [utils.i18n :as i18n]
[utils.re-frame :as rf]
[react-native.platform :as platform]
[react-native.safe-area :as safe-area]))
(def steps-numbers (def steps-numbers
{:intro 1 {:intro 1
@ -153,13 +157,17 @@
[quo/button {:on-press #(re-frame/dispatch [:navigate-back])} [quo/button {:on-press #(re-frame/dispatch [:navigate-back])}
(i18n/label :t/ok-got-it)]]]) (i18n/label :t/ok-got-it)]]])
(defview backup-seed (defn backup-seed
[] []
(letsubs [current-multiaccount [:profile/profile] (let [current-multiaccount (rf/sub [:profile/profile])
{:keys [step first-word second-word error word]} [:my-profile/recovery]] {:keys [step first-word
[react/keyboard-avoiding-view second-word error word]} (rf/sub [:my-profile/recovery])
footer-container-padding (+ (safe-area/get-top)
(rf/sub [:alert-banners/top-margin])
20)]
[rn/keyboard-avoiding-view
{:style {:flex 1} {:style {:flex 1}
:ignore-offset true} :keyboard-vertical-offset (if platform/ios? footer-container-padding 0)}
[topbar/topbar [topbar/topbar
{:title (i18n/label :t/backup-recovery-phrase) {:title (i18n/label :t/backup-recovery-phrase)
:subtitle (i18n/label :t/step-i-of-n {:step (steps-numbers step) :number 3}) :subtitle (i18n/label :t/step-i-of-n {:step (steps-numbers step) :number 3})

View File

@ -1,6 +1,5 @@
(ns legacy.status-im.ui.screens.profile.user.views (ns legacy.status-im.ui.screens.profile.user.views
(:require (:require
[legacy.status-im.ui.components.common.common :as components.common]
[legacy.status-im.ui.components.core :as components] [legacy.status-im.ui.components.core :as components]
[legacy.status-im.ui.components.list.item :as list.item] [legacy.status-im.ui.components.list.item :as list.item]
[quo.core :as quo] [quo.core :as quo]
@ -12,7 +11,6 @@
(defn content (defn content
[] []
(let [{:keys [mnemonic]} (rf/sub [:profile/profile])]
[rn/scroll-view {:flex 1} [rn/scroll-view {:flex 1}
[components/list-header "Legacy settings"] [components/list-header "Legacy settings"]
[list.item/list-item [list.item/list-item
@ -20,15 +18,13 @@
:title (i18n/label :t/privacy-and-security) :title (i18n/label :t/privacy-and-security)
:accessibility-label :privacy-and-security-settings-button :accessibility-label :privacy-and-security-settings-button
:chevron true :chevron true
:accessory (when mnemonic
[components.common/counter {:size 22} 1])
:on-press #(re-frame/dispatch [:open-modal :legacy-privacy-and-security])}] :on-press #(re-frame/dispatch [:open-modal :legacy-privacy-and-security])}]
[list.item/list-item [list.item/list-item
{:icon :main-icons/mobile {:icon :main-icons/mobile
:title (i18n/label :t/sync-settings) :title (i18n/label :t/sync-settings)
:accessibility-label :sync-settings-button :accessibility-label :sync-settings-button
:chevron true :chevron true
:on-press #(re-frame/dispatch [:open-modal :legacy-sync-settings])}]])) :on-press #(re-frame/dispatch [:open-modal :legacy-sync-settings])}]])
(defn legacy-settings (defn legacy-settings
[] []

View File

@ -189,7 +189,7 @@
:insets {:top? true}} :insets {:top? true}}
:component backup-settings/backup-settings} :component backup-settings/backup-settings}
{:name :backup-seed {:name :backup-seed
:options {:insets {:top? true}} :options {:insets {:top? platform/android? :bottom? true}}
:component profile.seed/backup-seed} :component profile.seed/backup-seed}
{:name :reset-password {:name :reset-password
:options {:topBar (topbar-options :t/reset-password) :options {:topBar (topbar-options :t/reset-password)

View File

@ -79,7 +79,7 @@
nil)) nil))
(defn label-component (defn label-component
[{:keys [label label-props blur? theme preview-size]}] [{:keys [label label-props label-icon-props blur? theme preview-size]}]
[rn/view {:accessibility-label :label-component} [rn/view {:accessibility-label :label-component}
(case label (case label
:text [text/text :text [text/text
@ -89,6 +89,7 @@
{:style (style/label-dot label-props)}] {:style (style/label-dot label-props)}]
:preview [preview-list/view {:type (:type label-props) :size (or preview-size :size-24)} :preview [preview-list/view {:type (:type label-props) :size (or preview-size :size-24)}
(:data label-props)] (:data label-props)]
:icon [icon/icon label-props label-icon-props]
nil)]) nil)])
(defn action-component (defn action-component

View File

@ -4,8 +4,19 @@
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
(def items (defn items
[[{:title (i18n/label :t/edit-profile) [mnemonic?]
[(when mnemonic?
[{:title (i18n/label :t/back-up-seed-phrase)
:on-press #(rf/dispatch [:open-modal :backup-seed])
:image-props :i/seed
:image :icon
:label :icon
:label-props :i/warning
:label-icon-props {:no-color true}
:blur? true
:action :arrow}])
[{:title (i18n/label :t/edit-profile)
:on-press #(rf/dispatch [:open-modal :edit-profile]) :on-press #(rf/dispatch [:open-modal :edit-profile])
:image-props :i/edit :image-props :i/edit
:image :icon :image :icon

View File

@ -37,15 +37,19 @@
[_ index] [_ index]
#js {:length 100 :offset (* 100 index) :index index}) #js {:length 100 :offset (* 100 index) :index index})
(defn logout-press
[]
(rf/dispatch [:multiaccounts.logout.ui/logout-pressed]))
(defn view (defn view
[] []
(let [theme (quo.theme/use-theme) (let [theme (quo.theme/use-theme)
insets (safe-area/get-insets) insets (safe-area/get-insets)
customization-color (rf/sub [:profile/customization-color]) customization-color (rf/sub [:profile/customization-color])
scroll-y (reanimated/use-shared-value 0) scroll-y (reanimated/use-shared-value 0)
logout-press #(rf/dispatch [:multiaccounts.logout.ui/logout-pressed])
profile (rf/sub [:profile/profile]) profile (rf/sub [:profile/profile])
full-name (profile.utils/displayed-name profile)] full-name (profile.utils/displayed-name profile)
on-scroll (rn/use-callback #(scroll-handler % scroll-y))]
[quo/overlay {:type :shell} [quo/overlay {:type :shell}
[rn/view [rn/view
{:key :header {:key :header
@ -70,13 +74,13 @@
[rn/flat-list [rn/flat-list
{:key :list {:key :list
:header [settings.header/view {:scroll-y scroll-y}] :header [settings.header/view {:scroll-y scroll-y}]
:data settings.items/items :data (settings.items/items (boolean (:mnemonic profile)))
:shows-vertical-scroll-indicator false :shows-vertical-scroll-indicator false
:render-fn settings-item-view :render-fn settings-item-view
:get-item-layout get-item-layout :get-item-layout get-item-layout
:footer [footer insets logout-press] :footer [footer insets logout-press]
:scroll-event-throttle 16 :scroll-event-throttle 16
:on-scroll #(scroll-handler % scroll-y) :on-scroll on-scroll
:bounces false :bounces false
:over-scroll-mode :never}] :over-scroll-mode :never}]
[quo/floating-shell-button [quo/floating-shell-button

View File

@ -81,10 +81,10 @@
res)) res))
(defn delay-render (defn delay-render
[content] [_]
(let [render? (reagent/atom false)] (let [render? (reagent/atom false)]
(js/setTimeout #(reset! render? true) 0) (js/setTimeout #(reset! render? true) 0)
(fn [] (fn [content]
(when @render? (when @render?
content)))) content))))

View File

@ -62,8 +62,8 @@
"other": "You can select {{count}} more participants" "other": "You can select {{count}} more participants"
}, },
"back": "Back", "back": "Back",
"back-up-seed-phrase": "Back up seed phrase", "back-up-seed-phrase": "Backup recovery phrase",
"back-up-your-seed-phrase": "Back up your seed phrase", "back-up-your-seed-phrase": "Backup your recovery phrase",
"balance": "Balance", "balance": "Balance",
"begin-set-up": "Begin setup", "begin-set-up": "Begin setup",
"bio": "Bio", "bio": "Bio",