diff options
author | Samantha Houts <samhouts@users.noreply.github.com> | 2017-03-24 04:02:59 -0700 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2017-03-24 11:02:59 +0000 |
commit | eea0bdcc6e3fdfcf3229abedac32204e47602f60 (patch) | |
tree | d6cadd11b85585adc33ea4c5d0948e884c3f15a3 /Xamarin.Forms.Controls.Issues | |
parent | 79ecf97d92331c790b5ba5c99f453607260f40cb (diff) | |
download | xamarin-forms-eea0bdcc6e3fdfcf3229abedac32204e47602f60.tar.gz xamarin-forms-eea0bdcc6e3fdfcf3229abedac32204e47602f60.tar.bz2 xamarin-forms-eea0bdcc6e3fdfcf3229abedac32204e47602f60.zip |
[iOS] Don't skip row height estimation for grouped lists (#838)
* Nest bugzilla 51536 classes for less pollution
* Add repro for 53834
* [iOS] Don't skip row height estimation for grouped lists
Diffstat (limited to 'Xamarin.Forms.Controls.Issues')
3 files changed, 128 insertions, 33 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51536.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51536.cs index 05149128..ad6e89f2 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51536.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51536.cs @@ -32,49 +32,49 @@ namespace Xamarin.Forms.Controls.Issues Content = listView; } - } - - [Preserve(AllMembers = true)] - public sealed class ItemViewModel - { - public string Name { get; set; } - public string Description { get; set; } - } - [Preserve(AllMembers = true)] - public sealed class ItemViewCell : ViewCell - { - public Label Label1 { get; set; } - public Label Label2 { get; set; } + [Preserve(AllMembers = true)] + public sealed class ItemViewModel + { + public string Name { get; set; } + public string Description { get; set; } + } - public ItemViewCell() + [Preserve(AllMembers = true)] + public sealed class ItemViewCell : ViewCell { - var stackLayout = new StackLayout + public Label Label1 { get; set; } + public Label Label2 { get; set; } + + public ItemViewCell() { - Orientation = StackOrientation.Vertical, - HorizontalOptions = LayoutOptions.StartAndExpand, - VerticalOptions = LayoutOptions.StartAndExpand - }; + var stackLayout = new StackLayout + { + Orientation = StackOrientation.Vertical, + HorizontalOptions = LayoutOptions.StartAndExpand, + VerticalOptions = LayoutOptions.StartAndExpand + }; - Label1 = new Label(); - Label2 = new Label { LineBreakMode = LineBreakMode.WordWrap }; + Label1 = new Label(); + Label2 = new Label { LineBreakMode = LineBreakMode.WordWrap }; - stackLayout.Children.Add(Label1); - stackLayout.Children.Add(Label2); + stackLayout.Children.Add(Label1); + stackLayout.Children.Add(Label2); - View = stackLayout; - } + View = stackLayout; + } - protected override void OnBindingContextChanged() - { - base.OnBindingContextChanged(); + protected override void OnBindingContextChanged() + { + base.OnBindingContextChanged(); - var item = BindingContext as ItemViewModel; + var item = BindingContext as ItemViewModel; - if (item != null) - { - Label1.Text = item.Name; - Label2.Text = item.Description; + if (item != null) + { + Label1.Text = item.Name; + Label2.Text = item.Description; + } } } } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla53834.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla53834.cs new file mode 100644 index 00000000..bb5b07e2 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla53834.cs @@ -0,0 +1,94 @@ +using System.Collections.ObjectModel; +using System.Linq; +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +#if UITEST +using Xamarin.Forms.Core.UITests; +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 53834, "incorrect row heights on ios when using groupheadertemplate in Xamarin.Forms 2.3.4.214-pre5", PlatformAffected.iOS)] + public class Bugzilla53834 : TestContentPage + { + const string Instructions = ""; + ObservableCollection<GroupedItem> grouped { get; set; } + ListView lstView; + + class MyViewCell : ViewCell + { + public MyViewCell() + { + var label = new Label { HeightRequest = 66, VerticalOptions = LayoutOptions.Start }; + label.SetBinding(Label.TextProperty, "."); + View = new StackLayout { Padding = 10, Children = { label } }; + } + } + + class MyHeaderViewCell : ViewCell + { + public MyHeaderViewCell() + { + Height = 25; + var label = new Label { VerticalOptions = LayoutOptions.Center }; + label.SetBinding(Label.TextProperty, nameof(GroupedItem.LongName)); + View = label; + } + } + + class GroupedItem : ObservableCollection<string> + { + public string LongName { get; set; } + public string ShortName { get; set; } + } + + protected override void Init() + { + var label = new Label { Text = Instructions }; + grouped = new ObservableCollection<GroupedItem>(); + lstView = new ListView() + { + IsGroupingEnabled = true, + HasUnevenRows = true, + ItemTemplate = new DataTemplate(typeof(MyViewCell)), + GroupHeaderTemplate = new DataTemplate(typeof(MyHeaderViewCell)), + ItemsSource = grouped, + }; + + var grp1 = new GroupedItem() { LongName = "Group 1", ShortName = "1" }; + var grp2 = new GroupedItem() { LongName = "Group 2", ShortName = "2" }; + + for (int i = 1; i < 4; i++) + { + grp1.Add($"I am a short text #{i}"); + grp1.Add($"I am a long text that should cause the line to wrap, and I should not be cut off or overlapping in any way. #{i}"); + grp2.Add($"I am a short text #{i}"); + grp2.Add($"I am a long text that should cause the line to wrap, and I should not be cut off or overlapping in any way. #{i}"); + } + + grouped.Add(grp1); + grouped.Add(grp2); + + Content = new StackLayout + { + Children = { + label, + lstView + } + }; + } + +#if (UITEST && __IOS__) + [Test] + [Category(UITestCategories.ManualReview)] + public void Bugzilla53834Test() + { + RunningApp.Screenshot("incorrect row heights test"); + } +#endif + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 5a8d41fa..6a621e4f 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -158,6 +158,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44096.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44176.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44453.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Bugzilla53834.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla51536.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44940.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44944.cs" /> |