-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Makes badge to auto size with content #146853
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
| final Alignment resolvedAlignment = alignment.resolve(textDirection); | ||
| final BoxParentData childParentData = child!.parentData! as BoxParentData; | ||
| childParentData.offset = offset + resolvedAlignment.alongOffset(Offset(size.width - badgeSize, size.height - badgeSize)); | ||
| Offset badgeLocation = offset + resolvedAlignment.alongOffset(Offset(size.width - widthOffset, size.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.
Just a question here, the logic here and the change on defaultOffset seem cause some breaking changes on vertical location. Do you think if it would make sense to keep the logic here so that only the size of the badge is fixed and location won't change?
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.
The previous logic didn't account for the height of the badge can change. it is why I have to compensate for the height after the badge location align is resolved.
I only compensate for the height in line 329 but not both width and height is because the styling in material design doesn't seem to change it horizontal position based on the badge width.
The logic is the following.
find out where the badge should be first without considering the size.
After we have the location, find out where the top left of the badge should be (which will be the childParentData.offset).
| // Adds a offset const Offset(0, 8) to avoiding breaking customers after | ||
| // the offset calculation changes. | ||
| // See https://github.com/flutter/flutter/pull/146853. | ||
| final Offset effectiveOffset = (offset ?? badgeTheme.offset ?? defaultOffset) + const Offset(0, 8); |
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.
@QuncCccccc This is the best way I can think of to cause least breaking for people who uses Badge(offset).
The customer that have a big jump in icon
https://fusion2.corp.google.com/presubmit/625484245/OCL:625484245:BASE:625495583:1713311589857:35f5826b/targets/invocations/a540f325-e68b-49cd-bce2-dc65254fb25d/targets/%2F%2Fanalytics%2Fmobile%2Fgiant%2Fui%2Fscreens:screens_tests_test_intelligent_home_screen_scuba_test.host/tests
is because they have a child which is too big in size so it uses offset to align the badge.
Adding this constant will make sure the offset they passed adjust the badge the same way.
QuncCccccc
left a comment
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:)
flutter/flutter@5d3bca4...2e80670 2024-04-26 [email protected] Roll Flutter Engine from d79458007712 to c410180e5bba (1 revision) (flutter/flutter#147407) 2024-04-26 [email protected] Roll Flutter Engine from 11a857e1599f to d79458007712 (1 revision) (flutter/flutter#147401) 2024-04-26 [email protected] Roll Flutter Engine from e99fc6ef91ef to 11a857e1599f (4 revisions) (flutter/flutter#147399) 2024-04-26 [email protected] Fix `FloatingActionButton` docs for `background` and `foreground` properties (flutter/flutter#147372) 2024-04-26 49699333+dependabot[bot]@users.noreply.github.com Bump peter-evans/create-pull-request from 6.0.4 to 6.0.5 (flutter/flutter#147388) 2024-04-26 [email protected] Fix `DateRangePickerDialog` does not use `rangePickerHeaderBackgroundColor` from `DatePickerTheme` in M2 (flutter/flutter#147370) 2024-04-26 [email protected] Roll Flutter Engine from a09295fe03c0 to e99fc6ef91ef (4 revisions) (flutter/flutter#147391) 2024-04-26 [email protected] Clean up leaks in a test. (flutter/flutter#147312) 2024-04-26 [email protected] add a new PopScope.onPopWithResultInvoke widget to replace PopScope.onPopInvoke (flutter/flutter#147016) 2024-04-26 [email protected] zero-sized RenderConstraintsTransformBox respects clipBehavior (flutter/flutter#147349) 2024-04-25 [email protected] Roll Flutter Engine from 3768ca0c02da to a09295fe03c0 (1 revision) (flutter/flutter#147386) 2024-04-25 [email protected] [devicelab] explicitly enable vulkan validation in test. (flutter/flutter#147382) 2024-04-25 [email protected] Roll Flutter Engine from 10a3504a9261 to 3768ca0c02da (1 revision) (flutter/flutter#147381) 2024-04-25 [email protected] Roll Flutter Engine from 694756b875bf to 10a3504a9261 (3 revisions) (flutter/flutter#147380) 2024-04-25 [email protected] Roll Flutter Engine from 19c182f47bde to 694756b875bf (1 revision) (flutter/flutter#147379) 2024-04-25 [email protected] Roll Flutter Engine from 163c18e870a9 to 19c182f47bde (1 revision) (flutter/flutter#147378) 2024-04-25 [email protected] Makes badge to auto size with content (flutter/flutter#146853) 2024-04-25 [email protected] Fix memory leaks in `Hero` widget (flutter/flutter#147303) 2024-04-25 [email protected] Roll Packages from cf6d280 to fde908d (11 revisions) (flutter/flutter#147375) 2024-04-25 [email protected] Roll Flutter Engine from 674890ce7141 to 163c18e870a9 (1 revision) (flutter/flutter#147373) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/flutter@5d3bca4...2e80670 2024-04-26 [email protected] Roll Flutter Engine from d79458007712 to c410180e5bba (1 revision) (flutter/flutter#147407) 2024-04-26 [email protected] Roll Flutter Engine from 11a857e1599f to d79458007712 (1 revision) (flutter/flutter#147401) 2024-04-26 [email protected] Roll Flutter Engine from e99fc6ef91ef to 11a857e1599f (4 revisions) (flutter/flutter#147399) 2024-04-26 [email protected] Fix `FloatingActionButton` docs for `background` and `foreground` properties (flutter/flutter#147372) 2024-04-26 49699333+dependabot[bot]@users.noreply.github.com Bump peter-evans/create-pull-request from 6.0.4 to 6.0.5 (flutter/flutter#147388) 2024-04-26 [email protected] Fix `DateRangePickerDialog` does not use `rangePickerHeaderBackgroundColor` from `DatePickerTheme` in M2 (flutter/flutter#147370) 2024-04-26 [email protected] Roll Flutter Engine from a09295fe03c0 to e99fc6ef91ef (4 revisions) (flutter/flutter#147391) 2024-04-26 [email protected] Clean up leaks in a test. (flutter/flutter#147312) 2024-04-26 [email protected] add a new PopScope.onPopWithResultInvoke widget to replace PopScope.onPopInvoke (flutter/flutter#147016) 2024-04-26 [email protected] zero-sized RenderConstraintsTransformBox respects clipBehavior (flutter/flutter#147349) 2024-04-25 [email protected] Roll Flutter Engine from 3768ca0c02da to a09295fe03c0 (1 revision) (flutter/flutter#147386) 2024-04-25 [email protected] [devicelab] explicitly enable vulkan validation in test. (flutter/flutter#147382) 2024-04-25 [email protected] Roll Flutter Engine from 10a3504a9261 to 3768ca0c02da (1 revision) (flutter/flutter#147381) 2024-04-25 [email protected] Roll Flutter Engine from 694756b875bf to 10a3504a9261 (3 revisions) (flutter/flutter#147380) 2024-04-25 [email protected] Roll Flutter Engine from 19c182f47bde to 694756b875bf (1 revision) (flutter/flutter#147379) 2024-04-25 [email protected] Roll Flutter Engine from 163c18e870a9 to 19c182f47bde (1 revision) (flutter/flutter#147378) 2024-04-25 [email protected] Makes badge to auto size with content (flutter/flutter#146853) 2024-04-25 [email protected] Fix memory leaks in `Hero` widget (flutter/flutter#147303) 2024-04-25 [email protected] Roll Packages from cf6d280 to fde908d (11 revisions) (flutter/flutter#147375) 2024-04-25 [email protected] Roll Flutter Engine from 674890ce7141 to 163c18e870a9 (1 revision) (flutter/flutter#147373) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Makes badge sizes it self according to child.
Previously, the bubble fixed its height to 16pixel. It clip the content if it is taller than 16 pixel. This causes an issue where user can increase font size in the android setting and mess up the ui
Now, the bubble can have various height from 16 pixel to the height of the child, it also extend the width to be the same as height if the child's width < height.
There is minor changes to floating location in the test. I can't really fix them unless I change some of the public API like
Badge(offset)orBadgeThemeData.largeSize. They are used differently in the new logic since now the badge can be larger than the Badge.child. I figure they are kind of minor so i think it should be okBefore the fix

After the fix

fixes #146777
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.