From 2c1bd40c423722e6cf41b1a235b5df1ab3092339 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Wed, 7 Feb 2024 09:20:27 +0100 Subject: [PATCH] Popup was closing when background was touched instead of tapped --- .../Platforms/iOS/Handler/PopupPageRenderer.cs | 8 ++++---- .../Mopups.Maui/Platforms/iOS/PopupWindow.cs | 18 ++---------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/Mopups/Mopups.Maui/Platforms/iOS/Handler/PopupPageRenderer.cs b/Mopups/Mopups.Maui/Platforms/iOS/Handler/PopupPageRenderer.cs index abba826..d47a8b3 100644 --- a/Mopups/Mopups.Maui/Platforms/iOS/Handler/PopupPageRenderer.cs +++ b/Mopups/Mopups.Maui/Platforms/iOS/Handler/PopupPageRenderer.cs @@ -42,8 +42,8 @@ protected override void Dispose(bool disposing) { if (disposing) { + _renderer.ViewController.View?.RemoveGestureRecognizer(_tapGestureRecognizer); _renderer = null; - View?.RemoveGestureRecognizer(_tapGestureRecognizer); } base.Dispose(disposing); @@ -53,7 +53,7 @@ protected override void Dispose(bool disposing) private void OnTap(UITapGestureRecognizer e) { - var view = e.View; + var view = e.View.Subviews.First(); var location = e.LocationInView(view); var subview = view.HitTest(location, null); @@ -108,14 +108,14 @@ public override void ViewDidLoad() ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext; ModalTransitionStyle = UIModalTransitionStyle.CoverVertical; - View?.AddGestureRecognizer(_tapGestureRecognizer); + _renderer.ViewController.View?.AddGestureRecognizer(_tapGestureRecognizer); } public override void ViewDidUnload() { base.ViewDidUnload(); - View?.RemoveGestureRecognizer(_tapGestureRecognizer); + _renderer.ViewController.View?.RemoveGestureRecognizer(_tapGestureRecognizer); } public override void ViewWillAppear(bool animated) diff --git a/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs b/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs index 6a58804..d5ddfa1 100644 --- a/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs +++ b/Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs @@ -26,12 +26,6 @@ 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); @@ -42,18 +36,10 @@ public override UIView HitTest(CGPoint point, UIEvent? uievent) if (formsElement.InputTransparent) return null!; - if ((formsElement.BackgroundInputTransparent || formsElement.CloseWhenBackgroundIsClicked ) && renderer?.PlatformView == hitTestResult) + if (formsElement.BackgroundInputTransparent && renderer?.PlatformView == hitTestResult) { - if (formsElement.CloseWhenBackgroundIsClicked) - { - _stop = true; - } - formsElement.SendBackgroundClick(); - if (formsElement.BackgroundInputTransparent) - { - return null!; //fires off other handlers? If hit test returns null, it seems that other elements will process the click instead - } + return null!; } return hitTestResult;