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

Commit

Permalink
Remove unnecessary edge inset for vertically scrolling groups; Fixes … (
Browse files Browse the repository at this point in the history
#13380) fixes #13347

* Remove unnecessary edge inset for vertically scrolling groups; Fixes #13347

* Fix edge insets in horizontally-scrolling groups
  • Loading branch information
hartez committed Feb 9, 2021
1 parent 0e708d0 commit 7ea5159
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<CollectionView x:Name="CollectionView" IsGrouped="True" Header="This is a header" Footer="This is a footer.">

<CollectionView.ItemsLayout>
<GridItemsLayout Span="2" Orientation="Vertical"></GridItemsLayout>
<GridItemsLayout Span="2" HorizontalItemSpacing="5" Orientation="Vertical"></GridItemsLayout>
</CollectionView.ItemsLayout>

<CollectionView.ItemTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 7ea5159

Please sign in to comment.