Skip to content

Commit

Permalink
Fix up relevant CA1416 warnings - Set 4 (#26995)
Browse files Browse the repository at this point in the history
* CA1416 warning fix.

* CA1416 warning changes

* CA1416 warning changes

* CA1416 warning changes
  • Loading branch information
Tamilarasan-Paranthaman authored Jan 20, 2025
1 parent 44eeba3 commit a46b6f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/Core/src/Handlers/Application/ApplicationHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ public static partial void MapCloseWindow(ApplicationHandler handler, IApplicati
}
}

[SupportedOSPlatform("maccatalyst13.0")]
public static partial void MapActivateWindow(ApplicationHandler handler, IApplication application, object? args)
{
// ActivateSceneSession requires 17+
if (!OperatingSystem.IsIOSVersionAtLeast(17) && !OperatingSystem.IsMacCatalyst())
{
return;
}

if (args is IWindow window)
{
var sceneSession = (window.Handler?.PlatformView as UIWindow)?.WindowScene?.Session;
Expand Down
18 changes: 15 additions & 3 deletions src/Core/src/Platform/iOS/MauiUIApplicationDelegate.Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public override void BuildMenu(IUIMenuBuilder builder)
MenuBuilder = builder;

UIWindow? window = null;
if (OperatingSystem.IsMacCatalystVersionAtLeast(14))

if (OperatingSystem.IsMacCatalystVersionAtLeast(14) || OperatingSystem.IsIOSVersionAtLeast(14))
{
// for iOS 14+ where active apperance is supported
var activeWindowScenes = new List<UIWindowScene>();
Expand All @@ -48,7 +49,7 @@ public override void BuildMenu(IUIMenuBuilder builder)
// we need to pick the newly created window in this case
// the order of window scene returned is not trustable, do not use last
// after some manual testing, windowing behaviour that is not ready yet is the newly created window
if (activeWindowScenes.Count > 1)
if ((OperatingSystem.IsMacCatalystVersionAtLeast(16) || OperatingSystem.IsIOSVersionAtLeast(16)) && activeWindowScenes.Count > 1)
{
foreach (var ws in activeWindowScenes)
{
Expand All @@ -59,8 +60,18 @@ public override void BuildMenu(IUIMenuBuilder builder)
}
}
}
else
else if (OperatingSystem.IsMacCatalystVersionAtLeast(15) || OperatingSystem.IsIOSVersionAtLeast(15))
{
window = activeWindowScenes[0].KeyWindow;
}
else if (activeWindowScenes[0].Windows.Length > 0)
{
window = activeWindowScenes[0].Windows[0];
}
else
{
window = Window ?? this.GetWindow() ?? UIApplication.SharedApplication.GetWindow()?.Handler?.PlatformView as UIWindow;
}
}
}
else
Expand All @@ -69,6 +80,7 @@ public override void BuildMenu(IUIMenuBuilder builder)
window = Window ?? this.GetWindow() ??
UIApplication.SharedApplication.GetWindow()?.Handler?.PlatformView as UIWindow;
}

window?.GetWindow()?.Handler?.UpdateValue(nameof(IMenuBarElement.MenuBar));

MenuBuilder = null;
Expand Down

0 comments on commit a46b6f7

Please sign in to comment.