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 picker to be a cross-platform component #2242

Merged
merged 15 commits into from
Apr 12, 2021

Conversation

tgolen
Copy link
Contributor

@tgolen tgolen commented Apr 6, 2021

@nickmurray47 @NikkiWines This PR was based on some stuff that I came across in #1767, primarily some missing method docs. As I looked more at the PR, I spotted a few things that should be improved to match our existing patterns better. Please have a look at this and let me know if you have any questions

Details

  • Adds some missing method docs
  • Renames a prop to have a less redundant name
  • DRY up some logic in the checkbox
  • Convert the picker into a cross-platform component

Fixed Issues

No issue, just some things I spotted in #1767

Tests / QA Steps

  1. Go to the profile page
  2. Go to preferences
  3. Change the priority mode
  4. Go back to settings
  5. Go to profile
  6. Change preferred prounouns
  7. Change timezones
  8. Change automatic timezone setting
  9. Verify all changes are saved properly

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

image

Mobile Web

image

Desktop

image

iOS

image

Android

image

@tgolen tgolen requested a review from a team as a code owner April 6, 2021 17:09
@MelvinBot MelvinBot requested review from sketchydroide and removed request for a team April 6, 2021 17:09
Comment on lines 29 to 30
<Pressable onPress={() => onClick(!isChecked)}>
{label ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

are we hiding the checkbox from now on if there's a label present? I think we should show the Checkmark icon regardless, otherwise, it's hard to know that it's a clickable element

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good catch. I think I read the original code wrong. I need to revert this.

actionName: PropTypes.string.isRequired,
actionName: PropTypes.string,
Copy link
Contributor

Choose a reason for hiding this comment

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

why the switch to making these prop optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a prop warning in the console that undefined was being passed. I looked through the code and there is a spot where the report action passed is {} (an empty object) so I just corrected the propTypes here.

Copy link
Contributor Author

@tgolen tgolen left a comment

Choose a reason for hiding this comment

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

Updated!

Comment on lines 29 to 30
<Pressable onPress={() => onClick(!isChecked)}>
{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.

Ah, good catch. I think I read the original code wrong. I need to revert this.

actionName: PropTypes.string.isRequired,
actionName: PropTypes.string,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a prop warning in the console that undefined was being passed. I looked through the code and there is a spot where the report action passed is {} (an empty object) so I just corrected the propTypes here.

nickmurray47
nickmurray47 previously approved these changes Apr 6, 2021
Copy link
Contributor

@nickmurray47 nickmurray47 left a comment

Choose a reason for hiding this comment

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

LGTM and test well on Web and iOS

@nickmurray47
Copy link
Contributor

looks like there are some merge conflicts too @tgolen

@tgolen
Copy link
Contributor Author

tgolen commented Apr 6, 2021

OK, updated to fix the conflicts. I added a file rename so that we are using the proper conventions and pointed out some more missing method docs and comments in #2169

@tgolen tgolen self-assigned this Apr 6, 2021
Comment on lines 20 to 22
inputAndroid: [
styles.picker.inputAndroid, styles.textInput, styles.disabledTextInput,
],
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure how platform specific styles are handled but would it make more sense to have the ios/android/index files just export the style and the component itself be defined once? would avoid duplication and make it easier to update without having to touch 3 files

Copy link
Contributor

@NikkiWines NikkiWines left a comment

Choose a reason for hiding this comment

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

Two small comments, looking good otherwise.

@@ -0,0 +1,35 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand why we need three different, largely identical files for the picker.

Copy link
Contributor

Choose a reason for hiding this comment

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

is the style the only change? could we have that an input for another compnent perharphs? No real idea, just wandering

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, the styles are basically the only difference. I like the idea of just exporting the proper styles from the platform-specific files and DRYing this up more. I'll be working on that today.

items={items}
style={useDisabledStyles ? {
...styles.picker,
inputAndroid: [
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be

inputAndroid: [styles.picker.inputAndroid, styles.textInput, styles.disabledTextInput],

@tgolen
Copy link
Contributor Author

tgolen commented Apr 8, 2021

OK, updated and retested on all platforms. I refactored it so the component is only defined once and only the styles are platform specific.

Copy link
Contributor

@NikkiWines NikkiWines left a comment

Choose a reason for hiding this comment

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

This looks good to me, any reason that mWeb is marked as n/a?

@tgolen
Copy link
Contributor Author

tgolen commented Apr 9, 2021

Just because... laziness 😁 I added testing for mobile web.

Copy link
Contributor

@sketchydroide sketchydroide left a comment

Choose a reason for hiding this comment

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

LGTM

@tgolen tgolen merged commit 377e1c2 into master Apr 12, 2021
@tgolen tgolen deleted the tgolen-improve-profile-quality branch April 12, 2021 16:35
@isagoico
Copy link

We are blocked to check this QA this PR in both iOS and Android apps because of the scrolling issue in settings>profile #2147

@isagoico
Copy link

QA in other platforms was a pass (mweb, web, desktop)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants