Wallet: Keypair feature flag (#19333)

* Wallet: Keypair feature flag (#19333)
This commit is contained in:
Omar Basem 2024-03-22 16:41:36 +04:00 committed by GitHub
parent 0cc414d717
commit 38fcb0c1a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 57 additions and 52 deletions

View File

@ -7,7 +7,7 @@
:flex-direction :row :flex-direction :row
:justify-content :space-between :justify-content :space-between
:align-items :center :align-items :center
:max-height 56 :height 56
:padding 12 :padding 12
:border-radius 12 :border-radius 12
:opacity (if (= state :disabled) 0.3 1) :opacity (if (= state :disabled) 0.3 1)

View File

@ -8,7 +8,7 @@
(defn view (defn view
[{:keys [track-text customization-color auth-button-label on-auth-success on-auth-fail [{: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}}}] :or {container-style {:flex 1}}}]
(let [theme (quo.theme/use-theme-value) (let [theme (quo.theme/use-theme-value)
auth-method (rf/sub [:auth-method]) auth-method (rf/sub [:auth-method])
@ -24,7 +24,7 @@
:on-auth-success on-auth-success :on-auth-success on-auth-success
:on-auth-fail on-auth-fail :on-auth-fail on-auth-fail
:auth-button-label auth-button-label}])) :auth-button-label auth-button-label}]))
[theme])] (into [] (concat [theme] dependencies)))]
[quo/slide-button [quo/slide-button
{:container-style container-style {:container-style container-style
:size size :size size

View File

@ -31,7 +31,7 @@
(defn new-keypair-created (defn new-keypair-created
[{:keys [db]} [{:keys [new-keypair]}]] [{:keys [db]} [{:keys [new-keypair]}]]
{:db (assoc-in db [:wallet :ui :create-account :new-keypair] 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) (rf/reg-event-fx :wallet/new-keypair-created new-keypair-created)

View File

@ -44,7 +44,7 @@
(defn blur (defn blur
[theme] [theme]
{:style {:flex 1} {:style {:flex 1}
:blur-radius 20 :blur-radius 25
:blur-type (quo.theme/theme-value :light :dark theme) :blur-type (quo.theme/theme-value :light :dark theme)
:blur-amount 20}) :blur-amount 20})

View File

@ -28,11 +28,12 @@
:scroll-enabled false}]) :scroll-enabled false}])
(defn- step-item (defn- step-item
[item index _ checked?] [item index _ {:keys [checked? customization-color]}]
[rn/view {:style style/step-item} [rn/view {:style style/step-item}
[quo/selectors [quo/selectors
{:type :checkbox {:type :checkbox
:on-change #(swap! checked? assoc (keyword (str index)) %)}] :customization-color customization-color
:on-change #(swap! checked? assoc (keyword (str index)) %)}]
[quo/text {:style {:margin-left 12}} (i18n/label item)]]) [quo/text {:style {:margin-left 12}} (i18n/label item)]])
(defn- f-view (defn- f-view
@ -61,7 +62,8 @@
[quo/page-top [quo/page-top
{:title (i18n/label :t/backup-recovery-phrase) {:title (i18n/label :t/backup-recovery-phrase)
:description :text :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)} [rn/view {:style (style/seed-phrase-container theme)}
(when (pos? (count @secret-phrase)) (when (pos? (count @secret-phrase))
[:<> [:<>
@ -86,7 +88,8 @@
[rn/flat-list [rn/flat-list
{:data step-labels {:data step-labels
:render-fn step-item :render-fn step-item
:render-data checked? :render-data {:checked? checked?
:customization-color customization-color}
:scroll-enabled false}]]) :scroll-enabled false}]])
(if @revealed? (if @revealed?
[rn/view {:style style/slide-button} [rn/view {:style style/slide-button}

View File

@ -24,5 +24,5 @@
(def cheat-description (def cheat-description
{:padding-horizontal 20 {:padding-horizontal 20
:padding-top 4 :padding-top 8
:padding-bottom 8}) :padding-bottom 8})

View File

@ -2,10 +2,8 @@
(def header-container (def header-container
{:margin-horizontal 20 {:margin-horizontal 20
:margin-vertical 12}) :margin-top 12
:margin-bottom 20})
(def bottom-action (def bottom-action
{:position :absolute {:margin-horizontal -20})
:bottom 12
:left 0
:right 0})

View File

@ -3,6 +3,7 @@
[quo.core :as quo] [quo.core :as quo]
[react-native.core :as rn] [react-native.core :as rn]
[reagent.core :as reagent] [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] [status-im.contexts.wallet.create-account.new-keypair.keypair-name.style :as style]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -15,26 +16,30 @@
(fn [] (fn []
(let [customization-color (rf/sub [:profile/customization-color])] (let [customization-color (rf/sub [:profile/customization-color])]
[rn/view {:style {:flex 1}} [rn/view {:style {:flex 1}}
[quo/page-nav [floating-button-page/view
{:icon-name :i/arrow-left {:header [quo/page-nav
:on-press #(rf/dispatch [:navigate-back]) {:icon-name :i/arrow-left
:accessibility-label :top-bar}] :on-press #(rf/dispatch [:navigate-back])
[quo/text-combinations :accessibility-label :top-bar}]
{:container-style style/header-container :footer [quo/bottom-actions
:title (i18n/label :t/keypair-name) {:actions :one-action
:description (i18n/label :t/keypair-name-description)}] :button-one-label (i18n/label :t/continue)
[quo/input :button-one-props {:disabled? (or (zero? (count @keypair-name))
{:container-style {:margin-horizontal 20} (> (count @keypair-name)
:placeholder (i18n/label :t/keypair-name-input-placeholder) keypair-name-max-length))
:label (i18n/label :t/keypair-name) :customization-color customization-color
:char-limit keypair-name-max-length :on-press #(rf/dispatch [:wallet/new-keypair-continue
:on-change-text #(reset! keypair-name %)}] {:keypair-name
[quo/bottom-actions @keypair-name}])}
{:actions :one-action :container-style style/bottom-action}]}
:button-one-label (i18n/label :t/continue) [quo/text-combinations
:button-one-props {:disabled? (or (zero? (count @keypair-name)) {:container-style style/header-container
(> (count @keypair-name) keypair-name-max-length)) :title (i18n/label :t/keypair-name)
:customization-color customization-color :description (i18n/label :t/keypair-name-description)}]
:on-press #(rf/dispatch [:wallet/new-keypair-continue [quo/input
{:keypair-name @keypair-name}])} {:container-style {:margin-horizontal 20}
:container-style style/bottom-action}]])))) :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 %)}]]]))))

View File

@ -46,12 +46,11 @@
:action :none})))) :action :none}))))
(defn- keypair (defn- keypair
[item index _ {:keys [profile-picture compressed-key selected-key-uid set-selected-key-uid]}] [item index _
(let [main-account (first (:accounts item)) {:keys [profile-picture compressed-key selected-key-uid set-selected-key-uid customization-color]}]
color (:customization-color main-account) (let [accounts (parse-accounts (:accounts item))]
accounts (parse-accounts (:accounts item))]
[quo/keypair [quo/keypair
{:customization-color color {:customization-color customization-color
:profile-picture (when (zero? index) profile-picture) :profile-picture (when (zero? index) profile-picture)
:status-indicator false :status-indicator false
:type (if (zero? index) :default-keypair :other) :type (if (zero? index) :default-keypair :other)
@ -75,6 +74,7 @@
selected-keypair (rf/sub [:wallet/selected-keypair-uid]) selected-keypair (rf/sub [:wallet/selected-keypair-uid])
profile-picture (rf/sub [:profile/image]) profile-picture (rf/sub [:profile/image])
[selected-key-uid set-selected-key-uid] (rn/use-state selected-keypair)] [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}} [rn/view {:style {:flex 1}}
[quo/page-nav [quo/page-nav
{:icon-name :i/close {:icon-name :i/close
@ -96,7 +96,8 @@
:render-data {:profile-picture profile-picture :render-data {:profile-picture profile-picture
:compressed-key compressed-key :compressed-key compressed-key
:selected-key-uid selected-key-uid :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 :initial-num-to-render 1
:content-container-style {:padding-bottom 60}}] :content-container-style {:padding-bottom 60}}]
[quo/bottom-actions [quo/bottom-actions

View File

@ -14,7 +14,6 @@
[status-im.contexts.wallet.create-account.style :as style] [status-im.contexts.wallet.create-account.style :as style]
[status-im.contexts.wallet.create-account.utils :as create-account.utils] [status-im.contexts.wallet.create-account.utils :as create-account.utils]
[status-im.contexts.wallet.sheets.account-origin.view :as account-origin] [status-im.contexts.wallet.sheets.account-origin.view :as account-origin]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf] [utils.re-frame :as rf]
[utils.responsiveness :refer [iphone-11-Pro-20-pixel-from-width]] [utils.responsiveness :refer [iphone-11-Pro-20-pixel-from-width]]
@ -32,10 +31,7 @@
:customization-color customization-color} :customization-color customization-color}
:i/seed) :i/seed)
:action (when-not new-keypair? :button) :action (when-not new-keypair? :button)
:action-props {:on-press (fn [] :action-props {:on-press #(rf/dispatch [:navigate-to :screen/wallet.select-keypair])
(ff/alert ::ff/wallet.bridge-token
#(rf/dispatch [:navigate-to
:screen/wallet.select-keypair])))
:button-text (i18n/label :t/edit) :button-text (i18n/label :t/edit)
:alignment :flex-start} :alignment :flex-start}
:description :text :description :text
@ -97,6 +93,7 @@
(i18n/label :t/keypair-title (i18n/label :t/keypair-title
{:name (:name keypair)}) {:name (:name keypair)})
(:name keypair)))] (:name keypair)))]
(rn/use-unmount #(rf/dispatch [:wallet/clear-new-keypair]))
[rn/view {:style {:flex 1}} [rn/view {:style {:flex 1}}
[quo/page-nav [quo/page-nav
{:type :no-title {:type :no-title
@ -166,7 +163,8 @@
(create-existing-keypair-account password))) (create-existing-keypair-account password)))
:auth-button-label (i18n/label :t/confirm) :auth-button-label (i18n/label :t/confirm)
:disabled? (empty? @account-name) :disabled? (empty? @account-name)
:container-style (style/slide-button-container bottom)}]])))) :container-style (style/slide-button-container bottom)
:dependencies [new-keypair]}]]))))
(defn- view-internal (defn- view-internal
[] []

View File

@ -10,7 +10,7 @@
(defonce ^:private feature-flags-config (defonce ^:private feature-flags-config
(reagent/atom (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.edit-derivation-path (enabled-in-env? :FLAG_EDIT_DERIVATION_PATH)
::wallet.remove-account (enabled-in-env? :FLAG_REMOVE_ACCOUNT_ENABLED) ::wallet.remove-account (enabled-in-env? :FLAG_REMOVE_ACCOUNT_ENABLED)
::wallet.network-filter (enabled-in-env? :FLAG_NETWORK_FILTER_ENABLED) ::wallet.network-filter (enabled-in-env? :FLAG_NETWORK_FILTER_ENABLED)