diff --git a/Mopups/Mopups.Maui/Mopups.csproj b/Mopups/Mopups.Maui/Mopups.csproj index 0eb0e8b..63573f6 100644 --- a/Mopups/Mopups.Maui/Mopups.csproj +++ b/Mopups/Mopups.Maui/Mopups.csproj @@ -2,8 +2,8 @@ - net7.0;net7.0-ios;net7.0-maccatalyst;;net7.0-android33.0 - $(TargetFrameworks);net7.0-windows10.0.19041.0 + net8.0;net8.0-maccatalyst;net8.0-ios;net8.0-android34.0 + $(TargetFrameworks);net8.0-windows10.0.19041.0 true @@ -27,12 +27,14 @@ Tyson Hooker,Maksym Koshovyi,Aswin P G, Kirill Lyubimov, Martijn Van Dijk, Shane Neuville $(CompanyName) Mopups;Popups;Maui;rg;Xamarin;ios;android;Windows;MacOS;Mopups;Dialogs;macos;windows - 1.2.0 + 1.3.0 Mopups (Maui Popups) - Finally did a release that should support Windows -Added in previous work for awaitable popups directly into this repo under prebaked. + Added in several fixes from the community (THANKYOU!) + +Upgraded to .NET 8 True snupkg + True AnyCPU @@ -80,6 +82,23 @@ Added in previous work for awaitable popups directly into this repo under prebak AnyCPU False + + True + + + True + + + r8 + True + True + True + + + True + True + True + diff --git a/Mopups/Mopups.Maui/Pages/PopupPage.cs b/Mopups/Mopups.Maui/Pages/PopupPage.cs index 190296b..a2601b6 100644 --- a/Mopups/Mopups.Maui/Pages/PopupPage.cs +++ b/Mopups/Mopups.Maui/Pages/PopupPage.cs @@ -116,7 +116,7 @@ public bool DisableAndroidAccessibilityHandling public PopupPage() { - //BackgroundColor = Color.FromArgb("#80000000"); + BackgroundColor = Colors.Transparent; } protected override bool OnBackButtonPressed() @@ -284,7 +284,7 @@ protected virtual bool OnBackgroundClicked() return CloseWhenBackgroundIsClicked; } - internal void SendBackgroundClick() + internal bool SendBackgroundClick() { BackgroundClicked?.Invoke(this, EventArgs.Empty); if (BackgroundClickedCommand?.CanExecute(BackgroundClickedCommandParameter) == true) @@ -294,6 +294,8 @@ internal void SendBackgroundClick() if (OnBackgroundClicked()) { MopupService.Instance.RemovePageAsync(this).SafeFireAndForget(); + return true; } + return false; } } diff --git a/Mopups/Mopups.Maui/Platforms/Android/Handler/PopupPageHandler.cs b/Mopups/Mopups.Maui/Platforms/Android/Handler/PopupPageHandler.cs index 1243451..9510ab3 100644 --- a/Mopups/Mopups.Maui/Platforms/Android/Handler/PopupPageHandler.cs +++ b/Mopups/Mopups.Maui/Platforms/Android/Handler/PopupPageHandler.cs @@ -10,7 +10,12 @@ public class PopupPageHandler : PageHandler public PopupPageHandler() { - this.SetMauiContext(MauiApplication.Current.Application.Windows[0].Handler.MauiContext); + SetMauiContext(MauiApplication.Current.Application.Windows[0].Handler.MauiContext); + } + + public PopupPageHandler(IMauiContext context) + { + SetMauiContext(context); } protected override void ConnectHandler(ContentViewGroup platformView) diff --git a/Mopups/Mopups.Maui/Platforms/Android/Impl/AndroidMopups.cs b/Mopups/Mopups.Maui/Platforms/Android/Impl/AndroidMopups.cs index 6e888ad..205111e 100644 --- a/Mopups/Mopups.Maui/Platforms/Android/Impl/AndroidMopups.cs +++ b/Mopups/Mopups.Maui/Platforms/Android/Impl/AndroidMopups.cs @@ -36,13 +36,19 @@ public static bool SendBackPressed(Action? backPressedHandler = null) public Task AddAsync(PopupPage page) { - HandleAccessibility(true, page.DisableAndroidAccessibilityHandling); + HandleAccessibility(true, page.DisableAndroidAccessibilityHandling, page.Parent as Page); page.Parent = MauiApplication.Current.Application.Windows[0].Content as Element; - var AndroidNativeView = IPopupPlatform.GetOrCreateHandler(page).PlatformView as Android.Views.View; - DecoreView?.AddView(AndroidNativeView); + page.Parent ??= MauiApplication.Current.Application.Windows[0].Content as Element; - return PostAsync(AndroidNativeView); + var handler = page.Handler ??= new PopupPageHandler(page.Parent.Handler.MauiContext); + + var androidNativeView = handler.PlatformView as Android.Views.View; + var decoreView = Platform.CurrentActivity?.Window?.DecorView as FrameLayout; + + decoreView?.AddView(androidNativeView); + + return PostAsync(androidNativeView); } public Task RemoveAsync(PopupPage page) @@ -51,7 +57,7 @@ public Task RemoveAsync(PopupPage page) if (renderer != null) { - HandleAccessibility(false, page.DisableAndroidAccessibilityHandling); + HandleAccessibility(false, page.DisableAndroidAccessibilityHandling, page.Parent as Page); DecoreView?.RemoveView(renderer.PlatformView as Android.Views.View); renderer.DisconnectHandler(); //?? no clue if works @@ -65,7 +71,7 @@ public Task RemoveAsync(PopupPage page) //! important keeps reference to pages that accessibility has applied to. This is so accessibility can be removed properly when popup is removed. #https://github.com/LuckyDucko/Mopups/issues/93 readonly List views = new(); - void HandleAccessibility(bool showPopup, bool disableAccessibilityHandling) + void HandleAccessibility(bool showPopup, bool disableAccessibilityHandling, Page? mainPage = null) { if (disableAccessibilityHandling) { @@ -74,7 +80,7 @@ void HandleAccessibility(bool showPopup, bool disableAccessibilityHandling) if (showPopup) { - Page? mainPage = Application.Current?.MainPage; + mainPage ??= Application.Current?.MainPage; if (mainPage is null) { diff --git a/Mopups/Mopups.Maui/Platforms/iOS/Handler/PopupPageHandler.cs b/Mopups/Mopups.Maui/Platforms/iOS/Handler/PopupPageHandler.cs index 98ed62b..f6cd3c4 100644 --- a/Mopups/Mopups.Maui/Platforms/iOS/Handler/PopupPageHandler.cs +++ b/Mopups/Mopups.Maui/Platforms/iOS/Handler/PopupPageHandler.cs @@ -6,9 +6,13 @@ public class PopupPageHandler : PageHandler { public PopupPageHandler() { - this.SetMauiContext(MauiUIApplicationDelegate.Current.Application.Windows[0].Handler.MauiContext); //Still a hack? + SetMauiContext(MauiUIApplicationDelegate.Current.Application.Windows[0].Handler.MauiContext); //Still a hack? } + public PopupPageHandler(IMauiContext context) + { + SetMauiContext(context); //Still a hack? + } protected override Microsoft.Maui.Platform.ContentView CreatePlatformView() { return base.CreatePlatformView(); diff --git a/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs b/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs index b614cc5..6a58804 100644 --- a/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs +++ b/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs @@ -8,6 +8,8 @@ namespace Mopups.Platforms.iOS { internal class PopupWindow : UIWindow { + + private bool _stop = false; public PopupWindow(IntPtr handle) : base(handle) { } @@ -24,6 +26,12 @@ public PopupWindow(UIWindowScene uiWindowScene) : base(uiWindowScene) public override UIView HitTest(CGPoint point, UIEvent? uievent) { + + if (_stop) + { + return base.HitTest(point, uievent); + } + var platformHandler = (PopupPageRenderer?)RootViewController; var renderer = platformHandler?.Handler; var hitTestResult = base.HitTest(point, uievent); @@ -36,6 +44,11 @@ public override UIView HitTest(CGPoint point, UIEvent? uievent) if ((formsElement.BackgroundInputTransparent || formsElement.CloseWhenBackgroundIsClicked ) && renderer?.PlatformView == hitTestResult) { + if (formsElement.CloseWhenBackgroundIsClicked) + { + _stop = true; + } + formsElement.SendBackgroundClick(); if (formsElement.BackgroundInputTransparent) { diff --git a/Mopups/Mopups.Maui/Platforms/iOS/iOSMopups.cs b/Mopups/Mopups.Maui/Platforms/iOS/iOSMopups.cs index 67b3ae4..06a66b5 100644 --- a/Mopups/Mopups.Maui/Platforms/iOS/iOSMopups.cs +++ b/Mopups/Mopups.Maui/Platforms/iOS/iOSMopups.cs @@ -10,15 +10,13 @@ internal class iOSMopups : IPopupPlatform // It's necessary because GC in Xamarin.iOS 13 removes all UIWindow if there are not any references to them. See #459 private readonly List _windows = new List(); - private static bool IsiOS9OrNewer => UIDevice.CurrentDevice.CheckSystemVersion(9, 0); private static bool IsiOS13OrNewer => UIDevice.CurrentDevice.CheckSystemVersion(13, 0); - public bool IsSystemAnimationEnabled => true; public Task AddAsync(PopupPage page) { - page.Parent = Application.Current.MainPage; + page.Parent ??= Application.Current?.MainPage; page.DescendantRemoved += HandleChildRemoved; @@ -26,7 +24,7 @@ public Task AddAsync(PopupPage page) if (keyWindow?.WindowLevel == UIWindowLevel.Normal) keyWindow.WindowLevel = -1; - var handler = (PopupPageHandler)IPopupPlatform.GetOrCreateHandler(page); + var handler = (page.Handler ??= new PopupPageHandler(page.Parent.Handler.MauiContext)) as PopupPageHandler; PopupWindow window; diff --git a/SampleMaui/Platforms/Android/AndroidManifest.xml b/SampleMaui/Platforms/Android/AndroidManifest.xml index cf4c698..e48afa1 100644 --- a/SampleMaui/Platforms/Android/AndroidManifest.xml +++ b/SampleMaui/Platforms/Android/AndroidManifest.xml @@ -1,7 +1,6 @@  - - + \ No newline at end of file diff --git a/SampleMaui/SampleMopups.csproj b/SampleMaui/SampleMopups.csproj index e7ea7cd..a7b7047 100644 --- a/SampleMaui/SampleMopups.csproj +++ b/SampleMaui/SampleMopups.csproj @@ -2,8 +2,8 @@ - net7.0-android;net7.0-ios;net7.0-maccatalyst - $(TargetFrameworks);net7.0-windows10.0.19041.0 + net8.0-maccatalyst;net8.0-ios;net8.0-android + $(TargetFrameworks);net8.0-windows10.0.19041.0