-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[WIP] Add Material Badge widget
#99853
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
25eed6c to
41bf9c5
Compare
HansMuller
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.
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.
c15f020 to
d2840fa
Compare
This comment was marked as resolved.
This comment was marked as resolved.
HansMuller
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.
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.
|
@TahaTesser Is this something you are still working on? |
Thanks for the comment, yes, I'll update this PR by Monday |
|
Update: |
|
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 |
Badge widgetBadge widget
Badge widgetBadge widget
|
Closing this for now as this new feature is a low priority right now. |
fixes #92257
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.