Skip to content

Commit 1d028df

Browse files
committed
Address PR feedback
1 parent 4ce15e9 commit 1d028df

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

src/Controls/src/Core/Handlers/Items/iOS/ItemsViewController.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,13 @@ protected virtual void UpdateTemplatedCell(TemplatedCell cell, NSIndexPath index
520520

521521
void ClearMeasurementCells()
522522
{
523-
if (_measurementCells is not null)
523+
foreach (var measurementCell in _measurementCells.Values)
524524
{
525-
foreach (var measurementCell in _measurementCells.Values)
526-
{
527-
measurementCell.LayoutAttributesChanged -= CellLayoutAttributesChanged;
528-
measurementCell.Unbind();
529-
}
530-
531-
_measurementCells.Clear();
525+
measurementCell.LayoutAttributesChanged -= CellLayoutAttributesChanged;
526+
measurementCell.Unbind();
532527
}
528+
529+
_measurementCells.Clear();
533530
}
534531

535532
public virtual NSIndexPath GetIndexForItem(object item)

src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewController2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void InvalidateLayoutIfItemsMeasureChanged()
218218
{
219219
if (visibleCells[n] is TemplatedCell2 { MeasureInvalidated: true } cell)
220220
{
221-
var indexPath = CollectionView.IndexPathForCell(cell);
221+
var indexPath = collectionView.IndexPathForCell(cell);
222222
if (indexPath is not null && Items.IndexPathHelpers.IsIndexPathValid(ItemsSource, indexPath))
223223
{
224224
invalidatedIndexPaths ??= [];

src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.iOS.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,13 @@ await CreateHandlerAndAddToWindow<THandler>(collectionView, async handler =>
309309
// Reset the data source to force another animation and a layout pass
310310
collectionView.ItemsSource = null;
311311

312-
await Task.Delay(100);
313-
((UIView)handler.PlatformView).LayoutIfNeeded();
312+
var platformView = (UIView)handler.PlatformView;
313+
var uiCollectionView = platformView as UICollectionView ?? platformView.Subviews.OfType<UICollectionView>().FirstOrDefault();
314+
Assert.NotNull(uiCollectionView);
315+
// Force synchronous flush of the ItemsSource reloading
316+
await uiCollectionView.PerformBatchUpdatesAsync(() => { });
317+
// Force a layout
318+
platformView.LayoutIfNeeded();
314319
});
315320
}
316321

0 commit comments

Comments
 (0)