Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 7ea5159

Browse files
authored
Remove unnecessary edge inset for vertically scrolling groups; Fixes … (#13380) fixes #13347
* Remove unnecessary edge inset for vertically scrolling groups; Fixes #13347 * Fix edge insets in horizontally-scrolling groups
1 parent 0e708d0 commit 7ea5159

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<CollectionView x:Name="CollectionView" IsGrouped="True" Header="This is a header" Footer="This is a footer.">
1010

1111
<CollectionView.ItemsLayout>
12-
<GridItemsLayout Span="2" Orientation="Vertical"></GridItemsLayout>
12+
<GridItemsLayout Span="2" HorizontalItemSpacing="5" Orientation="Vertical"></GridItemsLayout>
1313
</CollectionView.ItemsLayout>
1414

1515
<CollectionView.ItemTemplate>

Xamarin.Forms.Platform.iOS/CollectionView/GroupableItemsViewController.cs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -217,34 +217,24 @@ internal UIEdgeInsets GetInsetForSection(ItemsViewLayout itemsViewLayout,
217217
return uIEdgeInsets;
218218
}
219219

220-
// If we're grouping, we'll need to inset the sections to maintain the item spacing between the
221-
// groups and/or their group headers/footers
220+
// If we're grouping, we'll need to inset the sections to maintain the spacing between the
221+
// groups and their group headers/footers
222222

223-
var itemsLayout = ItemsView.ItemsLayout;
224-
var scrollDirection = itemsViewLayout.ScrollDirection;
225-
nfloat lineSpacing = itemsViewLayout.GetMinimumLineSpacingForSection(collectionView, itemsViewLayout, section);
223+
nfloat spacing = itemsViewLayout.GetMinimumLineSpacingForSection(collectionView, itemsViewLayout, section);
226224

227-
if (itemsLayout is GridItemsLayout)
228-
{
229-
nfloat itemSpacing = itemsViewLayout.GetMinimumInteritemSpacingForSection(collectionView, itemsViewLayout, section);
230-
231-
if (scrollDirection == UICollectionViewScrollDirection.Horizontal)
232-
{
233-
return new UIEdgeInsets(itemSpacing + uIEdgeInsets.Top, lineSpacing + uIEdgeInsets.Left,
234-
uIEdgeInsets.Bottom, uIEdgeInsets.Right);
235-
}
225+
var top = uIEdgeInsets.Top;
226+
var left = uIEdgeInsets.Left;
236227

237-
return new UIEdgeInsets(lineSpacing + uIEdgeInsets.Top, itemSpacing + uIEdgeInsets.Left,
238-
uIEdgeInsets.Bottom, uIEdgeInsets.Right);
228+
if (itemsViewLayout.ScrollDirection == UICollectionViewScrollDirection.Horizontal)
229+
{
230+
left += spacing;
239231
}
240-
241-
if (scrollDirection == UICollectionViewScrollDirection.Horizontal)
232+
else
242233
{
243-
return new UIEdgeInsets(uIEdgeInsets.Top, lineSpacing + uIEdgeInsets.Left,
244-
uIEdgeInsets.Bottom, uIEdgeInsets.Right);
234+
top += spacing;
245235
}
246236

247-
return new UIEdgeInsets(lineSpacing + uIEdgeInsets.Top, uIEdgeInsets.Left,
237+
return new UIEdgeInsets(top, left,
248238
uIEdgeInsets.Bottom, uIEdgeInsets.Right);
249239
}
250240

0 commit comments

Comments
 (0)