Implement badge component#463
Conversation
Used for badge control. ITheme.ValidationError prop is now ColorPair.
Create badge and badged controls. Badge is a simple badge. Badged makes it easy to attach a badge to button, icon, or other controls.
SKProCH
left a comment
There was a problem hiding this comment.
While i appreciate the work (and i like the results!) i have some thoughts:
Probably we shouldn't make 2 separate controls, since Badged can be used as Badge is there is no Content specified? What do you think?
|
And currently large sized badges go beyond not equally: While in MDiX it do it equally (half width "in control" half out, half height "in control" half out): I don't know which variant is the best and should this be fixed, but leaving it here just in case you missed that. P.S. Probably this is should be just another option in placement enum? |
|
The bed under my body is just about to take me to sleep right now, so I will work on the change requests at another day. As for small badge, just my feeling, I have concerns with the implementation where the shape of a control is implicitly and heavily modified by a property that does not directly mention it. As for "beyond", I believe the m3 guideline shows a layout that goes beyond on the outside. |
Probably yes, but I don't see usecases, where the user will specify BadgeContent and don't want to show it (and display the small dot instead). |
wait do I miss something? wheres the "BadgeContent" came from? It's a thing from official AvaloniaUI? |
|
honestly, idk how bout creating a lot content somehow, unless its necessary, but I have a different approach about |
No, this is a new property from
I am against this. Adding something via AttachedProperty is only necessary in cases where we need to add something to an existing control that we cannot change (or in other rare cases, like when we need to hide some internal information or something like that). In cases where we are doing something new, it is reasonable to create a new control to make it easier for third-party users to use, there is nothing wrong with that. |
Here is my intended use case: In this case, BadgeContent is bound to the number of new items; HasContent is bound to the negation of the slim layout option. It is pretty simple.
I am not sure if you are suggesting to make all of Badge or only Badged an assist, so I respond with both patterns. The Badge is a meaningful UI component and is not just a decoration. It might be possible to recreate Badged as an assist, but the assist class would have too many properties. |
This makes sense. But probably defining a new theme for control and just swapping it globally (in parent/app resources) wasn't the better way then binding every control to some global property? |
If the application has 100 badges and all of them are large badges, then yes. This is the official Bluesky app for Android (I usually use another client so I have tons of notifications lol) . The badge on notifications is large, but the badge on "Scroll to Top" (🔼) is small. In this case, only the badge on notifications can be slimmed down. |
|
Maybe yes, but I still think it should be determined by the data. However, I respect your opinion as an author, so let's leave it as you see it. P.S. Maybe make it a |
Yes, I was considering making HasContent an enum and allowing users to choose between True, False, and Auto. |
|
Hello, I'm so sorry for leaving this for so long. I have been focusing on some other areas lately, so I will not be able to work on this PR for a while at least. Of course, feel free to use any code or ideas from this PR, or the PR itself. Thank you! |
|
@Hyz-sui can you check "Allow edit for maintainers"? I can't push to your branch currently. |
…roundBrush as black
…en by default, enrich demo
|
I've fixed all the changes requested, but there is still plenty things to implement, like:
But currently keeping things simple, as i don't have so much time to this. PR are appreciated if anybody wants to do this |
|
Also, thanks, @Hyz-sui, its awesome work! |
|
Awesome, thank you for completing the PR! @SKProCH |




Created
BadgeandBadgedcontrols. Closes #347.Badge in m2 has not been completed, so I strongly referred to badge in m3.
I also created demo page for badges ( 2f95c4f ).
Screenshot
Badge
The
Badgecontrol is a simple badge. Users can place a single inline badge with this. It can be implemented usingBadgedwithBadgePlacement.Right, but more intuitive.Small badge (just a dot) is also implemented with
HasContentproperty.Badged
The
Badgedcontrol is a content wrapper that makes it easy to attach a badge to the content.You can customize the badge through
BadgeContent,BadgeBackground,BadgeForeground,BadgeCornerRadius,BadgeHasContent,BadgeWidth,BadgeHeight, andBadgeFontSizeproperties.The badge can be hidden with
IsBadgeVisible.You can choose the placement of the badge with
BadgePlacement.It should be TopLeft (default), Right (inline badge / place on the ending edge), or TopLeft (RTL) according to m3 guidelines, but is not limited technically in this control.
Other Changes
MaterialValidationErrorForegroundBrushhas been added.ITheme.ValidationErrorhas been changed fromColortoColorPairtype. I am not sure that this is breaking change or not.