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

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 2563, "NavigationPage should support queuing of navigation events", PlatformAffected.Android | PlatformAffected.WinPhone | PlatformAffected.iOS)]
	public class Issue2563 : ContentPage
	{
		public Issue2563 ()
		{
			var button = new Button {
				Text = "Click Me",
				VerticalOptions = LayoutOptions.Center,
				HorizontalOptions = LayoutOptions.Center
			};

			Content = button;

			var random = new Random ();
			button.Clicked += (sender, args) => {
				for (int i = 0; i < 10; i++) {
					button.Navigation.PushAsync (new ContentPage {
						Title = "Page " + i,
						Content = new Label {
							Text = "Page " + i,
#pragma warning disable 618
							XAlign = TextAlignment.Center,
#pragma warning restore 618

#pragma warning disable 618
							YAlign = TextAlignment.Center
#pragma warning restore 618
						}
					}, random.NextDouble () > 0.5);
				}

				for (int i = 0; i < 6; i++) {
					button.Navigation.PopAsync (random.NextDouble () > 0.5);
				}

				button.Navigation.PopToRootAsync (random.NextDouble () > 0.5);
			};
		}
	}
}