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

Implement Quo2 Numbered-Keyboard / Keyboard Key component #16723

Merged
merged 6 commits into from
Aug 2, 2023

Conversation

mmilad75
Copy link
Contributor

This PR implements the Keyboard Key of the Numbered Keyboard.

fixes #16605

iOS Android
ios.mov
android.mov

Platforms

  • Android
  • iOS

Steps to test

  • Open Status
  • Go to Quo2 Preview
  • Keyboard > Keyboard Key

@status-im-auto
Copy link
Member

status-im-auto commented Jul 19, 2023

Jenkins Builds

Click to see older builds (40)
Commit #️⃣ Finished (UTC) Duration Platform Result
bcf96e6 #1 2023-07-19 17:12:41 ~4 min tests 📄log
✔️ bcf96e6 #1 2023-07-19 17:16:57 ~8 min ios 📱ipa 📲
✔️ bcf96e6 #1 2023-07-19 17:17:25 ~8 min android-e2e 🤖apk 📲
✔️ bcf96e6 #1 2023-07-19 17:17:30 ~8 min android 🤖apk 📲
✔️ 2e21723 #3 2023-07-24 19:08:35 ~6 min ios 📱ipa 📲
✔️ 2e21723 #3 2023-07-24 19:11:16 ~9 min android 🤖apk 📲
✔️ 2e21723 #3 2023-07-24 19:11:21 ~9 min android-e2e 🤖apk 📲
✔️ 2e21723 #3 2023-07-24 19:11:48 ~9 min tests 📄log
✔️ 1d8a856 #4 2023-07-25 11:21:08 ~5 min android 🤖apk 📲
✔️ 1d8a856 #4 2023-07-25 11:22:14 ~6 min ios 📱ipa 📲
✔️ 1d8a856 #4 2023-07-25 11:22:32 ~6 min android-e2e 🤖apk 📲
✔️ 1d8a856 #4 2023-07-25 11:25:18 ~9 min tests 📄log
✔️ fdd3de1 #5 2023-07-25 12:14:30 ~5 min android 🤖apk 📲
✔️ fdd3de1 #5 2023-07-25 12:16:29 ~7 min android-e2e 🤖apk 📲
✔️ fdd3de1 #5 2023-07-25 12:17:38 ~8 min ios 📱ipa 📲
✔️ fdd3de1 #5 2023-07-25 12:18:30 ~9 min tests 📄log
✔️ 2f1038c #6 2023-07-25 15:17:25 ~6 min android-e2e 🤖apk 📲
✔️ 2f1038c #6 2023-07-25 15:17:41 ~6 min android 🤖apk 📲
✔️ 2f1038c #6 2023-07-25 15:18:11 ~6 min ios 📱ipa 📲
✔️ 2f1038c #6 2023-07-25 15:20:04 ~8 min tests 📄log
✔️ 0245eef #7 2023-07-27 09:47:03 ~6 min ios 📱ipa 📲
✔️ 0245eef #7 2023-07-27 09:49:09 ~8 min android-e2e 🤖apk 📲
✔️ 0245eef #7 2023-07-27 09:49:26 ~8 min android 🤖apk 📲
✔️ 0245eef #7 2023-07-27 09:50:05 ~9 min tests 📄log
3eda399 #8 2023-07-27 11:17:15 ~2 min tests 📄log
✔️ 3eda399 #8 2023-07-27 11:20:47 ~6 min android-e2e 🤖apk 📲
✔️ 3eda399 #8 2023-07-27 11:20:53 ~6 min android 🤖apk 📲
✔️ 3eda399 #8 2023-07-27 11:21:08 ~6 min ios 📱ipa 📲
✔️ afb804d #9 2023-07-27 18:46:46 ~6 min ios 📱ipa 📲
✔️ afb804d #9 2023-07-27 18:49:23 ~9 min android 🤖apk 📲
✔️ afb804d #9 2023-07-27 18:49:23 ~9 min android-e2e 🤖apk 📲
✔️ afb804d #9 2023-07-27 18:49:48 ~9 min tests 📄log
✔️ a5ad16c #11 2023-07-28 10:18:04 ~6 min ios 📱ipa 📲
✔️ a5ad16c #11 2023-07-28 10:21:06 ~9 min android-e2e 🤖apk 📲
✔️ a5ad16c #11 2023-07-28 10:21:10 ~9 min android 🤖apk 📲
✔️ a5ad16c #11 2023-07-28 10:21:20 ~9 min tests 📄log
✔️ d6596c0 #12 2023-07-28 12:27:05 ~5 min android 🤖apk 📲
✔️ d6596c0 #12 2023-07-28 12:28:22 ~6 min ios 📱ipa 📲
✔️ d6596c0 #12 2023-07-28 12:28:59 ~7 min android-e2e 🤖apk 📲
✔️ d6596c0 #12 2023-07-28 12:30:13 ~8 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 0327bd7 #13 2023-08-01 15:50:04 ~6 min ios 📱ipa 📲
✔️ 0327bd7 #13 2023-08-01 15:52:13 ~8 min android 🤖apk 📲
✔️ 0327bd7 #13 2023-08-01 15:52:18 ~8 min android-e2e 🤖apk 📲
✔️ 0327bd7 #13 2023-08-01 15:53:25 ~10 min tests 📄log
✔️ cf71c5b #14 2023-08-01 18:42:28 ~7 min ios 📱ipa 📲
✔️ cf71c5b #14 2023-08-01 18:43:15 ~8 min android-e2e 🤖apk 📲
✔️ cf71c5b #14 2023-08-01 18:43:28 ~8 min android 🤖apk 📲
✔️ cf71c5b #14 2023-08-01 18:45:11 ~10 min tests 📄log

@@ -188,6 +189,9 @@
(def search-input quo2.components.inputs.search-input.view/search-input)
(def title-input quo2.components.inputs.title-input.view/title-input)

;;;; Keyboard
Copy link
Contributor

@J-Son89 J-Son89 Jul 19, 2023

Choose a reason for hiding this comment

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

nit: this should be upper case for consistency and also matching the area name, i.e
;;;; NUMBERED KEYBOARD

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

Just jumping in to share my perspective.

I wish we didn't follow this convention. It's also not in the Clojure Style Guide https://guide.clojure.style/#four-semicolons-for-heading-comments

For an Emacs user, heading comments can be easily syntax highlighted (even by level). Vim should probably have this capability but I'm not using it anymore.

But I totally get why devs using other editors opted for using the screaming case to differentiate between normal comments and heading comments :)

Copy link
Contributor

Choose a reason for hiding this comment

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

tbh I don't think there's much of a convention there, we can just change that file to use 4 afaik 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

@J-Son89, I meant the case of the text is all uppercased. I know this is not important, who cares about the case of the heading right? But anyway it's not in the Clojure style guide.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah apologies, yeah I think we can just update this so?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say so, our guidelines say we follow the CSG unless stated otherwise.

@@ -219,6 +220,10 @@
{:name :title-input
:options {:topBar {:visible true}}
:component title-input/preview-title-input}]
:keyboard [{:name :keyboard-key
Copy link
Contributor

@J-Son89 J-Son89 Jul 19, 2023

Choose a reason for hiding this comment

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

this key should match figma to make it easy for devs to know where it's corresponding to
i.e :keyboard -> :numbered-keyboard

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

(ns quo2.components.numbered-keyboard.keyboard-key.view
(:require [react-native.core :as rn]
[quo2.theme :as quo.theme]
[status-im.ui.components.icons.icons :as icons]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[status-im.ui.components.icons.icons :as icons]
[quo2.components.icon :as icons]

status-im namespace contain outdated code

Copy link
Contributor

Choose a reason for hiding this comment

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

yep, avoid using status-im and quo namespaces where possible :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

(defn- keyboard-key-internal
[{:keys [label? disabled theme blur? icon? on-press?]}]
(let [label-color (get-label-color disabled theme blur?)]
[rn/touchable-highlight
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I think we want to do this the same as the quo2 button component. That is we use the rn/touchable-without-feedback and have an internal state for pressed that we can set the background color on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

colors/neutral-100)))

(defn- keyboard-key-internal
[{:keys [label? disabled theme blur? icon? on-press?]}]
Copy link
Contributor

@ajayesivan ajayesivan Jul 19, 2023

Choose a reason for hiding this comment

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

Change disabled to disabled?. In Clojure we suffix boolean values with ?.

Ref: https://github.com/status-im/status-mobile/blob/develop/doc/new-guidelines.md#dont-prepend-booleans-with-is-

Is on-press?, label & icon? booleans?

edit: here the only boolean options are disabled and blur so you can change it to
[{:keys [label disabled? theme blur? icon on-press]}]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

colors/neutral-100)))

(defn- keyboard-key-internal
[{:keys [label? disabled theme blur? icon? 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.

in clojurescript ? is common practice for marking boolean variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

colors/white
colors/neutral-100)))

(defn- keyboard-key-internal
Copy link
Contributor

@J-Son89 J-Son89 Jul 19, 2023

Choose a reason for hiding this comment

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

for labels we have a common pattern as using the second parameter as the label.
i.e

(defn- keyboard-key-internal
  [{:keys [ disabled theme blur? icon? on-press?]} label]

I think we should try to stick with Figma here (even if it's a bit much in this case - it will align with best practices then)
e.g


(defn- keyboard-key-internal
[{:keys [disabled theme blur? icon? on-press? type]} label]
(let [label-color (get-label-color disabled theme blur?)]
  [rn/touchable-highlight
   {:active-opacity 1
    :underlay-color (cond
                      blur?            colors/white-opa-10
                      (= :light theme) colors/neutral-10
                      (= :dark theme)  colors/neutral-80)
    :disabled       disabled
    :on-press       on-press?
    :style          style/container}
   (cond 
     (= type :key)  [icons/icon label (style/icon label-color)]
     (= type :digit) [rn/text {:style (style/text label-color)} label])]))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

:style style/container}
(cond
icon? [icons/icon icon? (style/icon label-color)]
label? [rn/text {:style (style/text label-color)} label?])]))
Copy link
Contributor

Choose a reason for hiding this comment

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

we want to use quo2 text component here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

(defn text
[color]
{:color color
:font-size 27})
Copy link
Contributor

@J-Son89 J-Son89 Jul 19, 2023

Choose a reason for hiding this comment

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

these font sizes are all set by the quo2 text component, in quo2.components.markdown.text
color is already handled there too 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

[quo2.foundations.colors :as colors]
[quo2.components.numbered-keyboard.keyboard-key.style :as style]))

(defn- get-label-color
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should put this helper in the styles file 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

(defn icon
[color]
{:color color
:width 30
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't have any icons that are size "30" and in the component it's 20 which is the default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@J-Son89
Copy link
Contributor

J-Son89 commented Jul 19, 2023

let's add a simple component spec test, like a render of each type and an on press 👍

Copy link
Contributor

@ilmotta ilmotta left a comment

Choose a reason for hiding this comment

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

Hey @mmilad75, I'm not approving or disapproving your PR, but felt like sharing one or two comments :)

blur? colors/white-opa-10
(= :light theme) colors/neutral-10
(= :dark theme) colors/neutral-80)
"transparent"))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think here we should use a keyword to be consistent with the rest of the codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

[{:keys [disabled? theme blur? on-press type]} label]
(let [label-color (style/get-label-color disabled? theme blur?)
background-color (style/toggle-background-color @pressed? blur? theme)]
[rn/touchable-without-feedback
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should start to use rn/pressable, which I recently added to the namespace react-native.core. The new API is the way to go. It's just as simple :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@J-Son89 Jamie suggested to use rn/touchable-without-feedback. Please let me know which one should I go with? @ilmotta

Copy link
Contributor

Choose a reason for hiding this comment

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

pressable is good, as long as we set the styling to our own designs and not based on the react-native components internal stylings 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

If you're looking for a more extensive and future-proof way to handle touch-based input, check out the Pressable API.

-- https://reactnative.dev/docs/touchablewithoutfeedback

@mmilad75, @J-Son89, all RN Touchable* have this yellow warning right at the top. It seems prudent that we define a guideline for using rn/pressable so that we can gradually phase out Touchable* from status-mobile.

cc @OmarBasem, @flexsurfer, @Parveshdhull, @smohamedjavid what do you guys think? Worth of a quick PR to add to the guidelines?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ilmotta Yeah I think we should start using Pressable. Although other touchable components are still maintained, I think it is better to start migrating sooner. Also, would unify the touchable components instead of having 3 different components.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@OmarBasem I replaced it with Pressable

(defn cool-preview
[]
(let [state (reagent/atom {:disabled? false
:on-press #(println "press")
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the purpose of preview screens is also to help designers review components, I think it's preferable to use js/alert instead of println, or, even better would be to show some kind of UI change once the thing is pressed because who likes alerts right? ;) But a js/alert is what's usually used in preview screens, so it's just fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

:align-items :center
:border-radius 999
:background-color color})

Copy link
Contributor

Choose a reason for hiding this comment

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

Extra line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

[]
(let [pressed? (reagent/atom false)]
(fn
[{:keys [disabled? theme blur? on-press type]} label]
Copy link
Contributor

Choose a reason for hiding this comment

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

[Code style] The arguments' vector should be almost always always in the same line of fn as in (fn [{:keys ...}]).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

:on-press-out #(reset! pressed? false)}
[rn/view
{:style (style/container background-color)}
(cond
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a perfect candidate for condp instead of cond!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@ilmotta ilmotta left a comment

Choose a reason for hiding this comment

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

I haven't checked the UI, but code looks good.

:digit [text/text
{:weight :regular
:size :heading-1
:style {:color label-color}} label])]))))
Copy link
Contributor

Choose a reason for hiding this comment

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

Quick one: label should be on the next line, otherwise it's hard to read the code. https://guide.clojure.style/#vertically-align-fn-args

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@ajayesivan ajayesivan left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work 🎉


(defn get-label-color
[disabled? theme blur?]
(if disabled?
Copy link
Contributor

@J-Son89 J-Son89 Jul 26, 2023

Choose a reason for hiding this comment

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

consider flattening this structure with a cond, something like

(cond 
  (and disabled? (or (= :dark theme) blur?)) colors/white-opa-30
  (and disabled? (or (= :light theme) blur?)) colors/neutral-30
  (or (= :dark theme) blur?) colors/white
   :else  colors/neutral-100)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@churik
Copy link
Member

churik commented Jul 28, 2023

@Francesca-G
can you please take a look?

components that are about to use in code, but not used yet, are checked by design team.
After approve from @Francesca-G PR is ready to be merged, thanks

@J-Son89
Copy link
Contributor

J-Son89 commented Jul 28, 2023

@churik, @Francesca-G - I asked @mmilad75 to make one small adjustment to the preview screens - it will make reviewing easier imo. Can we wait for @mmilad75 to update with this change and then he can ask @Francesca-G for the review? :)

@mmilad75
Copy link
Contributor Author

@Francesca-G Please check it. It's ready for review

@Francesca-G
Copy link

Francesca-G commented Jul 28, 2023

@Francesca-G Please check it. It's ready for review

I was about to check this PR but after installing it as usual it just crashes immediately when I try to open it (iPhone 13). Please let me know if it's a problem on my side, I tried to delete the app and re-installing it but it didn't seem to fix the issue

RPReplay_Final1690544514.mp4

@churik
Copy link
Member

churik commented Jul 28, 2023

@mmilad75
#16723 (comment) confirmed from QA; can't start IOS build (IOS 16.4, IPhone 12 mini)

@@ -40,4 +40,5 @@
[quo2.components.settings.settings-list.component-spec]
[quo2.components.settings.category.component-spec]
[quo2.components.share.share-qr-code.component-spec]
[quo2.components.tags.--tests--.status-tags-component-spec]))
[quo2.components.tags.--tests--.status-tags-component-spec]
[quo2.components.numbered-keyboard.keyboard-key.component-spec]))
Copy link
Contributor

Choose a reason for hiding this comment

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

actually same here, please keep this alpha sorted 👍 - not all files are alpha sorted but if you can see the pattern is mostly there then it's best to keep it that way and in some cases go one step further and help clean up the ones that are not :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@churik
Copy link
Member

churik commented Aug 1, 2023

@mmilad75 can you please resolve conflicts and rebase it to the latest develop?
Thanks!

@mmilad75
Copy link
Contributor Author

mmilad75 commented Aug 1, 2023

@mmilad75 can you please resolve conflicts and rebase it to the latest develop? Thanks!

Done

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.

The icon used for the Key type isn't correct.

Here's the icon used in the PR

Screenshot 2023-08-01 alle 18 41 44

Here's what the icon should look like

Screenshot 2023-08-01 alle 18 42 37

@mmilad75
Copy link
Contributor Author

mmilad75 commented Aug 1, 2023

The icon used for the Key type isn't correct.

Here's the icon used in the PR

Screenshot 2023-08-01 alle 18 41 44 Here's what the icon should look like Screenshot 2023-08-01 alle 18 42 37

Yes, you're right. It was discussed with @J-Son89 and we decided to fix this issue in another ticket since the label I've used is correct, but the icon itself is placed wrongly.

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.

@mmilad75 ok, I will approve It with required follow up for the icon :)

@mmilad75 mmilad75 merged commit 07336ed into develop Aug 2, 2023
2 checks passed
@mmilad75 mmilad75 deleted the milad/16605 branch August 2, 2023 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

Implement Quo2 Numbered-Keyboard / Keyboard Key component
9 participants