Skip to content

Commit

Permalink
Popup was closing when background was touched instead of tapped
Browse files Browse the repository at this point in the history
  • Loading branch information
dalux-kh committed Feb 7, 2024
1 parent 6031022 commit 2c1bd40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
8 changes: 4 additions & 4 deletions Mopups/Mopups.Maui/Platforms/iOS/Handler/PopupPageRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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)
Expand Down
18 changes: 2 additions & 16 deletions Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

Expand Down

0 comments on commit 2c1bd40

Please sign in to comment.