summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/ViewContainers/StateViewContainer.cs
blob: b08cc3063448e19e88868f8a3bb4d601d084d53f (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
using System;

namespace Xamarin.Forms.Controls
{
	internal class StateViewContainer<T> : ViewContainer<T> 
		where T : View
	{
		public Button StateChangeButton { get; private set; }
		public Label ViewInteractionLabel { get; private set; }

		public StateViewContainer (Enum formsMember, T view) : base (formsMember, view)
		{
			var name = formsMember.ToString ();

			var stateTitleLabel = new Label {
				Text = name + "?"
			};

			ViewInteractionLabel = new Label {
				Text = "Interacted? : False"
			};

			var stateValueLabel = new Label {
				BindingContext = view,
				AutomationId = name + "StateLabel"
			};
			if (name != "Focus")
				stateValueLabel.SetBinding (Label.TextProperty, name, converter: new GenericValueConverter (o => o.ToString()));

			StateChangeButton = new Button {
				Text = "Change State: " + name,
				AutomationId = name + "StateButton"
			};

			var labelLayout = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				Children = {
					stateTitleLabel,
					stateValueLabel
				}
			};

			ContainerLayout.Children.Add (ViewInteractionLabel);
			ContainerLayout.Children.Add (labelLayout);
			ContainerLayout.Children.Add (StateChangeButton);
		}
	}
}