Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support for Multiple Windows on MacOS #2260

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 18 additions & 1 deletion samples/CommunityToolkit.Maui.Sample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ public partial class App : Application
public App()
{
InitializeComponent();

MainPage = new AppShell();
}

#if MACCATALYST
protected override Window CreateWindow(IActivationState? activationState)
{
Window window = base.CreateWindow(activationState);
window.Destroying += (object? sender, EventArgs args) =>
{
if (Current?.Windows?.Count - 1 == 0)
{
// Exit the app when the last window closes
// This ensures app closes when last window closes on Mac
Environment.Exit(0);
}
};
return window;
}

#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>__MAUI_DEFAULT_SCENE_CONFIGURATION__</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
<key>NSSpeechRecognitionUsageDescription</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using Foundation;
using Microsoft.Maui;
using ObjCRuntime;
using UIKit;

namespace CommunityToolkit.Maui.Sample.Platforms.MacCatalyst;

[Register("SceneDelegate")]
public class SceneDelegate : MauiUISceneDelegate
{
}