-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Use better layout/measure path with refreshview * - fix naming * - set RefreshView content to maui compatible container * - add test * - fix null operator * Update Issue23029.xaml.cs * - fix content panel so it removes previous content * - add additional check
- Loading branch information
Showing
10 changed files
with
224 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23029.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Issue23029 : _IssuesUITest | ||
{ | ||
public override string Issue => "RefreshView doesn't use correct layout mechanisms"; | ||
|
||
public Issue23029(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
[Test] | ||
[Category(UITestCategories.RefreshView)] | ||
public void ValidateRefreshViewContentGetsFrameSet() | ||
{ | ||
App.WaitForElement("SizeChangedLabel"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?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.Issue23029"> | ||
<!-- | ||
Remove RefreshView or comment it out, and you will notice SizeChanged is fired | ||
and if you add RefreshView the SizeChanged will not fire. | ||
--> | ||
<Grid RowDefinitions="Auto,*" x:Name="grid"> | ||
<RefreshView Grid.Row="1"> | ||
<CollectionView x:Name="CView"> | ||
|
||
<CollectionView.ItemsLayout> | ||
<GridItemsLayout Orientation="Vertical" Span="1" /> | ||
</CollectionView.ItemsLayout> | ||
|
||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<Grid Padding="0, 0, 10, 10"> | ||
<Border Padding="20" Stroke="CornflowerBlue" StrokeThickness="1.5" Background="Transparent"> | ||
<Border.StrokeShape> | ||
<RoundRectangle CornerRadius="20"/> | ||
</Border.StrokeShape> | ||
|
||
<VerticalStackLayout Spacing="10"> | ||
|
||
<Label Text="{Binding ProgramName}" /> | ||
|
||
<Label Text="{Binding CourseName}" /> | ||
|
||
<Label Text="{Binding DueDate}" /> | ||
|
||
<HorizontalStackLayout Spacing="5"> | ||
<Button Text="Download" /> | ||
<Button Text="Upload" /> | ||
</HorizontalStackLayout> | ||
</VerticalStackLayout> | ||
</Border> | ||
</Grid> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
</RefreshView> | ||
</Grid> | ||
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[Issue(IssueTracker.Github, 23029, "RefreshView doesn't use correct layout mechanisms", PlatformAffected.All)] | ||
public partial class Issue23029 : ContentPage | ||
{ | ||
public Issue23029() | ||
{ | ||
InitializeComponent(); | ||
ObservableCollection<AssessmentModel> list = []; | ||
for (int i = 0; i < 100; i++) | ||
{ | ||
list.Add(new AssessmentModel() | ||
{ | ||
ProgramName = "International Assessment " + i.ToString(), | ||
CourseName = "English " + i.ToString(), | ||
DueDate = DateTime.Now.ToShortDateString() | ||
}); | ||
} | ||
CView.ItemsSource = list; | ||
|
||
CView.SizeChanged += OnSizeChanged; | ||
} | ||
|
||
private void OnSizeChanged(object sender, EventArgs e) | ||
{ | ||
if (CView.Frame.Height > 0 && CView.Width > 0 && grid.Children.Count == 1) | ||
{ | ||
// Works around a bug with modifying the grid while it's being measured | ||
this.Dispatcher.Dispatch(() => | ||
{ | ||
grid.Children.Insert(0, new Label() { Text = "Size Changed", AutomationId = "SizeChangedLabel" }); | ||
}); | ||
} | ||
|
||
if (sender is CollectionView collectionView && collectionView.ItemsLayout is GridItemsLayout gridItemsLayout) | ||
{ | ||
double maxWidthPerItem = 300; | ||
gridItemsLayout.Span = Math.Max(1, (int)(collectionView.Width / maxWidthPerItem)); | ||
} | ||
} | ||
|
||
public class AssessmentModel | ||
{ | ||
public string ProgramName { get; set; } = string.Empty; | ||
public string CourseName { get; set; } = string.Empty; | ||
public string DueDate { get; set; } = string.Empty; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.