- Notifications
You must be signed in to change notification settings - Fork 29.4k
Allow users to center align the floating label #90157
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
Conversation
| Gold has detected about 12 new digest(s) on patchset 2. |
48aedc3 to bbb743d Compare | Gold has detected about 8 new digest(s) on patchset 3. |
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.
Thanks for the great PR and design doc! I've left some comments on your design doc about the potential for some more fully-featured solutions to this problem. Let me know what you think.
400d049 to d916ffc Compare d916ffc to 3885f93 Compare | Gold has detected about 14 new digest(s) on patchset 5. |
| @werainkhatri Looks like there is a test failure on Linux web: Full error |
| Gold has detected about 12 new digest(s) on patchset 6. |
| Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. Changes reported for pull request #90157 at sha 0496a1f24bf0cc83be6ff6247e8a6692a89210bc |
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.
Some questions and some smaller changes for you. I think overall this approach looks pretty nice to me. I need to check out your branch and play around with it myself still, will do that soon.
| Gold has detected about 16 new digest(s) on patchset 7. |
| Gold has detected about 8 new digest(s) on patchset 8. |
| Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. Changes reported for pull request #90157 at sha f7f4b97e64c5a63f43c185535be97da0ea102630 |
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 tried running this on my own machine and it seems to work great.
The only major thing that I think we should change is that the x calculation should be done based on arbitrary FloatingLabelBehavior.x, not just by checking for center, even though it's not supported for now. See my comment about that and let me know what you think.
Otherwise most of my comments are small nits. Thanks for being patient with this PR and sorry it took me so long to try this out!
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.
Good catch.
| @mat100payette Here's what the border from #82321 looks like when the label is centered: The fade in/out of the border under the label is a little weird, but otherwise it looks pretty good. I've left a comment in that issue to discuss allowing arbitrary x values or not. |
f7f4b97 to 9fe11db Compare | Gold has detected about 2 new digest(s) on patchset 9. |
| Gold has detected about 8 new digest(s) on patchset 10. |
| Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
| It seems like arbitrary values for FloatingLabelAlignment would not help with rounded rects according to #82321 (comment), so that's another reason to leave that out of this PR for now and just use |
Fair enough. I have made the default constructor for |
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.
Thanks for handling the RTL stuff. I noticed one case where the docs need to be clarify left/right, otherwise just a few nits.
| if (label != null) { | ||
| final Offset labelOffset = _boxParentData(label!).offset; | ||
| final double labelHeight = label!.size.height; | ||
| final double labelHeight = _boxSize(label).height; |
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.
Good call switching to _boxSize.
| Should I make |
| Yes that's a good idea, you should make it private. Just in case in the future if we change how it works under the hood for some reason, it definitely won't be a breaking change if x is private. |
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.
LGTM 👍
CC @LongCatIsLooong for secondary review.
| if (label != null) { | ||
| final double labelX = _boxParentData(label!).offset.dx; | ||
| // +1 shifts the range of x from (-1.0, 1.0) to (0.0, 2.0). | ||
| final double floatAlign = decoration.floatingLabelAlignment._x + 1; |
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.
Thanks for making the calculations work with any _x and not just center and left 👍
| No secondary review needed actually, I'll go ahead and merge this. Thanks for the PR! |

Added InputDecorator.floatingLabelAlignment to allow users to align the floating label left or center of the input field.
Fixes #27357
Design Doc
Pre-launch Checklist
///).