summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1598.cs
blob: bb448743abe460eca7be74ea8154c4571cccc8a4 (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
using Xamarin.Forms.CustomAttributes;

namespace Xamarin.Forms.Controls
{
	public class MasterDetailToolbarBug : MasterDetailPage
	{
		public MasterDetailToolbarBug ()
		{
			Title = "MasterDetailToolbarBug";

			Master = new ContentPage () {
				Title = "Master"
			};
			Detail = new ContentPage () {
				Title = "Detail",
			};
			Detail.ToolbarItems.Add (new ToolbarItem ("ToolbarItem2", "Icon.png", ()
			                                                                      => { }));
		}
	}

	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 1598, "MasterDetailContainer does not handle adding of views which are already its children", PlatformAffected.Android)]
	public class Issue1598 : ContentPage
	{
		MasterDetailToolbarBug _secondPage = new MasterDetailToolbarBug ();

		public Issue1598 ()
		{
			Title = "XamarinTest MainMenu";

			var menu1 = new MainMenuCell ("MasterDetail - Toolbar bug", "Icon.png");
			menu1.Tapped += (o, e) => {
				Navigation.PushAsync (_secondPage);
			};

			var menu = new TableView () {
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.FillAndExpand,
				HasUnevenRows = true,
				Intent = TableIntent.Menu,
				Root = new TableRoot {
					new TableSection ("Menu") {
						menu1,
					}
				}
			};

			Content = menu;

			ToolbarItems.Add (new ToolbarItem ("ToolbarItem1", "bank.png", () => { }));
		}

		class MainMenuCell : ViewCell
		{
			public MainMenuCell (string title, string iconFile)
			{
				View = new StackLayout () {
					HorizontalOptions = LayoutOptions.FillAndExpand,
					VerticalOptions = LayoutOptions.FillAndExpand,
					Orientation = StackOrientation.Horizontal,
					Spacing = 15,
					Padding = 10,
					Children = {
						new Image () {
							Source = ImageSource.FromFile (iconFile),
							VerticalOptions = LayoutOptions.CenterAndExpand,
						},
						new Label () {
							Text = title,
							VerticalOptions = LayoutOptions.CenterAndExpand,
							Font = Font.SystemFontOfSize (NamedSize.Large,
							                              FontAttributes.Bold)
						}
					}
				};
			}
		}
	}
}