summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla53834.cs
blob: bb5b07e2acf8997da8bf65a6aa43865bf81b8715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
	}
}