Skip to content

Commit

Permalink
Clean up needs view logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Redth committed Nov 28, 2023
1 parent 2c8fe23 commit d08495e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions VirtualListView/Apple/CvCell.ios.maccatalyst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ public override UICollectionViewLayoutAttributes PreferredLayoutAttributesFittin
}

public bool NeedsView
=> NativeView == null || !NativeView.TryGetTarget(out var _);
=> NativeView == null
|| VirtualView is null
|| !NativeView.TryGetTarget(out var _)
|| !VirtualView.TryGetTarget(out var _);

public WeakReference<IView> VirtualView { get; set; }

Expand All @@ -113,19 +116,20 @@ public override void PrepareForReuse()
public void SetupView(IView view)
{
// Create a new platform native view if we don't have one yet
if (!(NativeView?.TryGetTarget(out var nativeView) ?? false))
if (!(NativeView?.TryGetTarget(out var _) ?? false))
{
nativeView = view.ToPlatform(this.Handler.MauiContext);
var nativeView = view.ToPlatform(this.Handler.MauiContext);
nativeView.Frame = this.ContentView.Frame;
nativeView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
this.ContentView.AddSubview(nativeView);
NativeView = new WeakReference<UIView>(nativeView);

this.ContentView.AddSubview(nativeView);

NativeView = new WeakReference<UIView>(nativeView);
}

if (!(VirtualView?.TryGetTarget(out var virtualView) ?? false) || (virtualView?.Handler is null))
{
virtualView = view;
VirtualView = new WeakReference<IView>(virtualView);
VirtualView = new WeakReference<IView>(view);
}
}

Expand Down

0 comments on commit d08495e

Please sign in to comment.