-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS, Catalyst] Fixed CollectionView items height appears larger in Developer Balance sample #31902
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
Merged
+378
−8
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c7a5f00
Fixed CollectionView card height appears larger in Developer Balance …
karthikraja-arumugam 06a8d74
Issue31897 modified test class
karthikraja-arumugam b7cd42a
Issue31897 Modified test sample
karthikraja-arumugam b22fb4b
Issue31897 the fix comment has been updated
karthikraja-arumugam 753c75c
Modified the test samppe
devanathan-vaithiyanathan 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
This file contains hidden or 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 hidden or 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
176 changes: 176 additions & 0 deletions
176
src/Controls/tests/TestCases.HostApp/Issues/Issue31897.cs
This file contains hidden or 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,176 @@ | ||
| using System.ComponentModel; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 31897, "CollectionView card height appears larger in Developer Balance sample", PlatformAffected.iOS | PlatformAffected.macOS)] | ||
| public class Issue31897 : ContentPage | ||
| { | ||
| Button getHeight; | ||
| Label HeightLabel; | ||
| CollectionView2 ProjectsCollectionView; | ||
|
|
||
| public Issue31897() | ||
| { | ||
| var mainGrid = new Grid(); | ||
|
|
||
| var scrollView = new ScrollView(); | ||
|
|
||
| // Create the inner grid with padding and row spacing | ||
| var innerGrid = new Grid | ||
| { | ||
| Padding = new Thickness(10), | ||
| RowSpacing = 10 | ||
| }; | ||
|
|
||
| // Add row definitions | ||
| innerGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); | ||
| innerGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); | ||
| innerGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); | ||
|
|
||
| // Create the "Get CV Height" button | ||
| getHeight = new Button | ||
| { | ||
| Text = "Get CV Height", | ||
| AutomationId = "GetHeightButton" | ||
| }; | ||
|
|
||
| getHeight.Clicked += (object sender, EventArgs e) => | ||
| { | ||
| HeightLabel.Text = Math.Round(ProjectsCollectionView.Height).ToString(); | ||
| }; | ||
|
|
||
| getHeight.SetValue(SemanticProperties.HeadingLevelProperty, SemanticHeadingLevel.Level1); | ||
| Grid.SetRow(getHeight, 0); | ||
|
|
||
| // Create the height label | ||
| HeightLabel = new Label(); | ||
| HeightLabel.AutomationId = "HeightLabel"; | ||
| HeightLabel.SetValue(SemanticProperties.HeadingLevelProperty, SemanticHeadingLevel.Level1); | ||
| Grid.SetRow(HeightLabel, 1); | ||
|
|
||
| // Create the CollectionView | ||
| ProjectsCollectionView = new CollectionView2 | ||
| { | ||
| Margin = new Thickness(-7.5, 0), | ||
| MinimumHeightRequest = 250, | ||
| SelectionMode = SelectionMode.Single | ||
| }; | ||
|
|
||
| // Set up the ItemsLayout | ||
| ProjectsCollectionView.ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal) | ||
| { | ||
| ItemSpacing = 7.5 | ||
| }; | ||
|
|
||
| // Create the DataTemplate for items | ||
| var itemTemplate = new DataTemplate(() => | ||
| { | ||
| var border = new Border | ||
| { | ||
| WidthRequest = 200, | ||
| Background = Colors.GreenYellow | ||
| }; | ||
|
|
||
| var contentView = new ContentView(); | ||
|
|
||
| var verticalStackLayout = new VerticalStackLayout | ||
| { | ||
| Spacing = 15, | ||
| Background = Colors.Red, | ||
| VerticalOptions = LayoutOptions.Start | ||
| }; | ||
|
|
||
| // Name label | ||
| var nameLabel = new Label | ||
| { | ||
| TextColor = Colors.Gray, | ||
| FontSize = 14, | ||
| TextTransform = TextTransform.Uppercase | ||
| }; | ||
| nameLabel.SetBinding(Label.TextProperty, "Name"); | ||
|
|
||
| // Description label | ||
| var descriptionLabel = new Label | ||
| { | ||
| LineBreakMode = LineBreakMode.WordWrap | ||
| }; | ||
| descriptionLabel.SetBinding(Label.TextProperty, "Description"); | ||
|
|
||
| verticalStackLayout.Children.Add(nameLabel); | ||
| verticalStackLayout.Children.Add(descriptionLabel); | ||
| contentView.Content = verticalStackLayout; | ||
| border.Content = contentView; | ||
|
|
||
| return border; | ||
| }); | ||
|
|
||
| ProjectsCollectionView.ItemTemplate = itemTemplate; | ||
|
|
||
| // Set up data binding | ||
| var viewModel = new Issue31897ViewModel(); | ||
| BindingContext = viewModel; | ||
| ProjectsCollectionView.SetBinding(CollectionView.ItemsSourceProperty, "Projects"); | ||
|
|
||
| Grid.SetRow(ProjectsCollectionView, 2); | ||
|
|
||
| // Add all controls to the inner grid | ||
| innerGrid.Children.Add(getHeight); | ||
| innerGrid.Children.Add(HeightLabel); | ||
| innerGrid.Children.Add(ProjectsCollectionView); | ||
|
|
||
| // Set up the hierarchy | ||
| scrollView.Content = innerGrid; | ||
| mainGrid.Children.Add(scrollView); | ||
| Content = mainGrid; | ||
| } | ||
|
|
||
| public class Issue31897ViewModel : INotifyPropertyChanged | ||
| { | ||
| List<Issue31897Project> _projects = new(); | ||
|
|
||
| public event PropertyChangedEventHandler PropertyChanged; | ||
|
|
||
| protected virtual void OnPropertyChanged(string propertyName) | ||
| { | ||
| PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
| } | ||
|
|
||
| public List<Issue31897Project> Projects | ||
| { | ||
| get { return _projects; } | ||
| set | ||
| { | ||
| _projects = value; | ||
| OnPropertyChanged(nameof(Projects)); | ||
| } | ||
| } | ||
|
|
||
| public Issue31897ViewModel() | ||
| { | ||
| LoadData(); | ||
| } | ||
|
|
||
| void LoadData() | ||
| { | ||
| var projects = new List<Issue31897Project>(); | ||
| for (int i = 0; i < 4; i++) | ||
| { | ||
| projects.Add(new Issue31897Project | ||
| { | ||
| ID = i, | ||
| Name = "Developer balance card view " + (i + 1), | ||
| Description = "This is a sample description for project " + (i + 1) | ||
| }); | ||
| } | ||
|
|
||
| Projects = projects; | ||
| } | ||
| } | ||
|
|
||
| public class Issue31897Project | ||
| { | ||
| public int ID { get; set; } | ||
| public string Name { get; set; } = string.Empty; | ||
| public string Description { get; set; } = string.Empty; | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31897.cs
This file contains hidden or 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,23 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue31897 : _IssuesUITest | ||
| { | ||
| public Issue31897(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
| public override string Issue => "CollectionView card height appears larger in Developer Balance sample"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.CollectionView)] | ||
| public void EnsureCollectionViewLayoutOnItemsSourceChange() | ||
| { | ||
| App.WaitForElement("GetHeightButton"); | ||
| App.Tap("GetHeightButton"); | ||
| var label = App.WaitForElement("HeightLabel"); | ||
| Assert.That(label.GetText(), Is.EqualTo("250")); | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
Could expand the tests by setting different item sources and asserting layout change (e.g., when items are added/removed, does the height still reflect correctly?). This ensures future changes do not regress measurement logic.
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.
@jsuarezruiz, New test scenarios were included. Could you please review and let me know if any concerns?