Skip to content
Merged
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
37 changes: 34 additions & 3 deletions src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
Loading