summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/GalleryPages/CellTypeList.cs
blob: 4298bc81e4a79177f27d63ba14f746db1d77651e (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
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;

namespace Xamarin.Forms.Controls
{
	internal class CellTypesListPage : ContentPage
	{
		public CellTypesListPage ()
		{
			Content = new CellTypeList ();
		}
	}

	[Preserve (AllMembers = true)]
	public class CellNavigation
	{
		public string CellType { get; set; }
		public ContentPage Page { get; set; }

		public CellNavigation (string type, ContentPage page)
		{
			CellType = type;
			Page = page;
		}
	}

	public class CellTypeList : ListView
	{
		// TODO Add gallerys for ViewCell, ListView and TableView
		public CellTypeList ()
		{
			var itemList = new List<CellNavigation> {
				new CellNavigation ("TextCell List", new TextCellListPage ()),
				new CellNavigation ("TextCell Table", new TextCellTablePage ()),
				new CellNavigation ("ImageCell List", new ImageCellListPage ()),
				new CellNavigation ("ImageCell Url List", new UrlImageCellListPage()),
				new CellNavigation ("ImageCell Table", new ImageCellTablePage ()),
				new CellNavigation ("SwitchCell List", new SwitchCellListPage ()),
				new CellNavigation ("SwitchCell Table", new SwitchCellTablePage ()),
				new CellNavigation ("EntryCell List", new EntryCellListPage ()),
				new CellNavigation ("EntryCell Table", new EntryCellTablePage ()),
				new CellNavigation ("ViewCell Image url table", new UrlImageViewCellListPage())
			};
			
			ItemsSource = itemList;

			var template = new DataTemplate (typeof (TextCell));
			template.SetBinding (TextCell.TextProperty, new Binding ("CellType"));

			ItemTemplate = template;
			ItemSelected += (s, e) => {
				if (SelectedItem == null)
					return;

				var cellNav = (CellNavigation) e.SelectedItem;
				Navigation.PushAsync (cellNav.Page);
				SelectedItem = null;
			};
		}		
	}
}