-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[RNMobile] RangeCell styling refactor #18157
Conversation
@iamthomasbishop please look at it 🙏 |
Updated description with a link to gb-mobile PR and resolved conflicts. |
I have also resolve conflicts after merge RangeControl markup |
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.
Thank you for these improvements @lukewalczak - they look great! 🎉
Added a couple of questions (rather than requests) on the code comments.
And I noticed a few small detail testing with bigger text sizes:
- If the system font sizes are set to a bigger size (quite common size), the fields start cropping the last digit for numbers bigger than 1000. This can be super confusing.
- If the text size is set to the accessibility sizes (the super big ones), the layout start to break. This case is a bit more extreme and we don't really have it well covered in the library in general, so maybe it's not that urgent. But we would want in this case the reset button to be vertically aligned.
accessibilityRole={ 'none' } | ||
editable={ false } | ||
accessible={ accessible } | ||
onPress={ this.onCellPress } | ||
accessibilityLabel={ accessibilityLabel } | ||
allowReset={ this.handleReset } |
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.
It's interesting that the root Cell
component provides Reset
option, but the reset functionality has to be handled by the parent component. It feels to me more like a generic button that could be anything. Maybe we can add it as an accessory view on this component, similar how we added the Switch?
Just by curiosity, I added allowReset
to other controls, it shows the Reset button but it looks a bit off (apart than it does nothing). It doesn't feel to me that it deserves to be on the root Cell component, unless we plan to add reset to more controls? (In which case this might be a good-enough first step). cc @iamthomasbishop
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.
It doesn't feel to me that it deserves to be on the root Cell component, unless we plan to add reset to more controls? (In which case this might be a good-enough first step)
That's correct, I don't think there are any other planned components at the moment that will need an explicit reset
button like this.
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.
One more note: if we do end up adding reset
to other cells/components, we'll want to display them in the same two-row way which provides more space for the reset
button.
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.
Currently we don't have many settings
in block but maybe it's not bad idea to allow reset single field (in case we will have much more settings). Correct me if I'm wrong but it seems now it's possible to manually delete/change the value or clear all settings.
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.
- Reset button is placed within a
Cell
component, because we want to locate it next to the label (Height in pixels) which is defined there actually, otherwise it has to be positioned absolutely.
@etoledom thanks for remarks ! We try to discuss |
I did some accessibility tweaks (@etoledom @iamthomasbishop please look at it):
pay no attention to the DONE button, something was wrong with a simulator |
componentDidMount() { | ||
AppState.addEventListener( 'change', this.handleChangePixelRatio ); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.handleToggleFocus(); | ||
AppState.removeEventListener( 'change', this.handleChangePixelRatio ); | ||
} | ||
|
||
getFontScale() { | ||
return PixelRatio.getFontScale() < 1 ? 1 : PixelRatio.getFontScale(); | ||
} | ||
|
||
handleChangePixelRatio( nextAppState ) { | ||
if ( nextAppState === 'active' ) { | ||
this.setState( { fontScale: this.getFontScale() } ); | ||
} | ||
} |
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.
Honestly, I think that it's worth to save that info in redux store, because it can be useful in the future to control other components 🤔
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.
It does sound like it would be helpful! But maybe it's too much for this PR.
b66c94d
to
500d414
Compare
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.
It looks so much better on bigger font sizes! Thanks for the update 🙏
made some space for Reset button, but then label is truncated
That's why is better to modify the layout to vertical when the text sizes are set to accessibility sizes. This is simple to do on iOS but not sure on RN. Anyway, I think it's good as it is for now 👍
TextInput width is multiplied by PixelRatio.getFontScale() therefore we can display 4 digits
Probably, having more than 4 digits is too much of an edge case for this context in particular. I wonder if there are other usages of the Range Control where the numbers could grow a lot bigger.
I think we can revisit if this case becomes a real problem.
From #18157 (comment)
Reset button is placed within a Cell component, because we want to locate it next to the label (Height in pixels) which is defined there actually, otherwise it has to be positioned absolutely.
Makes sense 👍
I'm still not sure about having a specific Reset
button that does nothing, and the reset logic has to be implemented on every instance of it. In this case I'd suggest to add it as a generic button (or "box" holder for any component).
But since it's the only component that uses it so far, it might be OK go forward with it and modify it if we need another control with Reset later on. I'm happy with what @pinarol decides.
I agree both. I think we can make this better with a simple tweak. Let's not name it as Reset in BottomSheetCell if it doesn't reset anything inside that component. How about just naming it as "customAction" and injecting the title and event handler from outside? Something like this: <BottomSheetCell ps: Feel free to change namings I don't feel strong about them :)
|
<View style={ platformStyles.labelIconSeparator } /> | ||
</View> | ||
) } | ||
<Text numberOfLines={ 1 } style={ [ defaultLabelStyle, labelStyle ] }> |
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.
@etoledom If we remove numberOfLines={ 1 }
we can have a not truncated label and it will look like:
wdyt?
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.
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.
Looks better than cropping!
Let's go with it if it does't affect other instances of cells and controls.
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.
I've also checked how it will affect other settings
Again, better than cropping. Looks good to me :)
Works for me! Going to adjust it :) |
Sounds good! That's what I meant by a |
Works for me! Also I did a quick testing and it is working pretty smoothly, i am very happy that we got rid of the jumpiness. |
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.
Looks and work great 🎉
Tested on iOS and Android.
Nice job @lukewalczak !
Description
NOTE: That PR is based on
rnmobile/spacer
Fixes: wordpress-mobile/gutenberg-mobile#1448
Ref to gb-mobile: wordpress-mobile/gutenberg-mobile#1511
Change
RangeCell
mobile component styling.How has this been tested?
Spacer
componentRangeCell
stylingScreenshots
Types of changes
Checklist: