Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,11 @@ void TearDownEmptyView()
_emptyViewFormsElement = null;
}

void LayoutEmptyView()
virtual internal CGRect LayoutEmptyView()
{
if (!_initialized || _emptyUIView == null || _emptyUIView.Superview == null)
{
return;
return CGRect.Empty;
}

var frame = DetermineEmptyViewFrame();
Expand All @@ -541,6 +541,8 @@ void LayoutEmptyView()

if (_emptyViewFormsElement != null && ((IElementController)ItemsView).LogicalChildren.IndexOf(_emptyViewFormsElement) != -1)
_emptyViewFormsElement.Layout(frame.ToRectangle());

return frame;
}

internal protected virtual void UpdateVisibility()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@ string DetermineViewReuseId(DataTemplate template, object item)
: VerticalSupplementaryView2.ReuseId;
}

internal override CGRect LayoutEmptyView()
{
var emptyViewFrame = base.LayoutEmptyView();
var footerView = CollectionView.ViewWithTag(FooterTag);

if (footerView is not null)
{
if (emptyViewFrame.Height > 0)
footerView.Frame = new CGRect(footerView.Frame.X, emptyViewFrame.Bottom, footerView.Frame.Width, footerView.Frame.Height);
else
footerView.Frame = new CGRect(footerView.Frame.X, CollectionView.ContentSize.Height - footerView.Frame.Height, footerView.Frame.Width, footerView.Frame.Height);
}

return emptyViewFrame;
}

protected override CGRect DetermineEmptyViewFrame()
{
nfloat headerHeight = 0;
Expand All @@ -175,7 +191,7 @@ protected override CGRect DetermineEmptyViewFrame()
if (footerView != null)
footerHeight = footerView.Frame.Height;

return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y, CollectionView.Frame.Width,
return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y + headerHeight, CollectionView.Frame.Width,
Math.Abs(CollectionView.Frame.Height - (headerHeight + footerHeight)));
}

Expand Down
31 changes: 31 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25606.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue25606">
<VerticalStackLayout>
<CollectionView VerticalOptions="Fill">

<CollectionView.Header>
<ContentView HeightRequest="200"
BackgroundColor="Red">
<Label AutomationId="Header"
Text="Header"/>
</ContentView>
</CollectionView.Header>

<CollectionView.EmptyView>
<ContentView
BackgroundColor="Blue">
<Label Text="EmptyView"/>
</ContentView>
</CollectionView.EmptyView>

<CollectionView.Footer>
<ContentView HeightRequest="200"
BackgroundColor="Green">
<Label Text="Footer"/>
</ContentView>
</CollectionView.Footer>
</CollectionView>
</VerticalStackLayout>
</ContentPage>
11 changes: 11 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25606.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.Github, "25606", "Empty View Overlapping Header in CollectionView with CollectionViewHandler2", PlatformAffected.iOS)]
public partial class Issue25606 : ContentPage
{
public Issue25606()
{
InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue25606 : _IssuesUITest
{
public Issue25606(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Empty View Overlapping Header in CollectionView with CollectionViewHandler2";

[Test]
[Category(UITestCategories.CollectionView)]
public void HeaderShouldNotBeCoveredByEmptyView()
{
App.WaitForElement("Header");
}
}
}