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

feat: implement saved address list item component #17398

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

briansztamfater
Copy link
Member

@briansztamfater briansztamfater commented Sep 22, 2023

fixes #17302

Summary

Implement Saved Address List Item component

Screenshots

Platforms

  • Android
  • iOS

Steps to test

  • Open Status
  • Open Quo2 previews
  • Select List Items > Saved Address
  • Verify correct design and behavior of the component

status: ready

@briansztamfater briansztamfater added the feature feature requests label Sep 22, 2023
@briansztamfater briansztamfater self-assigned this Sep 22, 2023
@briansztamfater briansztamfater marked this pull request as draft September 22, 2023 15:19
@briansztamfater briansztamfater changed the base branch from develop to feat/account-list-item September 22, 2023 15:22
@status-im-auto
Copy link
Member

status-im-auto commented Sep 22, 2023

Jenkins Builds

Click to see older builds (24)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ a66e40f #3 2023-09-22 15:28:49 ~6 min android-e2e 🤖apk 📲
✔️ a66e40f #3 2023-09-22 15:29:35 ~7 min ios 📱ipa 📲
✔️ a66e40f #3 2023-09-22 15:32:23 ~10 min android 🤖apk 📲
✔️ a66e40f #3 2023-09-22 15:32:45 ~10 min tests 📄log
✔️ 611e1f6 #6 2023-09-22 16:15:35 ~5 min android-e2e 🤖apk 📲
✔️ 611e1f6 #6 2023-09-22 16:17:44 ~7 min ios 📱ipa 📲
✔️ 611e1f6 #6 2023-09-22 16:19:14 ~9 min android 🤖apk 📲
✔️ 611e1f6 #6 2023-09-22 16:19:28 ~9 min tests 📄log
✔️ dac8a82 #7 2023-09-22 22:08:39 ~5 min android 🤖apk 📲
✔️ dac8a82 #7 2023-09-22 22:08:41 ~5 min android-e2e 🤖apk 📲
✔️ dac8a82 #7 2023-09-22 22:09:33 ~6 min ios 📱ipa 📲
✔️ dac8a82 #7 2023-09-22 22:11:46 ~8 min tests 📄log
✔️ ac787c0 #10 2023-09-22 22:18:58 ~6 min android-e2e 🤖apk 📲
✔️ ac787c0 #9 2023-09-22 22:19:04 ~6 min android 🤖apk 📲
✔️ ac787c0 #9 2023-09-22 22:19:28 ~6 min ios 📱ipa 📲
✔️ ac787c0 #9 2023-09-22 22:21:35 ~8 min tests 📄log
✔️ 0961568 #10 2023-09-23 00:31:22 ~6 min ios 📱ipa 📲
✔️ 0961568 #10 2023-09-23 00:32:34 ~7 min android 🤖apk 📲
✔️ 0961568 #11 2023-09-23 00:33:11 ~8 min android-e2e 🤖apk 📲
✔️ 0961568 #10 2023-09-23 00:34:23 ~9 min tests 📄log
✔️ b8128e4 #11 2023-09-27 18:20:20 ~9 min ios 📱ipa 📲
✔️ b8128e4 #12 2023-09-27 18:20:39 ~9 min android-e2e 🤖apk 📲
✔️ b8128e4 #11 2023-09-27 18:20:56 ~9 min android 🤖apk 📲
✔️ b8128e4 #11 2023-09-27 18:21:43 ~10 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 388ac8d #12 2023-09-27 22:53:03 ~8 min ios 📱ipa 📲
✔️ 388ac8d #12 2023-09-27 22:54:31 ~9 min android 🤖apk 📲
✔️ 388ac8d #13 2023-09-27 22:54:43 ~9 min android-e2e 🤖apk 📲
✔️ 388ac8d #12 2023-09-27 22:55:27 ~10 min tests 📄log
✔️ 981b5e5 #13 2023-09-28 14:28:31 ~6 min ios 📱ipa 📲
✔️ 981b5e5 #14 2023-09-28 14:31:15 ~9 min android-e2e 🤖apk 📲
✔️ 981b5e5 #13 2023-09-28 14:31:31 ~9 min android 🤖apk 📲
✔️ 981b5e5 #13 2023-09-28 14:32:26 ~10 min tests 📄log

@briansztamfater briansztamfater force-pushed the feat/saved-address-item branch 2 times, most recently from 2bcbe1a to 611e1f6 Compare September 22, 2023 16:09
@briansztamfater briansztamfater changed the title [WIP] feat: implement saved address item component [WIP] feat: implement saved address list item component Sep 22, 2023
@briansztamfater briansztamfater changed the title [WIP] feat: implement saved address list item component feat: implement saved address list item component Sep 22, 2023
@briansztamfater briansztamfater marked this pull request as ready for review September 22, 2023 22:05
@briansztamfater briansztamfater changed the base branch from feat/account-list-item to develop September 22, 2023 22:11
@briansztamfater briansztamfater force-pushed the feat/saved-address-item branch 2 times, most recently from ac787c0 to 0961568 Compare September 23, 2023 00:24
Comment on lines +1 to +4
(ns quo2.components.list-items.saved-address.component-spec
(:require [test-helpers.component :as h]
[quo2.components.list-items.saved-address.view :as saved-address]
[quo2.foundations.colors :as colors]))
Copy link
Contributor

Choose a reason for hiding this comment

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

I see tests for many styles in this file. I think we were talking about that sometime earlier that we shouldn't be testing styles? 🤔 cc @ilmotta @J-Son89

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, actually, I just wanted to test backgroundColor, not the entire style, but I didn't find a better way to do it. Of course I am open to change the approach if you have any suggestion, or to remove these tests entirely if they don't add too much value. Honestly, I don't have a strong opinion about this and I am not 100% sure about these tests.

Copy link
Contributor

@ilmotta ilmotta Sep 26, 2023

Choose a reason for hiding this comment

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

Yeah, I remember those discussions @OmarBasem. I tend to almost never say, "don't test that" because usually if the developer went into the trouble of writing a unit test that was useful for them to solve a problem, that probably means it's going to be valuable to other devs in the future.

I don't have a strong opinion, but if a developer wants to test some styles because they do more complicated calculations, that's good IMO. We just don't need to make that a rule, since it's probably an exception.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to just check for backgroundColor which is the only style prop that needs to be tested 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

sure, all sounds good to me 👍

theme]
:or {customization-color :blue
blur? false}}]
(let [names (string/split (:name user-props) " ")
Copy link
Contributor

@ilmotta ilmotta Sep 26, 2023

Choose a reason for hiding this comment

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

Note that string/split will return [""] when user-props is nil. I haven't checked if this is a problem, but it seems better if an empty seq was returned for your use case, otherwise a check like (seq names) would return true.

(string/split nil " ") ; => ("")

Something like this may be better:

(remove string/blank? (string/split nil " ")) ; => ()

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, I added some extra validation because this suggestion made the avatar component to crash if nil is passed as first or last name

:title "Alisher Yakupov"
:address "0x21a...49e"
:on-options-press #(js/alert "Options button pressed!")})]
(fn [] [preview/preview-container
Copy link
Contributor

Choose a reason for hiding this comment

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

A line break should be added after [].

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 😄

:show-blur-background? true
:blur-dark-only? true}
[quo/saved-address
(merge @state
Copy link
Contributor

Choose a reason for hiding this comment

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

assoc is more precise here since you always overwrite :user-props.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, updated with assoc instead of merge

:on-press-in on-press-in
:on-press-out on-press-out
:accessibility-label :container}
[rn/view {:style style/left-container}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a suggestion to break the tree to reduce the re-rendering overhead.

The difference here is that Reagent won't re-compute left-container when state, timer, active?, on-press, and on-options-press are changed.

diff --git a/src/quo2/components/list_items/saved_address/view.cljs b/src/quo2/components/list_items/saved_address/view.cljs
index ace513201..e21d19d02 100644
--- a/src/quo2/components/list_items/saved_address/view.cljs
+++ b/src/quo2/components/list_items/saved_address/view.cljs
@@ -9,6 +9,29 @@
             [quo2.components.icon :as icon]
             [clojure.string :as string]))
 
+(defn left-container
+  [{:keys [blur? theme name address customization-color]}]
+  (let [names      (string/split name " ")
+        first-name (first names)
+        last-name  (last names)]
+    [rn/view {:style style/left-container}
+     [wallet-user-avatar/wallet-user-avatar
+      {:size   :medium
+       :f-name first-name
+       :l-name last-name
+       :color  customization-color}]
+     [rn/view {:style style/account-container}
+      [text/text
+       {:weight :semi-bold
+        :size   :paragraph-1}
+       name]
+      [text/text {:size :paragraph-2}
+       [text/text
+        {:size   :paragraph-2
+         :weight :monospace
+         :style  (style/account-address blur? theme)}
+        address]]]]))
+
 (defn- internal-view
   []
   (let [state       (reagent/atom :default)
@@ -23,10 +46,7 @@
                  theme]
           :or   {customization-color :blue
                  blur?               false}}]
-      (let [names        (string/split (:name user-props) " ")
-            first-name   (first names)
-            last-name    (last names)
-            on-press-out (fn []
+      (let [on-press-out (fn []
                            (let [new-state (if @active? :default :active)]
                              (when @timer (js/clearTimeout @timer))
                              (reset! timer nil)
@@ -40,23 +60,12 @@
           :on-press-in         on-press-in
           :on-press-out        on-press-out
           :accessibility-label :container}
-         [rn/view {:style style/left-container}
-          [wallet-user-avatar/wallet-user-avatar
-           {:size   :medium
-            :f-name first-name
-            :l-name last-name
-            :color  (:customization-color user-props)}]
-          [rn/view {:style style/account-container}
-           [text/text
-            {:weight :semi-bold
-             :size   :paragraph-1}
-            (:name user-props)]
-           [text/text {:size :paragraph-2}
-            [text/text
-             {:size   :paragraph-2
-              :weight :monospace
-              :style  (style/account-address blur? theme)}
-             (:address user-props)]]]]
+         [left-container
+          {:blur?               blur?
+           :theme               theme
+           :name                (:name user-props)
+           :address             (:address user-props)
+           :customization-color (:customization-color user-props)}]
          [rn/pressable
           {:accessibility-label :options-button
            :on-press            #(when on-options-press

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, updated implementation

(let [state (reagent/atom {:type :default
:customization-color :blue
:account-color :pink
:title "Alisher Yakupov"
Copy link
Contributor

Choose a reason for hiding this comment

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

The descriptor should allow the dev/designer to at least change title as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added 👍

@briansztamfater
Copy link
Member Author

@Francesca-G can you review this component please?

(defn- background-color
[{:keys [state blur? customization-color]}]
(cond (and (or (= state :pressed) (= state :selected)) (not blur?))
(colors/custom-color customization-color 50 5)
Copy link
Contributor

Choose a reason for hiding this comment

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

should these not be themed? 50 for light and 60 for dark ? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Based on Figma, it uses the same color for both themes


(defn- left-container
[{:keys [blur? theme name address customization-color]}]
(let [names (remove string/blank? (string/split name " "))
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we have some utility function to handle this already?

ah I just checked, we have this for initials but not for names (as far as I can see)
get-initials in src/utils/string.cljs
perhaps we add this method there too? 🤔
cc @ulisesmac

Copy link

@Francesca-G Francesca-G left a comment

Choose a reason for hiding this comment

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

Looks good ✨

@briansztamfater briansztamfater merged commit 5ea7808 into develop Sep 28, 2023
@briansztamfater briansztamfater deleted the feat/saved-address-item branch September 28, 2023 15:13
ibrkhalil pushed a commit that referenced this pull request Oct 1, 2023
clauxx pushed a commit that referenced this pull request Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature feature requests
Projects
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

Implement List Items > Saved Address component
7 participants