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
:justify-content :space-between
:align-items :center
:max-height 56
:height 56
:padding 12
:border-radius 12
:opacity (if (= state :disabled) 0.3 1)

View File

@ -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

View File

@ -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)

View File

@ -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})

View File

@ -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}

View File

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

View File

@ -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})

View File

@ -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 %)}]]]))))

View File

@ -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

View File

@ -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
[]

View File

@ -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)