feat!: add saved addresses to wallet settings (#20475)

This commit is contained in:
Mohsen 2024-06-26 16:44:29 +03:30 committed by GitHub
parent 4bd7abaace
commit b005eb8181
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 59 additions and 48 deletions

View File

@ -31,7 +31,7 @@
(defn- checkbox-border-unchecked-color
[theme]
{:normal (colors/theme-colors colors/neutral-30 colors/neutral-70 theme)
:blur (colors/theme-colors colors/neutral-80-opa-20 colors/white-opa-40 theme)})
:blur (colors/theme-colors colors/neutral-80-opa-20 colors/white-opa-20 theme)})
(defn- filled-checkbox-background-color
[theme]

View File

@ -39,6 +39,12 @@
(def avatar-container-rounded
(assoc avatar-container-common :border-radius 16))
(def big-avatar-container-rounded
(assoc avatar-container-common
:width 84
:height 84
:border-radius 42))
(def community-logo-image
{:width 64
:height 64

View File

@ -13,8 +13,9 @@
:as props}]
[rn/view {:style style/avatar-overlay}
[rn/view
{:style (if (= avatar-type :wallet-account)
style/avatar-container-rounded
{:style (case avatar-type
:wallet-account style/avatar-container-rounded
:saved-address style/big-avatar-container-rounded
style/avatar-container-circular)}
(case avatar-type
:profile
@ -37,7 +38,7 @@
[channel-avatar/view (assoc props :locked? nil :size :size-64)]
:saved-address
[wallet-avatar/wallet-user-avatar (assoc props :size :size-64)]
[wallet-avatar/wallet-user-avatar (assoc props :size :size-80)]
nil)]])

View File

@ -27,4 +27,5 @@
{:color colors/white-opa-40})
(def saved-address-item
{:margin-top 4})
{:margin-top 4
:background-color colors/white-opa-5})

View File

@ -49,6 +49,7 @@
:multiline? true
:on-clear clear-input
:return-key-type :done
:auto-focus true
:clearable? (not empty-input?)
:on-change-text on-change-text
:button (when empty-input?
@ -83,7 +84,7 @@
[quo/info-message
{:accessibility-label :error-message
:size :default
:icon :i/info
:icon :i/alert
:type :error
:style style/info-message}
error-msg])))
@ -91,8 +92,7 @@
(defn- existing-saved-address
[{:keys [address]}]
(let [{:keys [name customization-color chain-short-names ens ens?]}
(rf/sub [:wallet/saved-address-by-address
address])]
(rf/sub [:wallet/saved-address-by-address address])]
[rn/view {:style style/existing-saved-address-container}
[quo/text
{:size :paragraph-1

View File

@ -93,20 +93,19 @@
:subtitle-type :default
:label :none
:blur? true
:icon-right? (not ens?)
:right-icon :i/advanced
:right-icon (when-not ens? :i/advanced)
:card? true
:title (i18n/label :t/address)
:subtitle ens
:custom-subtitle address-text
:on-press open-network-preferences
:on-press (when-not ens? open-network-preferences)
:container-style style/data-item}
ens?
(dissoc :custom-subtitle))
[ens ens? open-network-preferences address-text])]
[quo/overlay {:type :shell}
[floating-button-page/view
{:footer-container-padding 0
{:footer-container-padding (if edit? (+ (safe-area/get-bottom) 12) 0)
:header [quo/page-nav
{:type :no-title
:background :blur
@ -133,7 +132,7 @@
:container-style style/avatar}]
[quo/title-input
{:blur? true
:auto-focus true
:auto-focus (not edit?)
:max-length 24
:size :heading-1
:placeholder placeholder

View File

@ -73,17 +73,23 @@
(defn- filtered-list
[{:keys [search-text]}]
(let [search-result (rf/sub [:wallet/filtered-saved-addresses search-text])]
(if (empty? search-result)
[empty-result]
[rn/flat-list
{:key-fn :address
:data (rf/sub [:wallet/filtered-saved-addresses search-text])
:data search-result
:render-fn saved-address
:shows-vertical-scroll-indicator false
:keyboard-should-persist-taps :always
:content-container-style {:flex-grow 1}
:empty-component [empty-result]}])
:bounces false
:over-scroll-mode :never}])))
(defn- unfiltered-list
[{:keys [grouped-saved-addresses]}]
(if (empty? grouped-saved-addresses)
[empty-list]
[rn/section-list
{:key-fn :title
:shows-vertical-scroll-indicator false
@ -92,8 +98,9 @@
:render-section-header-fn header
:sections grouped-saved-addresses
:render-fn saved-address
:content-container-style {:flex-grow 1}
:empty-component [empty-list]}])
:bounces false
:over-scroll-mode :never
:content-container-style {:flex-grow 1}}]))
(defn- navigate-back
[]

View File

@ -2,7 +2,6 @@
(:require [quo.core :as quo]
[react-native.safe-area :as safe-area]
[status-im.contexts.settings.wallet.wallet-options.style :as style]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
@ -20,11 +19,10 @@
:blur? true
:on-press open-keypairs-and-accounts-settings-modal
:action :arrow}
(when (ff/enabled? ::ff/settings.saved-addresses)
{:title (i18n/label :t/saved-addresses)
:blur? true
:on-press open-saved-addresses-settings-modal
:action :arrow})])
:action :arrow}])
(defn basic-settings
[]

View File

@ -28,7 +28,7 @@
(let [{:keys [on-result]} (rf/sub [:get-screen-params])]
[scan-qr-code/view
{:title (i18n/label :t/scan-qr)
:subtitle (i18n/label :t/scan-an-account-qr-code)
:subtitle (i18n/label :t/scan-an-address-qr-code)
:error-message (i18n/label :t/oops-this-qr-does-not-contain-an-address)
:validate-fn #(contains-supported-address? %)
:on-success-scan (fn [result]

View File

@ -220,7 +220,7 @@
(defn make-network-item
"This function generates props for quo/category component item"
[{:keys [network-name color on-change networks state label-props type]}]
[{:keys [network-name color on-change networks state label-props type blur?]}]
(cond-> {:title (string/capitalize (name network-name))
:image :icon-avatar
:image-props {:icon (resources/get-network network-name)
@ -230,6 +230,7 @@
(if (= :default state)
:filled-checkbox
:checkbox))
:blur? blur?
:customization-color color
:checked? (contains? networks network-name)
:on-change on-change}}

View File

@ -90,10 +90,7 @@
:address address
:blur? blur?
:format :long}])
:container-style (merge style/data-item
{:background-color (colors/theme-colors colors/neutral-2_5
colors/neutral-90
theme)})}])
:container-style style/data-item}])
[quo/category
{:list-type :settings
:blur? blur?
@ -106,6 +103,7 @@
:normal-checkbox? receiver?
:networks (get-current-preferences-names)
:type :checkbox
:blur? blur?
:on-change (fn []
(toggle-network (:network-name
network))
@ -137,6 +135,7 @@
:normal-checkbox? receiver?
:networks (get-current-preferences-names)
:type :checkbox
:blur? blur?
:on-change (fn []
(toggle-network (:network-name
network))

View File

@ -11,8 +11,6 @@
(def ^:private initial-flags
{::community.edit-account-selection (enabled-in-env? :FLAG_EDIT_ACCOUNT_SELECTION_ENABLED)
::settings.saved-addresses (enabled-in-env?
:FLAG_WALLET_SETTINGS_SAVED_ADDRESSES_ENABLED)
::settings.import-all-keypairs (enabled-in-env?
:FLAG_WALLET_SETTINGS_IMPORT_ALL_KEYPAIRS)
::shell.jump-to (enabled-in-env? :ENABLE_JUMP_TO)

View File

@ -54,7 +54,7 @@
:wallet/saved-address-by-address
:<- [:wallet/saved-addresses-by-network-mode]
(fn [saved-addresses [_ address]]
(get saved-addresses address)))
(get saved-addresses (string/lower-case address))))
(rf/reg-sub
:wallet/filtered-saved-addresses
@ -65,7 +65,7 @@
(sort-by :name)
(filter
(fn [{:keys [name address ens chain-short-names]}]
(let [lowercase-query (string/lower-case query)]
(let [lowercase-query (string/lower-case (string/trim query))]
(or
(string/includes? (string/lower-case name) lowercase-query)
(string/includes? address lowercase-query)

View File

@ -2475,7 +2475,7 @@
"make-one-it-is-easy-we-promise": "Make one, its easy, we promise!",
"saved-addresses": "Saved addresses",
"no-saved-addresses": "No saved addresses",
"you-like-to-type-43-characters": "You like to type 43 characters?",
"you-like-to-type-43-characters": "Do you like to type 43 characters?",
"no-other-accounts": "No other accounts",
"here-is-a-cat-in-a-box-instead": "Heres a cat in a box instead",
"accounts-count": "{{count}} accounts",
@ -2506,6 +2506,7 @@
"select-another-account": "Select another account",
"oops-this-qr-does-not-contain-an-address": "Oops! This QR does not contain an address",
"scan-an-account-qr-code": "Scan an account QR code",
"scan-an-address-qr-code": "Scan an address QR code",
"buy-assets": "Buy assets",
"one-time": "One time",
"recurrent": "Recurrent",