Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 0 additions & 195 deletions src/Controls/samples/Controls.Sample/Pages/Core/ToolbarBadgePage.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ protected override IEnumerable<SectionModel> CreateItems() => new[]
new SectionModel(typeof(ToolbarPage), "Toolbar",
"Toolbar items are buttons that are typically displayed in the navigation bar."),

new SectionModel(typeof(ToolbarBadgePage), "Toolbar Badges",
"Badge notifications on toolbar items using BadgeText and BadgeColor properties."),

new SectionModel(typeof(TransformationsPage), "Transformations",
"Apply scale transformations, rotation, etc. to a View."),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public PrimaryToolbarItem(ToolbarItem item, bool forceName)

Clicked += OnClicked;
item.PropertyChanged += OnPropertyChanged;
UpdateBadge(item);

if (item != null && !string.IsNullOrEmpty(item.AutomationId))
AccessibilityIdentifier = item.AutomationId;
Expand Down Expand Up @@ -153,8 +152,6 @@ void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
UpdateTextAndStyle(item);
}
}
else if (e.PropertyName == nameof(ToolbarItem.BadgeText) || e.PropertyName == nameof(ToolbarItem.BadgeColor) || e.PropertyName == nameof(ToolbarItem.BadgeTextColor))
UpdateBadge(item);
#pragma warning disable CS0618 // Type or member is obsolete
else if (e.PropertyName == AutomationProperties.HelpTextProperty.PropertyName)
this.SetAccessibilityHint(item);
Expand Down Expand Up @@ -198,41 +195,6 @@ void UpdateTextAndStyle(ToolbarItem item)
#pragma warning restore CA1416, CA1422
Image = null;
}

void UpdateBadge(ToolbarItem item)
{
// UIBarButtonItem.Badge is only available on iOS 26+ / MacCatalyst 26+
if (!OperatingSystem.IsIOSVersionAtLeast(26) && !OperatingSystem.IsMacCatalystVersionAtLeast(26))
return;

var badgeText = item.BadgeText;

if (badgeText is null)
{
#pragma warning disable CA1416 // Validate platform compatibility
this.Badge = null;
#pragma warning restore CA1416
return;
}

#pragma warning disable CA1416 // Validate platform compatibility
UIBarButtonItemBadge badge;
if (badgeText.Length == 0)
badge = UIBarButtonItemBadge.Create(0); // Empty string shows as dot indicator
else if (int.TryParse(badgeText, out var count) && count >= 0)
badge = UIBarButtonItemBadge.Create((nuint)count);
else
badge = UIBarButtonItemBadge.Create(badgeText);

if (item.BadgeColor is not null)
badge.BackgroundColor = item.BadgeColor.ToPlatform();

if (item.BadgeTextColor is not null)
badge.ForegroundColor = item.BadgeTextColor.ToPlatform();

this.Badge = badge;
#pragma warning restore CA1416
}
}

internal sealed class SecondarySubToolbarItem
Expand Down
Loading
Loading