Skip to content

Commit

Permalink
Merge pull request #90 from mlxyz/master
Browse files Browse the repository at this point in the history
Cast descendant of GetVisualTreeDescendants() to IElement in DisposeModelAndChildrenHandlers method for better type safety
  • Loading branch information
LuckyDucko authored Nov 30, 2023
2 parents a060c43 + 5098bd4 commit c51d66f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Mopups/Mopups.Maui/Platforms/iOS/iOSMopups.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using CoreGraphics;


using Mopups.Interfaces;
using Mopups.Interfaces;
using Mopups.Pages;
using Mopups.Platforms.iOS;

using UIKit;
using UIKit;
namespace Mopups.iOS.Implementation;

internal class iOSMopups : IPopupPlatform
Expand Down Expand Up @@ -57,7 +54,7 @@ public Task AddAsync(PopupPage page)

handler.ViewController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
handler.ViewController.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical;


return window.RootViewController.PresentViewControllerAsync(handler.ViewController, false);

Expand Down Expand Up @@ -124,12 +121,15 @@ public async Task RemoveAsync(PopupPage page)

private static void DisposeModelAndChildrenHandlers(VisualElement view)
{
foreach (Element child in view.GetVisualTreeDescendants())
foreach (var descendant in view.GetVisualTreeDescendants())
{
IElementHandler handler = child.Handler;
child?.Handler?.DisconnectHandler();
(handler?.PlatformView as UIView)?.RemoveFromSuperview();
(handler?.PlatformView as UIView)?.Dispose();
if (descendant is IElement child)
{
IElementHandler handler = child.Handler;
child?.Handler?.DisconnectHandler();
(handler?.PlatformView as UIView)?.RemoveFromSuperview();
(handler?.PlatformView as UIView)?.Dispose();
}
}

view?.Handler?.DisconnectHandler();
Expand Down

0 comments on commit c51d66f

Please sign in to comment.