Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert CollectionView, the footer moves to the bottom of the page when the empty view or empty view template is enabled #27288

Merged
merged 7 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -109,24 +109,8 @@ void UpdateEmptyViewSize(double width, double height)

if (adapter is EmptyViewAdapter emptyViewAdapter)
{
var emptyView = emptyViewAdapter.EmptyView ?? emptyViewAdapter.EmptyViewTemplate;
Size size = Size.Zero;

IView view = emptyView as IView ?? (emptyView as DataTemplate)?.CreateContent() as IView;

if (view is not null)
{
if (view.Handler is null)
{
TemplateHelpers.GetHandler(view as View, this.MauiContext);
}

size = view.Measure(double.PositiveInfinity, double.PositiveInfinity);
}

var measuredHeight = !double.IsInfinity(size.Height) ? Context.ToPixels(size.Height) : height;
emptyViewAdapter.RecyclerViewWidth = width;
emptyViewAdapter.RecyclerViewHeight = measuredHeight > 0 ? measuredHeight : height;
emptyViewAdapter.RecyclerViewHeight = height;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,8 @@ protected virtual void RegisterViewTypes()

protected virtual CGRect DetermineEmptyViewFrame()
{
nfloat emptyViewHeight = CollectionView.Frame.Height;

if (_emptyViewFormsElement is IView emptyView)
{
emptyViewHeight = (nfloat)emptyView.Measure(CollectionView.Frame.Width, double.PositiveInfinity).Height;
}
return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y, CollectionView.Frame.Width, emptyViewHeight);
return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y,
CollectionView.Frame.Width, CollectionView.Frame.Height);
}

protected void RemeasureLayout(VisualElement formsElement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,15 @@ protected override CGRect DetermineEmptyViewFrame()
nfloat headerHeight = 0;
var headerView = CollectionView.ViewWithTag(HeaderTag);

if (headerView is not null)
if (headerView != null)
headerHeight = headerView.Frame.Height;

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

if (footerView is not null)
if (footerView != null)
footerHeight = footerView.Frame.Height;

var emptyView = CollectionView.ViewWithTag(EmptyTag);

if (emptyView is not null)
return base.DetermineEmptyViewFrame();

return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y, CollectionView.Frame.Width,
Math.Abs(CollectionView.Frame.Height - (headerHeight + footerHeight)));
}
Expand Down
Binary file not shown.
58 changes: 0 additions & 58 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24966.xaml

This file was deleted.

73 changes: 0 additions & 73 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24966.xaml.cs

This file was deleted.

31 changes: 31 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue27229.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.Issue27229"
xmlns:cv1="clr-namespace:Maui.Controls.Sample"
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"
x:Name="ThisMainPage"
Title="Main Page">
<CollectionView>
<CollectionView.EmptyView>
<ContentView>
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
<Label
Margin="10,25,10,10"
FontAttributes="Bold"
FontSize="18"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
AutomationId="ReadyToTest"
Text="No results matched your filter." />
<Label
FontAttributes="Italic"
FontSize="12"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="Try a broader filter?" />
</StackLayout>
</ContentView>
</CollectionView.EmptyView>
</CollectionView>
</ContentPage>
20 changes: 20 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue27229.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Collections.Specialized;

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 27229, "CollectionView, EmptyView Fills Available Space By Default")]
public partial class Issue27229
{
public Issue27229()
{
InitializeComponent();
}
}
}
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
internal class Issue27229 : _IssuesUITest
{
public Issue27229(TestDevice device) : base(device) { }

public override string Issue => "CollectionView, EmptyView Fills Available Space By Default";

[Test]
[Category(UITestCategories.CollectionView)]
public void CollectionViewEmptyViewFillsAvailableSpaceByDefault()
{
App.WaitForElement("ReadyToTest");
VerifyScreenshot();
}
}
}
Binary file not shown.
Loading