Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Move layout change resolution call up to VisualElement
Browse files Browse the repository at this point in the history
Fixes #13418
Fixes #13492
  • Loading branch information
hartez committed Feb 3, 2021
1 parent 520c136 commit 3ff9979
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 36 deletions.
10 changes: 0 additions & 10 deletions Xamarin.Forms.Platform.Android/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,16 +1315,6 @@ protected override void Dispose(bool disposing)

bool ILayoutChanges.HasLayoutOccurred => _hasLayoutOccurred;

protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
if (Element is Layout layout)
{
layout.ResolveLayoutChanges();
}

base.OnMeasure(widthMeasureSpec, heightMeasureSpec);
}

protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
{
base.OnLayout(changed, left, top, right, bottom);
Expand Down
10 changes: 10 additions & 0 deletions Xamarin.Forms.Platform.Android/VisualElementRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,5 +505,15 @@ internal virtual void SendVisualElementInitialized(VisualElement element, AView

void IVisualElementRenderer.SetLabelFor(int? id)
=> ViewCompat.SetLabelFor(this, id ?? ViewCompat.GetLabelFor(this));

protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
if (Element is Layout layout)
{
layout.ResolveLayoutChanges();
}

base.OnMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
}
6 changes: 0 additions & 6 deletions Xamarin.Forms.Platform.UAP/LayoutRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,5 @@ void UpdateClipToBounds()
Clip = new RectangleGeometry { Rect = new WRect(0, 0, ActualWidth, ActualHeight) };
}
}

protected override Windows.Foundation.Size MeasureOverride(Windows.Foundation.Size availableSize)
{
Element?.ResolveLayoutChanges();
return base.MeasureOverride(availableSize);
}
}
}
5 changes: 5 additions & 0 deletions Xamarin.Forms.Platform.UAP/VisualElementRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ protected override Windows.Foundation.Size MeasureOverride(Windows.Foundation.Si
if (Element == null || availableSize.Width * availableSize.Height == 0)
return new Windows.Foundation.Size(0, 0);

if (Element is Layout layout)
{
layout.ResolveLayoutChanges();
}

Element.IsInNativeLayout = true;

for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
Expand Down
20 changes: 0 additions & 20 deletions Xamarin.Forms.Platform.iOS/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,26 +586,6 @@ public override UIView HitTest(CGPoint point, UIEvent uievent)

return result;
}

void ResolveLayoutChanges()
{
if (Element is Layout layout)
{
layout.ResolveLayoutChanges();
}
}

public override void LayoutSubviews()
{
ResolveLayoutChanges();
base.LayoutSubviews();
}

public override CGSize SizeThatFits(CGSize size)
{
ResolveLayoutChanges();
return base.SizeThatFits(size);
}
}

internal static string ResolveMsAppDataUri(Uri uri)
Expand Down
12 changes: 12 additions & 0 deletions Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,25 @@ public void SetElement(TElement element)
}

#if __MOBILE__

void ResolveLayoutChanges()
{
if (Element is Layout layout)
{
layout.ResolveLayoutChanges();
}
}

public override SizeF SizeThatFits(SizeF size)
{
ResolveLayoutChanges();
return new SizeF(0, 0);
}

public override void LayoutSubviews()
{
ResolveLayoutChanges();

base.LayoutSubviews();

if (_blur != null && Superview != null)
Expand Down

0 comments on commit 3ff9979

Please sign in to comment.