diff --git a/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs b/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs index a61b16aa851f..235472aeab54 100644 --- a/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs +++ b/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs @@ -93,7 +93,7 @@ static UICollectionViewLayout CreateListLayout(UICollectionViewScrollDirection s //create global header and footer layoutConfiguration.BoundarySupplementaryItems = CreateSupplementaryItems(null, layoutHeaderFooterInfo, scrollDirection, groupWidth, groupHeight); - var layout = new CustomUICollectionViewCompositionalLayout(snapInfo, (sectionIndex, environment) => + var layout = new CustomUICollectionViewCompositionalLayout(snapInfo, groupingInfo, layoutHeaderFooterInfo, (sectionIndex, environment) => { // Each item has a size var itemSize = NSCollectionLayoutSize.Create(itemWidth, itemHeight); @@ -151,7 +151,7 @@ static UICollectionViewLayout CreateGridLayout(UICollectionViewScrollDirection s var layoutConfiguration = new UICollectionViewCompositionalLayoutConfiguration(); layoutConfiguration.ScrollDirection = scrollDirection; - var layout = new CustomUICollectionViewCompositionalLayout(snapInfo, (sectionIndex, environment) => + var layout = new CustomUICollectionViewCompositionalLayout(snapInfo, groupingInfo, headerFooterInfo, (sectionIndex, environment) => { // Each item has a size var itemSize = NSCollectionLayoutSize.Create(itemWidth, itemHeight); @@ -450,11 +450,15 @@ class CustomUICollectionViewCompositionalLayout : UICollectionViewCompositionalL { LayoutSnapInfo _snapInfo; ItemsUpdatingScrollMode _itemsUpdatingScrollMode; + LayoutGroupingInfo? _groupingInfo; + LayoutHeaderFooterInfo? _headerFooterInfo; - public CustomUICollectionViewCompositionalLayout(LayoutSnapInfo snapInfo, UICollectionViewCompositionalLayoutSectionProvider sectionProvider, UICollectionViewCompositionalLayoutConfiguration configuration, ItemsUpdatingScrollMode itemsUpdatingScrollMode) : base(sectionProvider, configuration) + public CustomUICollectionViewCompositionalLayout(LayoutSnapInfo snapInfo, LayoutGroupingInfo? groupingInfo, LayoutHeaderFooterInfo? headerFooterInfo, UICollectionViewCompositionalLayoutSectionProvider sectionProvider, UICollectionViewCompositionalLayoutConfiguration configuration, ItemsUpdatingScrollMode itemsUpdatingScrollMode) : base(sectionProvider, configuration) { _snapInfo = snapInfo; _itemsUpdatingScrollMode = itemsUpdatingScrollMode; + _groupingInfo = groupingInfo; + _headerFooterInfo = headerFooterInfo; } public override void FinalizeCollectionViewUpdates() @@ -558,6 +562,33 @@ public override CGPoint TargetContentOffset(CGPoint proposedContentOffset, CGPoi Configuration.ScrollDirection); } + public override CGSize CollectionViewContentSize + { + get + { + if (CollectionView != null) + { + bool hasGlobalHeaders = _headerFooterInfo?.HasHeader == true || _headerFooterInfo?.HasFooter == true; + bool hasGroupHeaders = _groupingInfo?.HasHeader == true || _groupingInfo?.HasFooter == true; + + if (hasGlobalHeaders || hasGroupHeaders) + { + return base.CollectionViewContentSize; + } + + if (CollectionView.NumberOfSections() > 0 && + CollectionView.NumberOfItemsInSection(0) > 0) + { + return base.CollectionViewContentSize; + } + + return CGSize.Empty; + } + + return base.CollectionViewContentSize; + } + } + CGPoint ScrollSingle(SnapPointsAlignment alignment, CGPoint proposedContentOffset, CGPoint scrollingVelocity) { // Get the viewport of the UICollectionView at the current content offset