Add support for XAML Hot Reload in Visual Studio
This commit is contained in:
@@ -41,8 +41,8 @@ public class AndroidMopups : IPopupPlatform
|
||||
{
|
||||
HandleAccessibility(true, page.DisableAndroidAccessibilityHandling, page);
|
||||
|
||||
page.Parent = MauiApplication.Current.Application.Windows[0].Content as Element;
|
||||
page.Parent ??= MauiApplication.Current.Application.Windows[0].Content as Element;
|
||||
var mainPage = (Element)MauiApplication.Current.Application.Windows[0].Content;
|
||||
mainPage.AddLogicalChild(page);
|
||||
|
||||
var handler = page.Handler ??= new PopupPageHandler(page.Parent.Handler.MauiContext);
|
||||
|
||||
@@ -56,13 +56,13 @@ public class AndroidMopups : IPopupPlatform
|
||||
{
|
||||
var renderer = IPopupPlatform.GetOrCreateHandler<PopupPageHandler>(page);
|
||||
|
||||
if(renderer != null)
|
||||
if (renderer != null)
|
||||
{
|
||||
HandleAccessibility(false, page.DisableAndroidAccessibilityHandling, page);
|
||||
|
||||
DecoreView?.RemoveView(renderer.PlatformView as Android.Views.View);
|
||||
renderer.DisconnectHandler(); //?? no clue if works
|
||||
page.Parent = null;
|
||||
page.Parent?.RemoveLogicalChild(page);
|
||||
|
||||
return PostAsync(DecoreView);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ internal class MacOSMopups : IPopupPlatform
|
||||
|
||||
public Task AddAsync(PopupPage page)
|
||||
{
|
||||
page.Parent = Application.Current.MainPage;
|
||||
var mainPage = Application.Current.MainPage;
|
||||
mainPage.AddLogicalChild(page);
|
||||
|
||||
page.DescendantRemoved += HandleChildRemoved;
|
||||
|
||||
@@ -102,7 +103,7 @@ internal class MacOSMopups : IPopupPlatform
|
||||
if (handler != null && viewController != null && !viewController.IsBeingDismissed)
|
||||
{
|
||||
var window = viewController.View?.Window;
|
||||
page.Parent = null;
|
||||
page.Parent?.RemoveLogicalChild(page);
|
||||
|
||||
if (window != null)
|
||||
{
|
||||
|
||||
@@ -51,7 +51,8 @@ namespace Mopups.Windows.Implementation
|
||||
|
||||
public async Task AddAsync(PopupPage page)
|
||||
{
|
||||
page.Parent = Application.Current.MainPage;
|
||||
var mainPage = Application.Current.MainPage;
|
||||
mainPage.AddLogicalChild(page);
|
||||
|
||||
var popup = new global::Microsoft.UI.Xaml.Controls.Primitives.Popup();
|
||||
|
||||
@@ -62,16 +63,12 @@ namespace Mopups.Windows.Implementation
|
||||
// Then you can use contructor resolution instead of singletons
|
||||
// But I figured we could do that in a later PR and just work on windows here
|
||||
|
||||
var renderer = (PopupPageRenderer)page.ToPlatform(Application.Current.MainPage.Handler.MauiContext);
|
||||
|
||||
var renderer = (PopupPageRenderer)page.ToPlatform(mainPage.Handler.MauiContext);
|
||||
renderer.Prepare(popup);
|
||||
popup.Child = renderer;
|
||||
|
||||
|
||||
// https://github.com/microsoft/microsoft-ui-xaml/issues/3389
|
||||
popup.XamlRoot =
|
||||
Application.Current.MainPage.Handler.MauiContext.Services.GetService<Microsoft.UI.Xaml.Window>().Content.XamlRoot;
|
||||
|
||||
popup.XamlRoot = mainPage.Handler.MauiContext.Services.GetService<Microsoft.UI.Xaml.Window>().Content.XamlRoot;
|
||||
popup.IsOpen = true;
|
||||
page.ForceLayout();
|
||||
|
||||
@@ -91,7 +88,7 @@ namespace Mopups.Windows.Implementation
|
||||
renderer.Destroy();
|
||||
|
||||
Cleanup(page);
|
||||
page.Parent = null;
|
||||
page.Parent?.RemoveLogicalChild(page);
|
||||
popup.Child = null;
|
||||
popup.IsOpen = false;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ internal class iOSMopups : IPopupPlatform
|
||||
|
||||
public Task AddAsync(PopupPage page)
|
||||
{
|
||||
page.Parent ??= Application.Current?.MainPage;
|
||||
var mainPage = Application.Current.MainPage;
|
||||
mainPage.AddLogicalChild(page);
|
||||
|
||||
var keyWindow = GetKeyWindow(UIApplication.SharedApplication);
|
||||
if (keyWindow?.WindowLevel == UIWindowLevel.Normal)
|
||||
@@ -87,7 +88,7 @@ internal class iOSMopups : IPopupPlatform
|
||||
if (handler != null && viewController != null && !viewController.IsBeingDismissed)
|
||||
{
|
||||
var window = viewController.View?.Window;
|
||||
page.Parent = null;
|
||||
page.Parent?.RemoveLogicalChild(page);
|
||||
|
||||
if (window != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user