Skip to content
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

Closed
wants to merge 38 commits into from

Conversation

ibrkhalil
Copy link
Contributor

@ibrkhalil ibrkhalil commented Apr 25, 2024

fixes #19796, #19765, #19766, #19764

Summary

This PR refactors the add address to watch component and makes it reusable, It abstracts the definition of the title, subtitle and the event that's going to be executed after the user proceeds after typing/scanning an ETH address or ENS name.

Review notes

The previous add address to watch should be tested to make sure no regressions happened and the addition of saved addresses will be under a feature flag as it's still WIP (The addition is added but the rendering of the accounts isn't here so you can add addresses but they won't show up lolz).

Add address to watch flow:
CleanShot 2024-05-13 at 10 56 04

Add saved address flow:
CleanShot 2024-05-13 at 10 52 31

Testing notes

Please only test that adding addresses to watch isn't broken.

Platforms

  • Android
  • iOS

Areas that maybe impacted

Adding addresses to watch

Functional
  • wallet / transactions

Steps to test

  • Open Status
  • Try adding address to watch by scanning or by entering an ETH or ENS address.

Before and after screenshots comparison

Not required

status: ready

@ibrkhalil ibrkhalil self-assigned this Apr 25, 2024
@ibrkhalil ibrkhalil changed the title Refactor: Add address to watch component and make it generic Refactor: Add address to watch component and make it generic and use it in add saved addresses screen Apr 25, 2024
@status-im-auto
Copy link
Member

status-im-auto commented Apr 25, 2024

Jenkins Builds

Click to see older builds (140)
Commit #️⃣ Finished (UTC) Duration Platform Result
c75bd3e #1 2024-04-25 11:38:53 ~2 min tests 📄log
✔️ c75bd3e #1 2024-04-25 11:42:21 ~6 min android-e2e 🤖apk 📲
✔️ c75bd3e #1 2024-04-25 11:42:39 ~6 min android 🤖apk 📲
✔️ c75bd3e #1 2024-04-25 11:44:55 ~8 min ios 📱ipa 📲
82a69ea #2 2024-04-25 11:54:21 ~2 min tests 📄log
✔️ 82a69ea #3 2024-04-25 11:58:57 ~7 min android 🤖apk 📲
✔️ 82a69ea #3 2024-04-25 11:58:59 ~7 min android-e2e 🤖apk 📲
✔️ 82a69ea #3 2024-04-25 12:02:26 ~10 min ios 📱ipa 📲
✔️ 458c7e1 #4 2024-04-25 15:29:57 ~4 min tests 📄log
✔️ 458c7e1 #5 2024-04-25 15:34:11 ~8 min android 🤖apk 📲
✔️ 458c7e1 #5 2024-04-25 15:34:27 ~8 min android-e2e 🤖apk 📲
✔️ 458c7e1 #5 2024-04-25 15:35:58 ~10 min ios 📱ipa 📲
✔️ 1cc2f2f #5 2024-04-25 15:44:27 ~3 min tests 📄log
✔️ 1cc2f2f #6 2024-04-25 15:46:38 ~6 min android 🤖apk 📲
✔️ 1cc2f2f #6 2024-04-25 15:49:05 ~8 min android-e2e 🤖apk 📲
✔️ 1cc2f2f #6 2024-04-25 15:53:48 ~13 min ios 📱ipa 📲
✔️ 7dcb21f #6 2024-04-25 19:59:53 ~4 min tests 📄log
✔️ 7dcb21f #7 2024-04-25 20:03:16 ~8 min android-e2e 🤖apk 📲
✔️ 7dcb21f #7 2024-04-25 20:03:17 ~8 min android 🤖apk 📲
✔️ 7dcb21f #7 2024-04-25 20:03:50 ~8 min ios 📱ipa 📲
6941451 #7 2024-04-26 08:00:37 ~2 min tests 📄log
✔️ 6941451 #8 2024-04-26 08:04:44 ~6 min android-e2e 🤖apk 📲
✔️ 6941451 #8 2024-04-26 08:04:52 ~6 min android 🤖apk 📲
9cd5f68 #8 2024-04-26 08:09:03 ~2 min tests 📄log
✔️ 9cd5f68 #9 2024-04-26 08:14:31 ~8 min ios 📱ipa 📲
✔️ 9cd5f68 #9 2024-04-26 08:14:34 ~8 min android-e2e 🤖apk 📲
✔️ 9cd5f68 #9 2024-04-26 08:14:40 ~8 min android 🤖apk 📲
f2f2b97 #9 2024-04-26 08:21:13 ~2 min tests 📄log
1abf3a5 #10 2024-04-26 08:27:55 ~2 min tests 📄log
✔️ 1abf3a5 #11 2024-04-26 08:31:09 ~5 min android-e2e 🤖apk 📲
✔️ 1abf3a5 #11 2024-04-26 08:31:15 ~5 min android 🤖apk 📲
✔️ 1abf3a5 #11 2024-04-26 08:34:13 ~8 min ios 📱ipa 📲
4b46fe0 #12 2024-04-26 09:25:02 ~2 min tests 📄log
✔️ 4b46fe0 #13 2024-04-26 09:28:29 ~5 min android-e2e 🤖apk 📲
✔️ 4b46fe0 #13 2024-04-26 09:29:31 ~6 min android 🤖apk 📲
✔️ 4b46fe0 #13 2024-04-26 09:31:02 ~8 min ios 📱ipa 📲
6edd011 #13 2024-04-26 10:05:50 ~2 min tests 📄log
b118065 #14 2024-04-26 10:12:23 ~2 min tests 📄log
✔️ b118065 #15 2024-04-26 10:15:35 ~5 min android 🤖apk 📲
✔️ b118065 #15 2024-04-26 10:16:28 ~6 min android-e2e 🤖apk 📲
✔️ b118065 #15 2024-04-26 10:18:02 ~8 min ios 📱ipa 📲
✔️ f7ecbdc #15 2024-04-26 10:37:37 ~4 min tests 📄log
✔️ f7ecbdc #16 2024-04-26 10:39:19 ~5 min android 🤖apk 📲
✔️ f7ecbdc #16 2024-04-26 10:40:17 ~6 min android-e2e 🤖apk 📲
✔️ f7ecbdc #16 2024-04-26 10:41:56 ~8 min ios 📱ipa 📲
✔️ 3b68e21 #16 2024-04-26 15:03:33 ~4 min tests 📄log
75cde66 #18 2024-04-26 15:08:26 ~2 min tests 📄log
✔️ 75cde66 #19 2024-04-26 15:11:36 ~5 min android 🤖apk 📲
✔️ 75cde66 #19 2024-04-26 15:12:40 ~6 min android-e2e 🤖apk 📲
✔️ d00dae0 #19 2024-04-26 15:18:00 ~4 min tests 📄log
✔️ d00dae0 #20 2024-04-26 15:21:44 ~8 min android 🤖apk 📲
✔️ d00dae0 #20 2024-04-26 15:21:45 ~8 min android-e2e 🤖apk 📲
✔️ d00dae0 #20 2024-04-26 15:21:47 ~8 min ios 📱ipa 📲
5e23cf9 #20 2024-05-03 12:12:11 ~2 min tests 📄log
✔️ 5e23cf9 #21 2024-05-03 12:17:22 ~7 min android-e2e 🤖apk 📲
✔️ 5e23cf9 #21 2024-05-03 12:17:23 ~7 min android 🤖apk 📲
✔️ 5e23cf9 #21 2024-05-03 12:17:47 ~8 min ios 📱ipa 📲
5bde748 #22 2024-05-03 15:12:35 ~2 min tests 📄log
✔️ 5bde748 #23 2024-05-03 15:16:41 ~6 min android 🤖apk 📲
✔️ 5bde748 #23 2024-05-03 15:16:46 ~6 min android-e2e 🤖apk 📲
✔️ 5bde748 #23 2024-05-03 15:19:32 ~9 min ios 📱ipa 📲
✔️ d55e54c #23 2024-05-03 15:56:37 ~3 min tests 📄log
✔️ d55e54c #24 2024-05-03 15:58:23 ~5 min android-e2e 🤖apk 📲
✔️ d55e54c #24 2024-05-03 15:58:27 ~5 min android 🤖apk 📲
✔️ d55e54c #24 2024-05-03 16:01:03 ~8 min ios 📱ipa 📲
✔️ 5b4d8d1 #25 2024-05-04 10:00:47 ~4 min tests 📄log
✔️ 5b4d8d1 #26 2024-05-04 10:03:29 ~6 min android-e2e 🤖apk 📲
✔️ 5b4d8d1 #26 2024-05-04 10:03:33 ~6 min android 🤖apk 📲
✔️ 5b4d8d1 #26 2024-05-04 10:05:57 ~9 min ios 📱ipa 📲
✔️ 821570a #26 2024-05-04 10:45:52 ~4 min tests 📄log
✔️ 821570a #27 2024-05-04 10:49:37 ~8 min android-e2e 🤖apk 📲
✔️ 821570a #27 2024-05-04 10:49:40 ~8 min android 🤖apk 📲
✔️ 821570a #27 2024-05-04 10:49:47 ~8 min ios 📱ipa 📲
✔️ 3f5208e #27 2024-05-04 11:15:42 ~3 min tests 📄log
✔️ 3f5208e #28 2024-05-04 11:18:38 ~6 min android-e2e 🤖apk 📲
✔️ 3f5208e #28 2024-05-04 11:18:41 ~6 min android 🤖apk 📲
✔️ 3f5208e #28 2024-05-04 11:19:57 ~8 min ios 📱ipa 📲
✔️ 9de279c #28 2024-05-04 11:28:11 ~4 min tests 📄log
✔️ 9de279c #29 2024-05-04 11:31:50 ~7 min android-e2e 🤖apk 📲
✔️ 9de279c #29 2024-05-04 11:32:00 ~8 min android 🤖apk 📲
✔️ 9de279c #29 2024-05-04 11:32:10 ~8 min ios 📱ipa 📲
e31d86d #29 2024-05-04 11:49:51 ~2 min tests 📄log
✔️ e31d86d #30 2024-05-04 11:54:53 ~7 min android-e2e 🤖apk 📲
✔️ e31d86d #30 2024-05-04 11:54:58 ~7 min android 🤖apk 📲
✔️ e31d86d #30 2024-05-04 11:55:22 ~8 min ios 📱ipa 📲
✔️ 4b595df #30 2024-05-05 12:42:45 ~3 min tests 📄log
✔️ 4b595df #31 2024-05-05 12:46:34 ~7 min android-e2e 🤖apk 📲
✔️ 4b595df #31 2024-05-05 12:46:40 ~7 min android 🤖apk 📲
✔️ 4b595df #31 2024-05-05 12:47:47 ~8 min ios 📱ipa 📲
✔️ a2766eb #33 2024-05-06 13:38:08 ~3 min tests 📄log
✔️ a2766eb #34 2024-05-06 13:42:01 ~7 min android 🤖apk 📲
✔️ a2766eb #34 2024-05-06 13:43:43 ~9 min ios 📱ipa 📲
cf0ae13 #34 2024-05-06 16:30:32 ~1 min tests 📄log
✔️ cf0ae13 #35 2024-05-06 16:34:37 ~5 min android-e2e 🤖apk 📲
✔️ cf0ae13 #35 2024-05-06 16:35:01 ~6 min android 🤖apk 📲
✔️ cf0ae13 #35 2024-05-06 16:37:22 ~8 min ios 📱ipa 📲
✔️ 0007c35 #36 2024-05-07 08:51:18 ~5 min android-e2e 🤖apk 📲
✔️ 0007c35 #36 2024-05-07 10:11:32 ~9 min ios 📱ipa 📲
✔️ 0007c35 #36 2024-05-07 10:48:25 ~5 min android 🤖apk 📲
✔️ 0007c35 #35 2024-05-07 11:05:23 ~3 min tests 📄log
✔️ 6837c2c #36 2024-05-07 12:34:47 ~4 min tests 📄log
✔️ 6837c2c #37 2024-05-07 12:36:31 ~5 min android 🤖apk 📲
✔️ 6837c2c #37 2024-05-07 12:37:35 ~7 min android-e2e 🤖apk 📲
✔️ 6837c2c #37 2024-05-07 12:41:01 ~10 min ios 📱ipa 📲
✔️ c9528d8 #37 2024-05-08 04:15:14 ~4 min tests 📄log
✔️ c9528d8 #38 2024-05-08 04:19:22 ~8 min ios 📱ipa 📲
✔️ c9528d8 #38 2024-05-08 04:21:53 ~10 min android-e2e 🤖apk 📲
✔️ c9528d8 #38 2024-05-08 04:22:05 ~10 min android 🤖apk 📲
✔️ fe766d8 #38 2024-05-08 09:18:16 ~3 min tests 📄log
✔️ fe766d8 #39 2024-05-08 09:21:14 ~6 min android-e2e 🤖apk 📲
✔️ fe766d8 #39 2024-05-08 09:21:15 ~7 min android 🤖apk 📲
✔️ fe766d8 #39 2024-05-08 09:23:23 ~9 min ios 📱ipa 📲
✔️ af2cab1 #39 2024-05-10 18:07:44 ~7 min tests 📄log
✔️ af2cab1 #40 2024-05-10 18:08:34 ~8 min android-e2e 🤖apk 📲
✔️ af2cab1 #40 2024-05-10 18:08:38 ~8 min android 🤖apk 📲
✔️ af2cab1 #40 2024-05-10 18:09:14 ~8 min ios 📱ipa 📲
4e2f6d5 #41 2024-05-10 18:28:55 ~27 sec ios 📄log
4e2f6d5 #41 2024-05-10 18:29:01 ~32 sec android-e2e 📄log
4e2f6d5 #41 2024-05-10 18:29:01 ~32 sec android 📄log
4e2f6d5 #40 2024-05-10 18:30:09 ~1 min tests 📄log
b97a40d #42 2024-05-11 03:47:25 ~25 sec ios 📄log
b97a40d #42 2024-05-11 03:47:31 ~37 sec android-e2e 📄log
b97a40d #42 2024-05-11 03:47:38 ~39 sec android 📄log
b97a40d #41 2024-05-11 03:48:35 ~1 min tests 📄log
✔️ 8f15829 #42 2024-05-11 03:52:51 ~3 min tests 📄log
✔️ 8f15829 #43 2024-05-11 03:57:49 ~8 min ios 📱ipa 📲
✔️ 8f15829 #43 2024-05-11 03:58:44 ~9 min android-e2e 🤖apk 📲
✔️ 8f15829 #43 2024-05-11 03:58:44 ~9 min android 🤖apk 📲
✔️ 911cdfe #43 2024-05-11 04:18:24 ~4 min tests 📄log
✔️ 911cdfe #44 2024-05-11 04:22:36 ~8 min ios 📱ipa 📲
✔️ 911cdfe #44 2024-05-11 04:24:30 ~10 min android-e2e 🤖apk 📲
✔️ 911cdfe #44 2024-05-11 04:24:42 ~10 min android 🤖apk 📲
✔️ 258b1ec #45 2024-05-12 06:43:28 ~5 min tests 📄log
✔️ 258b1ec #46 2024-05-12 06:43:59 ~5 min android-e2e 🤖apk 📲
✔️ 258b1ec #46 2024-05-12 06:45:13 ~6 min android 🤖apk 📲
✔️ 258b1ec #46 2024-05-12 06:47:25 ~9 min ios 📱ipa 📲
c8805b5 #46 2024-05-12 10:08:55 ~2 min tests 📄log
✔️ c8805b5 #47 2024-05-12 10:14:01 ~7 min android-e2e 🤖apk 📲
✔️ c8805b5 #47 2024-05-12 10:14:05 ~7 min android 🤖apk 📲
✔️ c8805b5 #47 2024-05-12 10:14:44 ~8 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 6e0b8ae #47 2024-05-12 10:31:54 ~5 min tests 📄log
✔️ 6e0b8ae #48 2024-05-12 10:34:04 ~8 min android-e2e 🤖apk 📲
✔️ 6e0b8ae #48 2024-05-12 10:34:14 ~8 min android 🤖apk 📲
✔️ 6e0b8ae #48 2024-05-12 10:34:43 ~8 min ios 📱ipa 📲
✔️ 26b26f8 #48 2024-05-13 06:41:37 ~4 min tests 📄log
✔️ 26b26f8 #49 2024-05-13 06:42:56 ~5 min android 🤖apk 📲
✔️ 26b26f8 #49 2024-05-13 06:43:47 ~6 min android-e2e 🤖apk 📲
✔️ 26b26f8 #49 2024-05-13 06:45:43 ~8 min ios 📱ipa 📲

@ibrkhalil ibrkhalil changed the title Refactor: Add address to watch component and make it generic and use it in add saved addresses screen Refactor add address to watch component and make it generic and use it in add saved addresses screen Apr 25, 2024
@@ -36,6 +38,10 @@
{:title (i18n/label :t/saved-addresses)
:accessibility-label :saved-addresses-header
:right :action
:on-press (fn []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should probably declare this outside, you can check if it triggers a re-render of the overlay if the sub wallet/saved-addresses changes (I believe it will, but if you declare it outside, it should not)

@@ -21,8 +22,9 @@
[]
(let [inset-top (safe-area/get-top)
customization-color (rf/sub [:profile/customization-color])
saved-addresses []
saved-addresses (rf/sub [:wallet/saved-addresses])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take the plan is to actually use saved addresses eventually (in that case this is fine for the time being of course), but if you only are checking whether there's any saved addresses, you should subscribe only to (seq saved-addresses), so that the view re-renders only when you flip from 0 to 1 or viceversa (maybe I am missing where you use it though, but couldn't find it)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually (boolean (seq saved-addresses)) should be the subscription, (seq saved-addresses) is not good enough

placeholder (-> confirming-addresses-purposes
(get-in [purpose :placeholder])
i18n/label)
account-name (reagent/atom "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state/atoms?

:bottom-action-props {:customization-color @account-color
:disabled? (string/blank? @account-name)
:accessibility-label :confirm-button-label
:on-press (fn []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this function could be defined outside? it's rather large for an on-press handler

:weight :monospace}
address])
:container-style style/data-item
:on-press #(js/alert "To be implemented")}]]]])))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could define it outside, to show the right pattern, even if it's not implemented :)

(cond
(or (nil? user-input) (= user-input "")) nil
(contains? known-addresses user-input) (i18n/label :t/address-already-in-use)
(or (nil? user-input) (= user-input "")) nil
Copy link
Contributor

@cammellos cammellos Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(empty? user-input) nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty? doesn't cater for whitespace, I think it shouldn't be used for strings often

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use blank? of course, but that would be changing the functionality, not sure what the original intention of the code was, empty? should retain it, while blank adds some extra cases, but either are fine by me, but or looks unneccessary

(rf/dispatch [:wallet/clean-scanned-address]))
customization-color (rf/sub [:profile/customization-color])]
(let [addresses (rf/sub [:wallet/addresses])
lowercased-addresses (map string/lower-case addresses)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like probably you want this int the sub since you are not using addresses?

customization-color (rf/sub [:profile/customization-color])]
(let [addresses (rf/sub [:wallet/addresses])
lowercased-addresses (map string/lower-case addresses)
input-value (reagent/atom nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state/atom?


(def save-address-drawer-bar-container
{:position :absolute
:left "50%"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need percentages here, probably can be done without


(defn view
[]
(let [{:keys [address purpose ens?]} (rf/sub [:get-screen-params])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Purpose' here really lacks clarity of the use. It's very generic, is there something more informative we can use?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it also suggests that we would be better to abstract some pieces of this page but not the whole page, or at least have it configurable from outside rather than encapsulating these properties.
Wdyt @briansztamfater, it was a topic we talked about yesterday

(defn- validate-address
[known-addresses user-input]
[known-addresses user-input purpose]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo Better to pass the text (i18n label) than this generic purpose which is rather specific here

@ibrkhalil ibrkhalil force-pushed the refactor-add-addresses-to-watch-screen/logic branch from 9cd5f68 to f2f2b97 Compare April 26, 2024 08:17
@@ -17,12 +18,26 @@
:image (resources/get-themed-image :sweating-man theme)
:container-style style/empty-container-style}]))

(defn on-press
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe not the best name

:account-emoji account-emoji
:account-color account-color
:address address})}}
(prn "meg " button-label)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug

(rf/reg-sub
:wallet/addresses
:<- [:wallet]
:-> #(->> %
:accounts
keys
to-lower-case
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can create a separate subscription for this? wallet/lowercase-addresses based on this one, so we leverage caching

@ibrkhalil ibrkhalil marked this pull request as draft April 26, 2024 15:05
@ibrkhalil
Copy link
Contributor Author

Drafting till improvements are done.

@J-Son89
Copy link
Contributor

J-Son89 commented Apr 29, 2024

@ibrkhalil - since this pr is in draft now I'd suggest removing the request-manual-qa label. Imo we should only add this once the pr is truly ready for the pr process, i.e it has sufficient dev approvals etc 👍

@ibrkhalil ibrkhalil force-pushed the refactor-add-addresses-to-watch-screen/logic branch 2 times, most recently from d55e54c to 7fe3fa6 Compare May 4, 2024 09:55
@ibrkhalil ibrkhalil marked this pull request as ready for review May 4, 2024 11:23
@ibrkhalil ibrkhalil changed the title Refactor add address to watch component and make it generic and use it in add saved addresses screen Refactor add address to watch component and make it generic and use it in add saved addresses screen behind a FF May 4, 2024
@ibrkhalil ibrkhalil requested review from flexsurfer and removed request for shivekkhurana, smohamedjavid and ulisesmac May 4, 2024 11:24
@ibrkhalil ibrkhalil force-pushed the refactor-add-addresses-to-watch-screen/logic branch from abeefd0 to a2766eb Compare May 6, 2024 13:34
@ibrkhalil ibrkhalil force-pushed the refactor-add-addresses-to-watch-screen/logic branch from f7c439f to 258b1ec Compare May 12, 2024 06:38
@ibrkhalil ibrkhalil marked this pull request as ready for review May 13, 2024 06:37
@@ -56,23 +56,35 @@


(defn root-container
[{:keys [type size customization-color]
[{:keys [type size customization-color emoji?]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding text only (initials) styling to the emoji styling.

Comment on lines +81 to +85
: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)})))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main addition is border-radius, color and background-color

@@ -13,7 +13,7 @@

(h/test "with emoji"
(let [emoji "💸"]
(h/render [account-avatar/view {:emoji emoji :size 80}])
(h/render [account-avatar/view {:emoji emoji :size 80 :emoji? :true}])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests updates

Comment on lines +21 to +43
[{:keys [size emoji account-name-initials emoji?]
:or {size style/default-size
emoji "🍑"
emoji? true}
: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])]))
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 -37 to -38
;; TODO: monospace font
;; https://github.com/status-im/status-mobile/issues/17009
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting a duplicated comment

@@ -0,0 +1,12 @@
(ns status-im.contexts.wallet.common.address-input.style)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File moved only.

@@ -0,0 +1,63 @@
(ns status-im.contexts.wallet.common.address-input.view
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File moved only.

Comment on lines +30 to +37
account-name-initials (when-not emoji?
(->> (string/split (if (string/blank? account-name)
placeholder
account-name)
#" ")
(map (fn [segment]
(utils.string/get-initials segment 1)))
(apply str)))]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we have a helper that extracts initials from multiple whitespace-separated words?


(defn view
[{:keys [page-nav-right-side placeholder account-name account-color account-emoji
on-change-name
on-change-color
on-change-emoji section-label
bottom-action-label bottom-action-props
custom-bottom-action watch-only?]} & children]
custom-bottom-action watch-only? top-left-icon]} & children]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added top-left-icon to customize the exit icon.

@@ -11,7 +11,7 @@
[utils.re-frame :as rf]))

(defn view
[{:keys [selected-networks account watch-only?]}]
[{:keys [selected-networks account watch-only? sheet-title sheet-description]}]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added overrides.

Copy link
Member

@seanstrom seanstrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice stuff! I've done a first pass of a review 👍
I'll come back and do another pass soon 🔎

Comment on lines +21 to +24
[{:keys [size emoji account-name-initials emoji?]
:or {size style/default-size
emoji "🍑"
emoji? true}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small tweak 🔧
Do we need to pass emoji? as a prop?
Could we compute emoji? based on whether the emoji field is present (not nil)?

Comment on lines +39 to +43
{:accessibility-label :account-name
:size :heading-1
:weight :medium
:style (style/account-name opts)}
account-name-initials])]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny suggestion 🔖
maybe the :accessibility-label should be :account-initials or :account-name-initials?

Comment on lines +35 to +40
[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))]
Copy link
Member

Choose a reason for hiding this comment

The 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 (?)

Comment on lines +55 to +57
:on-press (fn []
(on-press-confirm-add-address-to-save input-value)
(clear-input))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be use-callback function if we want to avoid extra re-renders for the footer button.

Comment on lines +72 to +78
:on-press #(on-press-confirm-address-to-save
{:ens? ens?
:adding-address-purpose adding-address-purpose
:account-name account-name
:account-color account-color
:address address
:theme theme})}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be a use-callback if want to avoid extra re-renders for the bottom-action button.

Comment on lines +24 to +40
on-change-text (fn [new-text]
(set-validation-message (validate new-text))
(set-input-value new-text)
(reagent/flush)
(if (and (not (string/blank? new-text)) (nil? (validate new-text)))
(debounce/debounce-and-dispatch [:wallet/get-address-details new-text]
500)
(rf/dispatch [:wallet/clear-address-activity]))
(when (and scanned-address (not= scanned-address new-text))
(wallet.utils/clear-activity-and-scanned-address)))
paste-on-input #(clipboard/get-string
(fn [clipboard-text]
(on-change-text clipboard-text)))]
(rn/use-effect (fn []
(when-not (string/blank? scanned-address)
(on-change-text scanned-address)))
[scanned-address])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain a bit more why we reagent/flush?
Also it seems that this logic could be refactored into re-frame effects or even co-effects. Thoughts?

Comment on lines +25 to +28
(defn on-press-close
[]
(clear-activity-and-scanned-address)
(rf/dispatch [:navigate-back]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be renamed to something more specific, for example: close-wallet or on-close-wallet?

Comment on lines +814 to +818
(let [result (rf/sub [sub-name])]
(is (match? (:address result) (:address sample-added-address)))
(is (match? (:title result) (:title sample-added-address)))
(is (match? (:description result) (:description sample-added-address)))
(is (match? (:adding-address-purpose result) (:adding-address-purpose sample-added-address))))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be able to use select-keys and then use match? on two maps?

@smohamedjavid smohamedjavid self-assigned this May 23, 2024
@smohamedjavid
Copy link
Member

Taking over this PR. Marking this PR as a Draft until the reviews are addressed.

@smohamedjavid smohamedjavid marked this pull request as draft May 23, 2024 09:00
@smohamedjavid smohamedjavid removed their assignment May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

Refactor add address to watch component and make it generic/reusable
6 participants