Skip to content

Commit

Permalink
Merge pull request #137 from IeuanWalker/NullVirtualView
Browse files Browse the repository at this point in the history
Null VirtualView
  • Loading branch information
LuckyDucko authored Sep 30, 2024
2 parents b5fb645 + bce14b7 commit 66f585d
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions Mopups/Mopups.Maui/Platforms/iOS/PopupWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,42 @@ public PopupWindow(UIWindowScene uiWindowScene) : base(uiWindowScene)

}

public override UIView HitTest(CGPoint point, UIEvent? uievent)
public override UIView? HitTest(CGPoint point, UIEvent? uievent)
{
var platformHandler = (PopupPageRenderer?)RootViewController;
var renderer = platformHandler?.Handler;
var hitTestResult = base.HitTest(point, uievent);
try
{
var platformHandler = (PopupPageRenderer?)RootViewController;
var renderer = platformHandler?.Handler;
var hitTestResult = base.HitTest(point, uievent);

if (!(platformHandler?.Handler?.VirtualView is PopupPage formsElement))
return hitTestResult;
if(renderer?.VirtualView is null)
{
return hitTestResult;
}

if(renderer.VirtualView is not PopupPage formsElement)
return hitTestResult;

if (formsElement.InputTransparent)
return null!;
if(formsElement.InputTransparent)
return null;

if (formsElement.BackgroundInputTransparent && renderer?.PlatformView == hitTestResult)
if(formsElement.BackgroundInputTransparent && renderer.PlatformView == hitTestResult)
{
formsElement.SendBackgroundClick();
return null;
}
return hitTestResult;
}
catch(Exception)
{
formsElement.SendBackgroundClick();
return null!;
// Perform any necessary cleanup here
RootViewController?.View?.RemoveFromSuperview();
RootViewController = null;
Hidden = true;
Dispose();

return null;
}
return hitTestResult;

}
}
}

0 comments on commit 66f585d

Please sign in to comment.