Add Shell badge support (BadgeText, BadgeColor, BadgeTextColor)#34659
Add Shell badge support (BadgeText, BadgeColor, BadgeTextColor)#34659jfversluis wants to merge 10 commits intonet11.0from
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34659Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34659" |
Add BadgeText and BadgeColor bindable properties to BaseShellItem, enabling badge indicators on Shell bottom tab items across all platforms. Platform implementations: - Android: BadgeDrawable on BottomNavigationView with text and color support - iOS/MacCatalyst: UITabBarItem.BadgeValue and BadgeColor - Windows: InfoBadge on NavigationViewItem with ViewModel binding Includes 19 unit tests and interactive sample page. Fixes #8305 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add HostApp test page (Issue8305) with Shell tabs and badge controls - Add 4 NUnit UI tests: initial badge, runtime set, clear, multiple tabs - Fix missing using directives in ShellBadgeGallery sample page Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
d534554 to
55ad580
Compare
There was a problem hiding this comment.
Pull request overview
Adds Shell badge support (text + background color) for bottom tabs across platforms, wiring new BaseShellItem bindable properties through platform renderers/handlers and adding test/sample coverage.
Changes:
- Introduces
BadgeText/BadgeColorbindable properties onBaseShellItem. - Implements badge rendering updates for Android (BottomNavigationView), iOS/MacCatalyst (UITabBarItem), and Windows (InfoBadge via NavigationViewItem).
- Adds unit tests, UI screenshot tests, and a sample gallery page demonstrating badge behavior.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Core/src/Platform/Windows/NavigationViewItemViewModel.cs | Adds badge-related view-model properties for WinUI binding (text, background, computed visibility/value). |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue8305.cs | Adds UI screenshot tests for initial/runtime/cleared/multiple badge states. |
| src/Controls/tests/TestCases.HostApp/Issues/Issue8305.cs | Adds HostApp test page for interactive badge updates via buttons. |
| src/Controls/tests/Core.UnitTests/ShellBadgeTests.cs | Adds unit tests validating defaults, binding, and property change behavior for badge properties. |
| src/Controls/src/Core/Shell/BaseShellItem.cs | Adds the new bindable properties and public API surface on BaseShellItem. |
| src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt | Records new badge APIs for netstandard. |
| src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt | Records new badge APIs for .NET. |
| src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt | Records new badge APIs for Windows TFM. |
| src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt | Records new badge APIs for Tizen TFM. |
| src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | Records new badge APIs for MacCatalyst TFM. |
| src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt | Records new badge APIs for iOS TFM. |
| src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt | Records new badge APIs for Android TFM (also includes new protected virtual renderer method). |
| src/Controls/src/Core/Platform/Windows/TabbedPage/TabbedPageStyle.xaml | Wires WinUI InfoBadge into the tab template via bindings. |
| src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs | Maps badge properties to Windows tab view-model and tracks runtime updates. |
| src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs | Updates UITabBarItem badge text/color on initial setup and on property changes. |
| src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellItemRenderer.cs | Implements Android badge creation/removal and updates on property changes/menu setup. |
| src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellBadgeGallery.cs | Adds an interactive sample page for setting/clearing badges and colors. |
| src/Controls/samples/Controls.Sample/Pages/AppShell.xaml | Adds the new badge gallery and XAML examples using BadgeText / BadgeColor. |
src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellItemRenderer.cs
Outdated
Show resolved
Hide resolved
src/Controls/samples/Controls.Sample/Pages/Core/ShellGalleries/ShellBadgeGallery.cs
Show resolved
Hide resolved
src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
397f424 to
18f1a88
Compare
… alignment - Fix Android UpdateAllBadges to skip More tab when overflow exists - Fix ShellBadgeGallery nullable annotations (Color?, ShellSection?, IList?) - Align net-tizen PublicAPI entries with other TFMs (use ~ prefix) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add missing 'using Microsoft.Maui' for ClearButtonVisibility/Thickness - Fix event handler sender parameter to 'object?' for nullable compat Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@jfversluis , |
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Extends badge support from Shell bottom tabs (PR #34659) to ToolbarItems. Uses native platform APIs: Android BadgeUtils/BadgeDrawable, iOS 26+ UIBarButtonItem.badge, and Windows InfoBadge overlay. Includes 17 unit tests, UI test page, and sample gallery page. Fixes #8305 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run maui-pr |
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
|
Azure Pipelines successfully started running 1 pipeline(s). |
…or customization - Add BadgeTextColor BindableProperty to BaseShellItem - Android: BadgeDrawable.BadgeTextColor - iOS/MacCatalyst: UITabBarItem.SetBadgeTextAttributes - Windows: InfoBadge.Foreground via NavigationViewItemViewModel.BadgeForeground - Update all platform handlers to track BadgeTextColor property changes - Add BadgeForeground property to NavigationViewItemViewModel (Windows) - Bind Foreground in TabbedPageStyle.xaml InfoBadge template - Add 6 unit tests for BadgeTextColor (25 total) - Update all 7 PublicAPI.Unshipped.txt files - Add Badge Text Color section to ShellBadgeGallery sample page Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run maui-pr-uitests |
Change BadgeText semantics: null = no badge, empty string = dot indicator, non-empty string = text/count badge. Previously both null and empty string hid the badge. Platform implementations: - Android: ClearNumber() on BadgeDrawable for dot mode - iOS: Set BadgeValue to empty string (native dot support) - Windows: HasBadge checks 'is not null' instead of IsNullOrEmpty Added 3 unit tests for dot badge behavior. Updated sample page dot badge button to use empty string. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run maui-pr |
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Remove duplicate entries in net-android that caused RS0025 build errors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run maui-pr |
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
|
Azure Pipelines successfully started running 1 pipeline(s). |
Generated from CI build 1354596 (WinUI UITests Controls Shell). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run maui-pr |
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
|
Azure Pipelines successfully started running 1 pipeline(s). |
- Add 4 iOS (ios-26) reference screenshots for Shell badge tests - Add 4 Android reference screenshots for Shell badge tests - Generated from CI build 1354898 snapshot artifacts Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run maui-pr-uitests |
|
/azp run maui-pr |
|
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
|
Azure Pipelines successfully started running 1 pipeline(s). |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description
Adds badge notification support to Shell bottom tabs on all platforms (Android, iOS, MacCatalyst, Windows).
Closes #8305 (first iteration — bottom tabs)
New API
Three new bindable properties on
BaseShellItem:BadgeTextstring?null= no badge,""= dot indicator, non-empty = text/count badge.BadgeColorColor?nulluses the platform default.BadgeTextColorColor?nulluses the platform default (typically white).XAML Usage
Platform Implementation
BottomNavigationView.GetOrCreateBadge()/BadgeDrawableClearNumber()for dot mode.UITabBarItem.BadgeValue/BadgeColor/SetBadgeTextAttributesInfoBadgeonNavigationViewItemvia ViewModel bindingDot Badge Support
Setting
BadgeText = ""(empty string) displays a small dot indicator without text on all platforms. This is distinct fromnullwhich hides the badge entirely.What's Included
BaseShellItemwith full XML documentationShellBadgeTests.cs)Issue8305.cs)ShellBadgeGallery)What's NOT Included (follow-up work)
Screenshots
Testing