Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 41a1ff5

Browse files
PureWeenjsuarezruiz
andauthoredJan 24, 2025··
Revert CollectionView, the footer moves to the bottom of the page when the empty view or empty view template is enabled (#27288)
* Revert "CollectionView, the footer moves to the bottom of the page when the empty view or empty view template is enabled (#24997)" This reverts commit 763b6f5. # Conflicts: # src/Controls/src/Core/Handlers/Items/iOS/ItemsViewController.cs # src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue24966.cs * - update testing * Pending snapshots * Windows snapshot * Add conditional compilation for Windows tests * - remove windows image --------- Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com>
1 parent 246a43f commit 41a1ff5

15 files changed

+79
-190
lines changed
 

‎src/Controls/src/Core/Handlers/Items/ItemsViewHandler.Android.cs

+1-17
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,8 @@ void UpdateEmptyViewSize(double width, double height)
109109

110110
if (adapter is EmptyViewAdapter emptyViewAdapter)
111111
{
112-
var emptyView = emptyViewAdapter.EmptyView ?? emptyViewAdapter.EmptyViewTemplate;
113-
Size size = Size.Zero;
114-
115-
IView view = emptyView as IView ?? (emptyView as DataTemplate)?.CreateContent() as IView;
116-
117-
if (view is not null)
118-
{
119-
if (view.Handler is null)
120-
{
121-
TemplateHelpers.GetHandler(view as View, this.MauiContext);
122-
}
123-
124-
size = view.Measure(double.PositiveInfinity, double.PositiveInfinity);
125-
}
126-
127-
var measuredHeight = !double.IsInfinity(size.Height) ? Context.ToPixels(size.Height) : height;
128112
emptyViewAdapter.RecyclerViewWidth = width;
129-
emptyViewAdapter.RecyclerViewHeight = measuredHeight > 0 ? measuredHeight : height;
113+
emptyViewAdapter.RecyclerViewHeight = height;
130114
}
131115
}
132116
}

‎src/Controls/src/Core/Handlers/Items/iOS/ItemsViewController.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -538,13 +538,8 @@ protected virtual void RegisterViewTypes()
538538

539539
protected virtual CGRect DetermineEmptyViewFrame()
540540
{
541-
nfloat emptyViewHeight = CollectionView.Frame.Height;
542-
543-
if (_emptyViewFormsElement is IView emptyView)
544-
{
545-
emptyViewHeight = (nfloat)emptyView.Measure(CollectionView.Frame.Width, double.PositiveInfinity).Height;
546-
}
547-
return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y, CollectionView.Frame.Width, emptyViewHeight);
541+
return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y,
542+
CollectionView.Frame.Width, CollectionView.Frame.Height);
548543
}
549544

550545
protected void RemeasureLayout(VisualElement formsElement)

‎src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,15 @@ protected override CGRect DetermineEmptyViewFrame()
7070
nfloat headerHeight = 0;
7171
var headerView = CollectionView.ViewWithTag(HeaderTag);
7272

73-
if (headerView is not null)
73+
if (headerView != null)
7474
headerHeight = headerView.Frame.Height;
7575

7676
nfloat footerHeight = 0;
7777
var footerView = CollectionView.ViewWithTag(FooterTag);
7878

79-
if (footerView is not null)
79+
if (footerView != null)
8080
footerHeight = footerView.Frame.Height;
8181

82-
var emptyView = CollectionView.ViewWithTag(EmptyTag);
83-
84-
if (emptyView is not null)
85-
return base.DetermineEmptyViewFrame();
86-
8782
return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y, CollectionView.Frame.Width,
8883
Math.Abs(CollectionView.Frame.Height - (headerHeight + footerHeight)));
8984
}

‎src/Controls/tests/TestCases.HostApp/Issues/Issue24966.xaml

-58
This file was deleted.

‎src/Controls/tests/TestCases.HostApp/Issues/Issue24966.xaml.cs

-73
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Maui.Controls.Sample.Issues.Issue27229"
5+
xmlns:cv1="clr-namespace:Maui.Controls.Sample"
6+
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"
7+
x:Name="ThisMainPage"
8+
Title="Main Page">
9+
<CollectionView>
10+
<CollectionView.EmptyView>
11+
<ContentView>
12+
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
13+
<Label
14+
Margin="10,25,10,10"
15+
FontAttributes="Bold"
16+
FontSize="18"
17+
HorizontalOptions="Fill"
18+
HorizontalTextAlignment="Center"
19+
AutomationId="ReadyToTest"
20+
Text="No results matched your filter." />
21+
<Label
22+
FontAttributes="Italic"
23+
FontSize="12"
24+
HorizontalOptions="Fill"
25+
HorizontalTextAlignment="Center"
26+
Text="Try a broader filter?" />
27+
</StackLayout>
28+
</ContentView>
29+
</CollectionView.EmptyView>
30+
</CollectionView>
31+
</ContentPage>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.ComponentModel;
5+
using System.Runtime.CompilerServices;
6+
using System.Windows.Input;
7+
using System.Collections.Specialized;
8+
9+
namespace Maui.Controls.Sample.Issues
10+
{
11+
[XamlCompilation(XamlCompilationOptions.Compile)]
12+
[Issue(IssueTracker.Github, 27229, "CollectionView, EmptyView Fills Available Space By Default")]
13+
public partial class Issue27229
14+
{
15+
public Issue27229()
16+
{
17+
InitializeComponent();
18+
}
19+
}
20+
}

‎src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue24966.cs

-28
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#if TEST_FAILS_ON_WINDOWS
2+
using NUnit.Framework;
3+
using UITest.Appium;
4+
using UITest.Core;
5+
6+
namespace Microsoft.Maui.TestCases.Tests.Issues
7+
{
8+
internal class Issue27229 : _IssuesUITest
9+
{
10+
public Issue27229(TestDevice device) : base(device) { }
11+
12+
public override string Issue => "CollectionView, EmptyView Fills Available Space By Default";
13+
14+
[Test]
15+
[Category(UITestCategories.CollectionView)]
16+
public void CollectionViewEmptyViewFillsAvailableSpaceByDefault()
17+
{
18+
App.WaitForElement("ReadyToTest");
19+
VerifyScreenshot();
20+
}
21+
}
22+
}
23+
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.