Skip to content

Conversation

@TahaTesser
Copy link
Member

@TahaTesser TahaTesser commented Mar 9, 2022

fixes #92257

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Mar 9, 2022
@TahaTesser TahaTesser requested a review from darrenaustin March 9, 2022 19:13
@TahaTesser TahaTesser requested a review from HansMuller March 10, 2022 16:15
@TahaTesser TahaTesser changed the title Add Material Badge Add Material Badge widget Mar 15, 2022
@TahaTesser TahaTesser requested a review from HansMuller March 15, 2022 15:18
Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

This is getting better but it's still needs some refinement. The Badge widget shouldn't require a controller, just a child. A factory like Badge.count(), that created a private Badge subclass might handle the special case where the Badge's child displays an integer with a limited number of digits.

Updating Badges based on application state, by rebuilding the badges themselves or some part of the navigation bar or its ancestors, should be up to the application. An example that demonstrated a simple version of this would be helpful.

Since the typical use-case for a Badge is displaying a short string within a filled "stadium" shape, it makes sense for it to have shape, backgroundColor and textStyle parameters. The TextStyle would be used to wrap the child in a DefaultTextStyle. A TextStyle parameter is a little tricky because the common case is to just override the default TextStyle's color. If you also provide a textColor parameter, then it should probably override the TextStyle's color, even if that's non-null.

This widget will need to deal with textScaleFactor and (probably) visualDensity to the extent that it constrains its layout to fit into a navigation bar.

@flutter-dashboard

This comment was marked as resolved.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

Badges might be applied to any widget, not just to a NavigationDestination. This widget would be more useful if it had a child and an alignment property. That way it could be used to decorate NavigationDestinations as well as any other widget.

@Hixie
Copy link
Contributor

Hixie commented May 17, 2022

@TahaTesser Is this something you are still working on?

@TahaTesser
Copy link
Member Author

@TahaTesser Is this something you are still working on?

Thanks for the comment, yes, I'll update this PR by Monday

@TahaTesser
Copy link
Member Author

Update:
Still working on this, currently trying to badge alignment relative child widget.

@TahaTesser
Copy link
Member Author

I'm trying to figure out how to position the badge relative to a child in a cleaner way using render objects and make it customizable depending on the child's size so the badge can be used with any child widget.

My current solution is to place it inside a Stack with some padding but it won't flexible, and will require custom padding whenever the badge is used with a child bigger a normal such as in NavigationRailDestination.

@TahaTesser TahaTesser marked this pull request as draft June 14, 2022 14:47
@TahaTesser TahaTesser removed the request for review from darrenaustin July 11, 2022 13:45
@TahaTesser TahaTesser changed the title Add Material Badge widget [[WIP] Add Material Badge widget Jul 11, 2022
@TahaTesser TahaTesser changed the title [[WIP] Add Material Badge widget [WIP] Add Material Badge widget Jul 11, 2022
@TahaTesser
Copy link
Member Author

Closing this for now as this new feature is a low priority right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add badge widget

4 participants