-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] Figure a better EstimatedItemSize for HorizontalList (#20022)
* [Samples] Add repro case for issue #15815 * [iOS] Remove dead code * [iOS] Try find a better EstimatedItemSize for horizontal list * [uitest] Add Uitest for CollectionView * Fix test * Pink color
- Loading branch information
Showing
6 changed files
with
142 additions
and
15 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/Controls/samples/Controls.Sample.UITests/Issues/Issues15815.xaml
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,21 @@ | ||
<?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.Issues15815" | ||
Title="Issues15815"> | ||
<Grid RowDefinitions="Auto,Auto, Auto" > | ||
<Label Grid.Row="0" Text="The last cell (index 2) is not visible with MeasureAllItems if 1st cell is 50px width" /> | ||
<CollectionView x:Name="col" BackgroundColor="Pink" Grid.Row="1" ItemsLayout="HorizontalList" | ||
ItemSizingStrategy="MeasureAllItems" HeightRequest="200"> | ||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<Grid BackgroundColor="{Binding Color}" WidthRequest="{Binding Width}" HeightRequest="200"> | ||
<Label AutomationId="{Binding Id}" Text="{Binding Name}" FontSize="Header" TextColor="Black"/> | ||
</Grid> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
<Label Grid.Row="2" Text="Last Cell Blue should be visible" /> | ||
</Grid> | ||
|
||
</ContentPage> |
34 changes: 34 additions & 0 deletions
34
src/Controls/samples/Controls.Sample.UITests/Issues/Issues15815.xaml.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,34 @@ | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
using Microsoft.Maui.Graphics; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
|
||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 15815, "Horizontal CollectionView does not show the last element under some condition", PlatformAffected.iOS)] | ||
public partial class Issues15815 : ContentPage | ||
{ | ||
public Issues15815() | ||
{ | ||
InitializeComponent(); | ||
col.ItemsSource = new ObservableCollection<ItemViewModel> | ||
{ | ||
new ItemViewModel { Index = 0, Color = Colors.Red, Width = 50 }, | ||
new ItemViewModel { Index = 1, Color = Colors.Green, Width = 100 }, | ||
new ItemViewModel { Index = 2, Color = Colors.Blue, Width = 100 }, | ||
}; | ||
} | ||
|
||
class ItemViewModel | ||
{ | ||
public Color Color { get; set; } | ||
public int Width { get; set; } | ||
public int Index { get; set; } | ||
public string Id => $"id-{Index}"; | ||
public string Name => $"Item {Index}"; | ||
} | ||
} | ||
} |
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
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.AppiumTests.Issues; | ||
|
||
public class Issue15815 : _IssuesUITest | ||
{ | ||
public Issue15815(TestDevice device) | ||
: base(device) | ||
{ } | ||
|
||
public override string Issue => "Horizontal CollectionView does not show the last element under some condition"; | ||
|
||
[Test] | ||
public void LastItemIsVisilbe() | ||
{ | ||
var lastItem = App.WaitForElement("id-2"); | ||
Assert.AreEqual("Item 2", lastItem.GetText()); | ||
} | ||
} |