Skip to content

Commit

Permalink
[iOS] Make sure to distinguish between group header and global header…
Browse files Browse the repository at this point in the history
… on CV2
  • Loading branch information
rmarinho committed Oct 18, 2024
1 parent 0eedb14 commit 11a183f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ protected override void RegisterViewTypes()

private protected override void RegisterSupplementaryViews(UICollectionElementKindSection kind)
{
base.RegisterSupplementaryViews(kind);
if (IsHorizontal)
base.RegisterSupplementaryViews(kind);
if (IsHorizontal)
{
CollectionView.RegisterClassForSupplementaryView(typeof(HorizontalSupplementaryView2),
kind, HorizontalSupplementalView2ReuseId);
Expand All @@ -87,10 +87,14 @@ string DetermineViewReuseId(NSString elementKind)
public override UICollectionReusableView GetViewForSupplementaryElement(UICollectionView collectionView,
NSString elementKind, NSIndexPath indexPath)
{
var suplementaryViewFromStructuredView = base.GetViewForSupplementaryElement(collectionView, elementKind, indexPath);
if (suplementaryViewFromStructuredView is not null)
// If the IndexPath is less than 2, it's a header or footer for a section not a group
if (indexPath.Length < 2)
{
return suplementaryViewFromStructuredView;
var suplementaryViewFromStructuredView = base.GetViewForSupplementaryElement(collectionView, elementKind, indexPath);
if (suplementaryViewFromStructuredView is not null)
{
return suplementaryViewFromStructuredView;
}
}

var reuseId = DetermineViewReuseId(elementKind);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public CollectionViewCoreGalleryContentPage()
// VisitAndUpdateItemsSource (src\Compatibility\ControlGallery\src\UITests.Shared\Tests\CollectionViewUITests.cs)
TestBuilder.NavButton("Default Text Galleries", () => new DefaultTextGallery(), Navigation),
TestBuilder.NavButton("DataTemplate Galleries", () => new DataTemplateGallery(), Navigation),
TestBuilder.NavButton("Grouping Galleries", () => new GroupingGallery(), Navigation),
TestBuilder.NavButton("Header Footer Galleries", () => new HeaderFooterGallery(), Navigation),
TestBuilder.NavButton("Observable Collection Galleries", () => new ObservableCollectionGallery(), Navigation),
// SelectionShouldUpdateBinding (src\Compatibility\ControlGallery\src\Issues.Shared\CollectionViewBoundSingleSelection.cs)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests
{
public class CollectionViewGroupingTests : CollectionViewUITests
{

protected override bool ResetAfterEachTest => true;

public CollectionViewGroupingTests(TestDevice device)
: base(device)
{
}

[Test]
[Category(UITestCategories.CollectionView)]
public void GroupingAndHeaderWorks()
{
VisitInitialGallery("Grouping");

VisitSubGallery("Basic Grouping");

// header
App.WaitForElement("This is a header");
// group header
App.WaitForElement("Avengers");
// group footer
App.WaitForElement("Total members: 12");
}
}
}

0 comments on commit 11a183f

Please sign in to comment.