-
Notifications
You must be signed in to change notification settings - Fork 980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor add address to watch component and make it generic and use it in add saved addresses screen behind a FF #19797
Changes from all commits
d4d2785
f8ad8c9
68374b9
789bc81
0e5519c
d04b512
7b74e9b
1d7a276
e3246f8
e8cce9a
e0db249
62e03d7
50966d3
227a8a6
d7b627b
3bcaa6b
0608626
3db99ca
db062a6
460233d
2725625
e5a4d8a
64c77ac
eca89de
149a149
a74e3ad
b89d5ae
1b1f5c4
ed98ee4
400edc5
ae1f049
5db1af3
7bb01c1
31765b4
258b1ec
c8805b5
6e0b8ae
26b26f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,23 +56,35 @@ | |
|
||
|
||
(defn root-container | ||
[{:keys [type size customization-color] | ||
[{:keys [type size customization-color emoji?] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding text only (initials) styling to the emoji styling. |
||
:or {size default-size | ||
customization-color :blue}} | ||
theme] | ||
(let [watch-only? (= type :watch-only) | ||
width (cond-> size | ||
(keyword? size) (container-size size))] | ||
(cond-> {:width width | ||
:height width | ||
:background-color (colors/resolve-color customization-color theme) | ||
:border-radius (get-border-radius size) | ||
:border-color (colors/theme-colors colors/neutral-80-opa-5 colors/white-opa-5 theme) | ||
:padding (get-padding size) | ||
:align-items :center | ||
:justify-content :center} | ||
(if emoji? | ||
(cond-> {:width width | ||
:height width | ||
:background-color (colors/resolve-color customization-color theme) | ||
:border-radius (get-border-radius size) | ||
:border-color (colors/theme-colors colors/neutral-80-opa-5 colors/white-opa-5 theme) | ||
:padding (get-padding size) | ||
:align-items :center | ||
:justify-content :center} | ||
|
||
watch-only? | ||
(assoc :border-width (get-border-width size) | ||
:background-color (colors/resolve-color customization-color theme 10))))) | ||
watch-only? | ||
(assoc :border-width (get-border-width size) | ||
:background-color (colors/resolve-color customization-color theme 10))) | ||
{:width width | ||
:height width | ||
:border-radius width | ||
:align-items :center | ||
:justify-content :center | ||
:color (colors/resolve-color customization-color theme 60) | ||
:background-color (colors/resolve-color customization-color theme 20)}))) | ||
Comment on lines
+81
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Main addition is border-radius, color and background-color |
||
|
||
(defn account-name | ||
[{:keys [customization-color theme]}] | ||
{:color (colors/resolve-color customization-color theme 60)}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
(:require | ||
[clojure.string :as string] | ||
[quo.components.avatars.account-avatar.style :as style] | ||
[quo.components.markdown.text :as text] | ||
[quo.theme :as quo.theme] | ||
[react-native.core :as rn])) | ||
|
||
|
@@ -17,18 +18,26 @@ | |
:customization-color - keyword or hexstring -> :blue/:army/... or #ABCEDF | ||
|
||
:theme - keyword -> :light/:dark" | ||
[{:keys [size emoji] | ||
:or {size style/default-size | ||
emoji "🍑"} | ||
[{:keys [size emoji account-name-initials emoji?] | ||
:or {size style/default-size | ||
emoji "🍑" | ||
emoji? true} | ||
Comment on lines
+21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small tweak 🔧 |
||
:as opts}] | ||
(let [theme (quo.theme/use-theme) | ||
emoji-size (style/get-emoji-size size)] | ||
[rn/view | ||
{:accessible true | ||
:accessibility-label :account-avatar | ||
:style (style/root-container opts theme)} | ||
[rn/text | ||
{:accessibility-label :account-emoji | ||
:adjusts-font-size-to-fit true | ||
:style {:font-size emoji-size}} | ||
(when emoji (string/trim emoji))]])) | ||
(if emoji? | ||
[rn/text | ||
{:accessibility-label :account-emoji | ||
:adjusts-font-size-to-fit true | ||
:style {:font-size emoji-size}} | ||
(when emoji (string/trim emoji))] | ||
[text/text | ||
{:accessibility-label :account-name | ||
:size :heading-1 | ||
:weight :medium | ||
:style (style/account-name opts)} | ||
account-name-initials])])) | ||
Comment on lines
+21
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add support for initials as saved addresses don't have emojis.
Comment on lines
+39
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tiny suggestion 🔖 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,8 +34,6 @@ | |
(map :short-name networks)) | ||
address-text [text/text | ||
{:size size | ||
;; TODO: monospace font | ||
;; https://github.com/status-im/status-mobile/issues/17009 | ||
Comment on lines
-37
to
-38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deleting a duplicated comment |
||
:weight (or weight :monospace) | ||
:style (style/address-text format blur? theme)} | ||
(if (= format :short) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
[react-native.safe-area :as safe-area] | ||
[status-im.common.resources :as resources] | ||
[status-im.contexts.settings.wallet.saved-addresses.style :as style] | ||
[status-im.feature-flags :as ff] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf])) | ||
|
||
|
@@ -17,12 +18,27 @@ | |
:image (resources/get-themed-image :sweating-man theme) | ||
:container-style style/empty-container-style}])) | ||
|
||
(defn on-press-add-saved-address | ||
[] | ||
(when (ff/enabled? ::ff/wallet.enable-saving-addresses) | ||
(rf/dispatch [:wallet/add-address-to-save | ||
{:title :t/add-address | ||
:description :t/save-address-description | ||
:input-title :t/address-or-ens-name | ||
:accessibility-label :add-address-to-save | ||
:screen :screen/wallet.add-address-to-save | ||
:confirm-screen :screen/wallet.confirm-address-to-save | ||
:confirm-screen-props {:button-label :t/save-address | ||
:address-type :t/address | ||
:placeholder :t/address-name}}]))) | ||
|
||
Comment on lines
+23
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only enable the plus button to work if the feature flag is enabled. |
||
(defn view | ||
[] | ||
(let [inset-top (safe-area/get-top) | ||
customization-color (rf/sub [:profile/customization-color]) | ||
saved-addresses [] | ||
saved-addresses? (rf/sub [:wallet/saved-addresses?]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A quicker and cleaner subscription to check if there's any saved-addresses. |
||
navigate-back (rn/use-callback #(rf/dispatch [:navigate-back]))] | ||
(rn/use-mount #(rf/dispatch [:wallet/get-saved-addresses])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fetch saved addresses on component mount. |
||
[quo/overlay | ||
{:type :shell | ||
:container-style (style/page-wrapper inset-top)} | ||
|
@@ -36,7 +52,8 @@ | |
{:title (i18n/label :t/saved-addresses) | ||
:accessibility-label :saved-addresses-header | ||
:right :action | ||
:on-press on-press-add-saved-address | ||
:customization-color customization-color | ||
:icon :i/add}]] | ||
(when-not (seq saved-addresses) | ||
(when-not saved-addresses? | ||
[empty-state])])) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns status-im.contexts.wallet.add-account.add-address-to-save.style) | ||
|
||
(def header-container {:padding-bottom 8}) | ||
|
||
(def info-message | ||
{:margin-top 8 | ||
:margin-left 20}) | ||
Comment on lines
+1
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a file rename/relocation only. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
(ns status-im.contexts.wallet.add-account.add-address-to-save.view | ||
(:require | ||
[clojure.string :as string] | ||
[quo.core :as quo] | ||
[react-native.core :as rn] | ||
[status-im.common.floating-button-page.view :as floating-button-page] | ||
[status-im.contexts.wallet.add-account.add-address-to-save.style :as style] | ||
[status-im.contexts.wallet.common.activity-indicator.view :as activity-indicator] | ||
[status-im.contexts.wallet.common.address-input.view :as address-input] | ||
[status-im.contexts.wallet.utils :as wallet.utils] | ||
[status-im.subs.wallet.add-account.address-to-watch] | ||
[utils.ens.core :as utils.ens] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf])) | ||
|
||
(defn- on-press-confirm-add-address-to-save | ||
[input-value] | ||
(rf/dispatch | ||
[:wallet/confirm-add-address-to-save | ||
{:address input-value | ||
:ens? (utils.ens/is-valid-eth-name? | ||
input-value)}])) | ||
|
||
(defn view | ||
[] | ||
(let [addresses (rf/sub [:wallet/lowercased-saved-addresses]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A new sub to use lowercased addresses, Because when there's case changes in addresses text duplication is hard to detect. |
||
{:keys [title description input-title accessibility-label]} | ||
(rf/sub [:wallet/currently-added-address]) | ||
validate #(wallet.utils/validate-fn % addresses) | ||
customization-color (rf/sub [:profile/customization-color])] | ||
(wallet.utils/clear-activity-and-scanned-address) | ||
(fn [] | ||
(let [activity-state (rf/sub [:wallet/watch-address-activity-state]) | ||
validated-address (rf/sub [:wallet/watch-address-validated-address]) | ||
[input-value set-input-value] (rn/use-state nil) | ||
[validation-msg set-validation-message] (rn/use-state nil) | ||
clear-input (fn [] | ||
(set-input-value nil) | ||
(set-validation-message nil) | ||
(wallet.utils/clear-activity-and-scanned-address))] | ||
Comment on lines
+35
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use state hooks instead of ratoms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure, but I think we're not using the form-2 style components either (?) |
||
[rn/view | ||
{:style {:flex 1}} | ||
[floating-button-page/view | ||
{:header [quo/page-nav | ||
{:type :no-title | ||
:icon-name :i/close | ||
:on-press wallet.utils/on-press-close}] | ||
:footer [quo/button | ||
{:customization-color customization-color | ||
:disabled? (or (string/blank? input-value) | ||
(some? (validate input-value)) | ||
(= activity-state :invalid-ens) | ||
(= activity-state :scanning) | ||
(not validated-address)) | ||
:on-press (fn [] | ||
(on-press-confirm-add-address-to-save input-value) | ||
(clear-input)) | ||
Comment on lines
+55
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be |
||
:container-style {:z-index 2}} | ||
(i18n/label :t/continue)]} | ||
[quo/page-top | ||
{:container-style style/header-container | ||
:title (i18n/label title) | ||
:description :text | ||
:description-text (i18n/label description)}] | ||
[address-input/view | ||
{:input-value input-value | ||
:validate validate | ||
:validation-msg validation-msg | ||
:clear-input clear-input | ||
:set-validation-message set-validation-message | ||
:set-input-value set-input-value | ||
:input-title (i18n/label input-title) | ||
:accessibility-label accessibility-label}] | ||
(if validation-msg | ||
[quo/info-message | ||
{:accessibility-label :error-message | ||
:size :default | ||
:icon :i/info | ||
:type :error | ||
:style style/info-message} | ||
validation-msg] | ||
[activity-indicator/view activity-state])]])))) |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests updates