From 38fcb0c1a0338c97709516f630f814131ccbeda3 Mon Sep 17 00:00:00 2001 From: Omar Basem Date: Fri, 22 Mar 2024 16:41:36 +0400 Subject: [PATCH] Wallet: Keypair feature flag (#19333) * Wallet: Keypair feature flag (#19333) --- .../list_items/quiz_item/style.cljs | 2 +- .../standard_auth/slide_button/view.cljs | 4 +- .../wallet/create_account/events.cljs | 2 +- .../backup_recovery_phrase/style.cljs | 2 +- .../backup_recovery_phrase/view.cljs | 13 +++-- .../new_keypair/check_your_backup/style.cljs | 2 +- .../new_keypair/keypair_name/style.cljs | 8 ++- .../new_keypair/keypair_name/view.cljs | 51 ++++++++++--------- .../create_account/select_keypair/view.cljs | 13 ++--- .../contexts/wallet/create_account/view.cljs | 10 ++-- src/status_im/feature_flags.cljs | 2 +- 11 files changed, 57 insertions(+), 52 deletions(-) diff --git a/src/quo/components/list_items/quiz_item/style.cljs b/src/quo/components/list_items/quiz_item/style.cljs index 9efad1f7b5..6459be26c7 100644 --- a/src/quo/components/list_items/quiz_item/style.cljs +++ b/src/quo/components/list_items/quiz_item/style.cljs @@ -7,7 +7,7 @@ :flex-direction :row :justify-content :space-between :align-items :center - :max-height 56 + :height 56 :padding 12 :border-radius 12 :opacity (if (= state :disabled) 0.3 1) diff --git a/src/status_im/common/standard_authentication/standard_auth/slide_button/view.cljs b/src/status_im/common/standard_authentication/standard_auth/slide_button/view.cljs index c2ac9b7a7a..cef4210ab4 100644 --- a/src/status_im/common/standard_authentication/standard_auth/slide_button/view.cljs +++ b/src/status_im/common/standard_authentication/standard_auth/slide_button/view.cljs @@ -8,7 +8,7 @@ (defn view [{:keys [track-text customization-color auth-button-label on-auth-success on-auth-fail - auth-button-icon-left size blur? container-style disabled?] + auth-button-icon-left size blur? container-style disabled? dependencies] :or {container-style {:flex 1}}}] (let [theme (quo.theme/use-theme-value) auth-method (rf/sub [:auth-method]) @@ -24,7 +24,7 @@ :on-auth-success on-auth-success :on-auth-fail on-auth-fail :auth-button-label auth-button-label}])) - [theme])] + (into [] (concat [theme] dependencies)))] [quo/slide-button {:container-style container-style :size size diff --git a/src/status_im/contexts/wallet/create_account/events.cljs b/src/status_im/contexts/wallet/create_account/events.cljs index 6b83b41ed0..76982e2025 100644 --- a/src/status_im/contexts/wallet/create_account/events.cljs +++ b/src/status_im/contexts/wallet/create_account/events.cljs @@ -31,7 +31,7 @@ (defn new-keypair-created [{:keys [db]} [{:keys [new-keypair]}]] {:db (assoc-in db [:wallet :ui :create-account :new-keypair] new-keypair) - :fx [[:dispatch [:navigate-back-to :wallet-create-account]]]}) + :fx [[:dispatch [:navigate-back-to :screen/wallet.create-account]]]}) (rf/reg-event-fx :wallet/new-keypair-created new-keypair-created) diff --git a/src/status_im/contexts/wallet/create_account/new_keypair/backup_recovery_phrase/style.cljs b/src/status_im/contexts/wallet/create_account/new_keypair/backup_recovery_phrase/style.cljs index 56c00b8821..28a8718697 100644 --- a/src/status_im/contexts/wallet/create_account/new_keypair/backup_recovery_phrase/style.cljs +++ b/src/status_im/contexts/wallet/create_account/new_keypair/backup_recovery_phrase/style.cljs @@ -44,7 +44,7 @@ (defn blur [theme] {:style {:flex 1} - :blur-radius 20 + :blur-radius 25 :blur-type (quo.theme/theme-value :light :dark theme) :blur-amount 20}) diff --git a/src/status_im/contexts/wallet/create_account/new_keypair/backup_recovery_phrase/view.cljs b/src/status_im/contexts/wallet/create_account/new_keypair/backup_recovery_phrase/view.cljs index ad5d8ec230..752150d978 100644 --- a/src/status_im/contexts/wallet/create_account/new_keypair/backup_recovery_phrase/view.cljs +++ b/src/status_im/contexts/wallet/create_account/new_keypair/backup_recovery_phrase/view.cljs @@ -28,11 +28,12 @@ :scroll-enabled false}]) (defn- step-item - [item index _ checked?] + [item index _ {:keys [checked? customization-color]}] [rn/view {:style style/step-item} [quo/selectors - {:type :checkbox - :on-change #(swap! checked? assoc (keyword (str index)) %)}] + {:type :checkbox + :customization-color customization-color + :on-change #(swap! checked? assoc (keyword (str index)) %)}] [quo/text {:style {:margin-left 12}} (i18n/label item)]]) (defn- f-view @@ -61,7 +62,8 @@ [quo/page-top {:title (i18n/label :t/backup-recovery-phrase) :description :text - :description-text (i18n/label :t/backup-recovery-phrase-description)}] + :description-text (i18n/label :t/backup-recovery-phrase-description) + :container-style {:padding-bottom 8}}] [rn/view {:style (style/seed-phrase-container theme)} (when (pos? (count @secret-phrase)) [:<> @@ -86,7 +88,8 @@ [rn/flat-list {:data step-labels :render-fn step-item - :render-data checked? + :render-data {:checked? checked? + :customization-color customization-color} :scroll-enabled false}]]) (if @revealed? [rn/view {:style style/slide-button} diff --git a/src/status_im/contexts/wallet/create_account/new_keypair/check_your_backup/style.cljs b/src/status_im/contexts/wallet/create_account/new_keypair/check_your_backup/style.cljs index c1d04d566e..39d6892300 100644 --- a/src/status_im/contexts/wallet/create_account/new_keypair/check_your_backup/style.cljs +++ b/src/status_im/contexts/wallet/create_account/new_keypair/check_your_backup/style.cljs @@ -24,5 +24,5 @@ (def cheat-description {:padding-horizontal 20 - :padding-top 4 + :padding-top 8 :padding-bottom 8}) diff --git a/src/status_im/contexts/wallet/create_account/new_keypair/keypair_name/style.cljs b/src/status_im/contexts/wallet/create_account/new_keypair/keypair_name/style.cljs index 62f63984c0..ac38696374 100644 --- a/src/status_im/contexts/wallet/create_account/new_keypair/keypair_name/style.cljs +++ b/src/status_im/contexts/wallet/create_account/new_keypair/keypair_name/style.cljs @@ -2,10 +2,8 @@ (def header-container {:margin-horizontal 20 - :margin-vertical 12}) + :margin-top 12 + :margin-bottom 20}) (def bottom-action - {:position :absolute - :bottom 12 - :left 0 - :right 0}) + {:margin-horizontal -20}) diff --git a/src/status_im/contexts/wallet/create_account/new_keypair/keypair_name/view.cljs b/src/status_im/contexts/wallet/create_account/new_keypair/keypair_name/view.cljs index 9af5060054..4b25c5e52a 100644 --- a/src/status_im/contexts/wallet/create_account/new_keypair/keypair_name/view.cljs +++ b/src/status_im/contexts/wallet/create_account/new_keypair/keypair_name/view.cljs @@ -3,6 +3,7 @@ [quo.core :as quo] [react-native.core :as rn] [reagent.core :as reagent] + [status-im.common.floating-button-page.view :as floating-button-page] [status-im.contexts.wallet.create-account.new-keypair.keypair-name.style :as style] [utils.i18n :as i18n] [utils.re-frame :as rf])) @@ -15,26 +16,30 @@ (fn [] (let [customization-color (rf/sub [:profile/customization-color])] [rn/view {:style {:flex 1}} - [quo/page-nav - {:icon-name :i/arrow-left - :on-press #(rf/dispatch [:navigate-back]) - :accessibility-label :top-bar}] - [quo/text-combinations - {:container-style style/header-container - :title (i18n/label :t/keypair-name) - :description (i18n/label :t/keypair-name-description)}] - [quo/input - {:container-style {:margin-horizontal 20} - :placeholder (i18n/label :t/keypair-name-input-placeholder) - :label (i18n/label :t/keypair-name) - :char-limit keypair-name-max-length - :on-change-text #(reset! keypair-name %)}] - [quo/bottom-actions - {:actions :one-action - :button-one-label (i18n/label :t/continue) - :button-one-props {:disabled? (or (zero? (count @keypair-name)) - (> (count @keypair-name) keypair-name-max-length)) - :customization-color customization-color - :on-press #(rf/dispatch [:wallet/new-keypair-continue - {:keypair-name @keypair-name}])} - :container-style style/bottom-action}]])))) + [floating-button-page/view + {:header [quo/page-nav + {:icon-name :i/arrow-left + :on-press #(rf/dispatch [:navigate-back]) + :accessibility-label :top-bar}] + :footer [quo/bottom-actions + {:actions :one-action + :button-one-label (i18n/label :t/continue) + :button-one-props {:disabled? (or (zero? (count @keypair-name)) + (> (count @keypair-name) + keypair-name-max-length)) + :customization-color customization-color + :on-press #(rf/dispatch [:wallet/new-keypair-continue + {:keypair-name + @keypair-name}])} + :container-style style/bottom-action}]} + [quo/text-combinations + {:container-style style/header-container + :title (i18n/label :t/keypair-name) + :description (i18n/label :t/keypair-name-description)}] + [quo/input + {:container-style {:margin-horizontal 20} + :placeholder (i18n/label :t/keypair-name-input-placeholder) + :label (i18n/label :t/keypair-name) + :char-limit keypair-name-max-length + :auto-focus true + :on-change-text #(reset! keypair-name %)}]]])))) diff --git a/src/status_im/contexts/wallet/create_account/select_keypair/view.cljs b/src/status_im/contexts/wallet/create_account/select_keypair/view.cljs index ca8e29777e..bedd8c83f9 100644 --- a/src/status_im/contexts/wallet/create_account/select_keypair/view.cljs +++ b/src/status_im/contexts/wallet/create_account/select_keypair/view.cljs @@ -46,12 +46,11 @@ :action :none})))) (defn- keypair - [item index _ {:keys [profile-picture compressed-key selected-key-uid set-selected-key-uid]}] - (let [main-account (first (:accounts item)) - color (:customization-color main-account) - accounts (parse-accounts (:accounts item))] + [item index _ + {:keys [profile-picture compressed-key selected-key-uid set-selected-key-uid customization-color]}] + (let [accounts (parse-accounts (:accounts item))] [quo/keypair - {:customization-color color + {:customization-color customization-color :profile-picture (when (zero? index) profile-picture) :status-indicator false :type (if (zero? index) :default-keypair :other) @@ -75,6 +74,7 @@ selected-keypair (rf/sub [:wallet/selected-keypair-uid]) profile-picture (rf/sub [:profile/image]) [selected-key-uid set-selected-key-uid] (rn/use-state selected-keypair)] + (rn/use-mount #(rf/dispatch [:wallet/get-keypairs])) [rn/view {:style {:flex 1}} [quo/page-nav {:icon-name :i/close @@ -96,7 +96,8 @@ :render-data {:profile-picture profile-picture :compressed-key compressed-key :selected-key-uid selected-key-uid - :set-selected-key-uid set-selected-key-uid} + :set-selected-key-uid set-selected-key-uid + :customization-color customization-color} :initial-num-to-render 1 :content-container-style {:padding-bottom 60}}] [quo/bottom-actions diff --git a/src/status_im/contexts/wallet/create_account/view.cljs b/src/status_im/contexts/wallet/create_account/view.cljs index bb97baf399..524113eb76 100644 --- a/src/status_im/contexts/wallet/create_account/view.cljs +++ b/src/status_im/contexts/wallet/create_account/view.cljs @@ -14,7 +14,6 @@ [status-im.contexts.wallet.create-account.style :as style] [status-im.contexts.wallet.create-account.utils :as create-account.utils] [status-im.contexts.wallet.sheets.account-origin.view :as account-origin] - [status-im.feature-flags :as ff] [utils.i18n :as i18n] [utils.re-frame :as rf] [utils.responsiveness :refer [iphone-11-Pro-20-pixel-from-width]] @@ -32,10 +31,7 @@ :customization-color customization-color} :i/seed) :action (when-not new-keypair? :button) - :action-props {:on-press (fn [] - (ff/alert ::ff/wallet.bridge-token - #(rf/dispatch [:navigate-to - :screen/wallet.select-keypair]))) + :action-props {:on-press #(rf/dispatch [:navigate-to :screen/wallet.select-keypair]) :button-text (i18n/label :t/edit) :alignment :flex-start} :description :text @@ -97,6 +93,7 @@ (i18n/label :t/keypair-title {:name (:name keypair)}) (:name keypair)))] + (rn/use-unmount #(rf/dispatch [:wallet/clear-new-keypair])) [rn/view {:style {:flex 1}} [quo/page-nav {:type :no-title @@ -166,7 +163,8 @@ (create-existing-keypair-account password))) :auth-button-label (i18n/label :t/confirm) :disabled? (empty? @account-name) - :container-style (style/slide-button-container bottom)}]])))) + :container-style (style/slide-button-container bottom) + :dependencies [new-keypair]}]])))) (defn- view-internal [] diff --git a/src/status_im/feature_flags.cljs b/src/status_im/feature_flags.cljs index f5f296d34b..dd8d14b4f5 100644 --- a/src/status_im/feature_flags.cljs +++ b/src/status_im/feature_flags.cljs @@ -10,7 +10,7 @@ (defonce ^:private feature-flags-config (reagent/atom - {::wallet.edit-default-keypair (enabled-in-env? :FLAG_EDIT_DEFAULT_KEYPAIR) + {::wallet.bridge-token (enabled-in-env? :FLAG_BRIDGE_TOKEN_ENABLED) ::wallet.edit-derivation-path (enabled-in-env? :FLAG_EDIT_DERIVATION_PATH) ::wallet.remove-account (enabled-in-env? :FLAG_REMOVE_ACCOUNT_ENABLED) ::wallet.network-filter (enabled-in-env? :FLAG_NETWORK_FILTER_ENABLED)