Skip to content

Commit

Permalink
[net9.0] Disable NSToolbar Tabs (#25184)
Browse files Browse the repository at this point in the history
* Disable NSToolbar Tabs

* - fix OS check

* Update TabbedViewExtensions.cs

* Update TabbedViewExtensions.cs

* - analyze this

---------

Co-authored-by: Shane Neuville <[email protected]>
  • Loading branch information
github-actions[bot] and PureWeen authored Oct 15, 2024
1 parent c72387d commit f147e8b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance)

public ShellItemRenderer(IShellContext context)
{
this.DisableiOS18ToolbarTabs();
_context = context;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class TabbedRenderer : UITabBarController, IPlatformViewHandler
[Microsoft.Maui.Controls.Internals.Preserve(Conditional = true)]
public TabbedRenderer()
{
this.DisableiOS18ToolbarTabs();
_viewHandlerWrapper = new ViewHandlerDelegator<TabbedPage>(Mapper, CommandMapper, this);
}

Expand Down
22 changes: 22 additions & 0 deletions src/Core/src/OperatingSystemMacCatalyst18Workaround.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

namespace Microsoft.Maui.Platform
{
#if PLATFORM
internal static partial class OperatingSystemMacCatalyst18Workaround
{
public static bool IsMacCatalystVersionAtLeast18()
{
#if !MACCATALYST
return false;
#else
// Delete all uses of this once this is merged
// /https://github.com/xamarin/xamarin-macios/issues/21390


return Environment.OSVersion.Version.Major >= 18;
#endif
}
}
#endif
}
14 changes: 14 additions & 0 deletions src/Core/src/Platform/iOS/TabbedViewExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using Foundation;
using Microsoft.Maui.Graphics;
Expand All @@ -9,6 +10,19 @@ namespace Microsoft.Maui.Platform
{
internal static class TabbedViewExtensions
{
internal static void DisableiOS18ToolbarTabs(this UITabBarController tabBarController)
{
// Should apply to iOS and Catalyst
if (OperatingSystemMacCatalyst18Workaround.IsMacCatalystVersionAtLeast18() || //https://github.com/xamarin/xamarin-macios/issues/21390
OperatingSystem.IsIOSVersionAtLeast(18, 0))
{
tabBarController.TraitOverrides.HorizontalSizeClass = UIUserInterfaceSizeClass.Compact;
tabBarController.Mode = UITabBarControllerMode.TabSidebar;
tabBarController.Sidebar.Hidden = true;
tabBarController.TabBarHidden = true;
}
}

[System.Runtime.Versioning.SupportedOSPlatform("ios15.0")]
[System.Runtime.Versioning.SupportedOSPlatform("tvos15.0")]
internal static void UpdateiOS15TabBarAppearance(
Expand Down

0 comments on commit f147e8b

Please sign in to comment.