Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null VirtualView #137

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;

}
}
}
Loading