Skip to content
Merged
Show file tree
Hide file tree
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
27 changes: 14 additions & 13 deletions src/Controls/src/Core/Handlers/Items2/iOS/TemplatedCell2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ public event EventHandler<LayoutAttributesChangedEventArgs2> LayoutAttributesCha
bool _measureInvalidated;
bool _needsArrange;
bool _hasArrangedSize;
bool _hasNativeBoundsSize;
bool _isArranging;
bool _invalidatedDuringArrange;
bool _requiresSafeAreaReconciliation;
Size _measuredSize;
Size _cachedConstraints;
Size _lastArrangedSize;
Size _lastNativeBoundsSize;
WeakReference<object> _itemsSource;

// Indicates the cell is being used as a supplementary view (group header/footer)
Expand Down Expand Up @@ -123,14 +125,10 @@ public override UICollectionViewLayoutAttributes PreferredLayoutAttributesFittin

if (_measureInvalidated || constraintsChanged)
{
// Dynamic content invalidations need an inline arrange so the
// updated content is rendered immediately. Constraint changes,
// such as rotation, are deferred to LayoutSubviews when the
// cell has already been arranged so the final native bounds
// are used for the arrange.
shouldArrangeInline =
!constraintsChanged && !_invalidatedDuringArrange;

// External invalidations need a synchronous arrange even if the outer
// size is unchanged. Arrange-induced invalidations only need another
// inline arrange when measurement produces a different size.
shouldArrangeInline = !_invalidatedDuringArrange || constraintsChanged;
_invalidatedDuringArrange = false;

// Preserve invalidations raised by Measure or Arrange for the next pass.
Expand Down Expand Up @@ -188,8 +186,9 @@ public override UICollectionViewLayoutAttributes PreferredLayoutAttributesFittin
preferredAttributes.ZIndex = 2;

if (_needsArrange &&
((shouldArrangeInline && _hasArrangedSize) ||
!_hasArrangedSize))
(shouldArrangeInline ||
!_hasArrangedSize ||
!size.ToCGSize().IsCloseTo(_lastArrangedSize)))
{
ArrangeVirtualView(virtualView, size);
}
Expand Down Expand Up @@ -231,7 +230,10 @@ public override void LayoutSubviews()
{
var boundsSize = Bounds.Size.ToSize();
var needsFinalArrange = _needsArrange;
var boundsChanged = _hasArrangedSize && !Bounds.Size.IsCloseTo(_lastArrangedSize);
// Preferred sizing can advance _lastArrangedSize before UIKit applies new bounds.
var boundsChanged = _hasNativeBoundsSize && !Bounds.Size.IsCloseTo(_lastNativeBoundsSize);
_hasNativeBoundsSize = true;
_lastNativeBoundsSize = boundsSize;
if (_requiresSafeAreaReconciliation ||
virtualView is ISafeAreaView2 { HasExplicitSafeAreaEdges: true })
{
Expand Down Expand Up @@ -268,8 +270,7 @@ public override void LayoutSubviews()
double.IsPositiveInfinity(_cachedConstraints.Height) ? boundsSize.Height : _cachedConstraints.Height));

if (safeAreaChanged ||
needsFinalArrange ||
(boundsChanged && measuredConstraintsMatchBounds))
(boundsChanged && (needsFinalArrange || measuredConstraintsMatchBounds)))
{
ArrangeVirtualView(virtualView, boundsSize);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task LayoutPassesShouldNotIncrease()
if (App.FindElement("HeadingLabel").GetText() == "CollectionViewHandler2")
{
maxMeasurePasses = 373;
maxArrangePasses = 276;
maxArrangePasses = 313;
Comment thread
BagavathiPerumal marked this conversation as resolved.
Resolved
}
#elif ANDROID
const int maxMeasurePasses = 353;
Expand Down
Loading