Skip to content

Commit

Permalink
Revert "chore: [iOS] Remove unneeded workaround"
Browse files Browse the repository at this point in the history
This reverts commit a2e5c9c.
  • Loading branch information
davidjohnoliver committed Oct 28, 2021
1 parent 801f51c commit 56510fa
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/ListViewBase/ListViewBaseSource.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ public override CGRect Frame
{
base.Frame = value;
UpdateContentViewFrame();
UpdateContentLayoutSlots(value);
}
}

Expand All @@ -766,6 +767,7 @@ public override CGRect Bounds
}
base.Bounds = value;
UpdateContentViewFrame();
UpdateContentLayoutSlots(Frame);
}
}

Expand All @@ -781,6 +783,20 @@ private void UpdateContentViewFrame()
}
}

/// <summary>
/// Fakely propagate the applied Frame of this internal container as the LayoutSlot of the publicly visible container.
/// This is required for the UIElement.TransformToVisual to work properly.
/// </summary>
private void UpdateContentLayoutSlots(Rect frame)
{
var content = Content;
if (content != null)
{
LayoutInformation.SetLayoutSlot(content, frame);
content.LayoutSlotWithMarginsAndAlignments = frame;
}
}

/// <summary>
/// Clear the cell's measured size, this allows the static template size to be updated with the correct databound size.
/// </summary>
Expand Down Expand Up @@ -918,6 +934,11 @@ public override void LayoutSubviews()
if (Content != null)
{
Layouter.ArrangeChild(Content, new Rect(0, 0, (float)size.Width, (float)size.Height));

// The item has to be arranged relative to this internal container (at 0,0),
// but doing this the LayoutSlot[WithMargins] has been updated,
// so we fakely re-inject the relative position of the item in its parent.
UpdateContentLayoutSlots(Frame);
}
}

Expand Down

0 comments on commit 56510fa

Please sign in to comment.