diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml index aee06400441..f30d1c16aae 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml @@ -9,7 +9,7 @@ - + diff --git a/Xamarin.Forms.Platform.iOS/CollectionView/GroupableItemsViewController.cs b/Xamarin.Forms.Platform.iOS/CollectionView/GroupableItemsViewController.cs index 752700fc3dd..66dae2a3f93 100644 --- a/Xamarin.Forms.Platform.iOS/CollectionView/GroupableItemsViewController.cs +++ b/Xamarin.Forms.Platform.iOS/CollectionView/GroupableItemsViewController.cs @@ -217,34 +217,24 @@ int GetLayoutSpanCount() return uIEdgeInsets; } - // If we're grouping, we'll need to inset the sections to maintain the item spacing between the - // groups and/or their group headers/footers + // If we're grouping, we'll need to inset the sections to maintain the spacing between the + // groups and their group headers/footers - var itemsLayout = ItemsView.ItemsLayout; - var scrollDirection = itemsViewLayout.ScrollDirection; - nfloat lineSpacing = itemsViewLayout.GetMinimumLineSpacingForSection(collectionView, itemsViewLayout, section); + nfloat spacing = itemsViewLayout.GetMinimumLineSpacingForSection(collectionView, itemsViewLayout, section); - if (itemsLayout is GridItemsLayout) - { - nfloat itemSpacing = itemsViewLayout.GetMinimumInteritemSpacingForSection(collectionView, itemsViewLayout, section); - - if (scrollDirection == UICollectionViewScrollDirection.Horizontal) - { - return new UIEdgeInsets(itemSpacing + uIEdgeInsets.Top, lineSpacing + uIEdgeInsets.Left, - uIEdgeInsets.Bottom, uIEdgeInsets.Right); - } + var top = uIEdgeInsets.Top; + var left = uIEdgeInsets.Left; - return new UIEdgeInsets(lineSpacing + uIEdgeInsets.Top, itemSpacing + uIEdgeInsets.Left, - uIEdgeInsets.Bottom, uIEdgeInsets.Right); + if (itemsViewLayout.ScrollDirection == UICollectionViewScrollDirection.Horizontal) + { + left += spacing; } - - if (scrollDirection == UICollectionViewScrollDirection.Horizontal) + else { - return new UIEdgeInsets(uIEdgeInsets.Top, lineSpacing + uIEdgeInsets.Left, - uIEdgeInsets.Bottom, uIEdgeInsets.Right); + top += spacing; } - return new UIEdgeInsets(lineSpacing + uIEdgeInsets.Top, uIEdgeInsets.Left, + return new UIEdgeInsets(top, left, uIEdgeInsets.Bottom, uIEdgeInsets.Right); }