-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Wire RefreshView up to our xplat layout workflow #23169
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
76ab234
Use better layout/measure path with refreshview
PureWeen 8020033
- fix naming
PureWeen cac0a38
- set RefreshView content to maui compatible container
PureWeen 408dc8a
- add test
PureWeen 89316b5
- fix null operator
PureWeen 6b89090
Update Issue23029.xaml.cs
PureWeen f3d8dd0
- fix content panel so it removes previous content
PureWeen 28cb8ae
- add additional check
PureWeen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,53 @@ | ||
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
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
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was most likely here to workaround the fact that we didn't have the layout path setup correctly.
It looks like the original addition of this didn't add tests
#14302
So, it'd be good to test through those closed issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the sample here and it looks good still