diff --git a/sample/HotUI.Samples/HotUI.Samples.csproj b/sample/HotUI.Samples/HotUI.Samples.csproj index 42c0784e..e2d9c932 100644 --- a/sample/HotUI.Samples/HotUI.Samples.csproj +++ b/sample/HotUI.Samples/HotUI.Samples.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 diff --git a/sample/HotUI.Samples/ListPage2.cs b/sample/HotUI.Samples/ListPage2.cs new file mode 100644 index 00000000..c8195c15 --- /dev/null +++ b/sample/HotUI.Samples/ListPage2.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using HotUI.Samples.Models; + +namespace HotUI.Samples +{ + public class ListPage2 : HotPage + { + //This should come from a database or something + List Songs = new List + { + new Song + { + Title = "All the Small Things", + Artist = "Blink-182", + Album = "Dude Ranch", + }, + new Song + { + Title = "Monster", + Artist = "Skillet", + Album = "Awake", + } + }; + + protected override View Build() => new ListView(Songs) + { + BuildCell = song => new Stack + { + new Image(song.ArtworkUrl), + new Stack + { + new Text(song.Title), + new Text(song.Artist), + new Text(song.Album), + } + }, + BuildHeader = group => new Stack + { + new Text(group) + }, + BackgroundColor = Color.Green, + }.OnSelected((song) => { Console.WriteLine("Song Selected"); }); + } +} \ No newline at end of file diff --git a/src/HotUI/Controls/ListView.cs b/src/HotUI/Controls/ListView.cs index d2a366a4..38383a9b 100644 --- a/src/HotUI/Controls/ListView.cs +++ b/src/HotUI/Controls/ListView.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Drawing; namespace HotUI { @@ -21,6 +22,18 @@ namespace HotUI { { this.ItemSelected = (o) => onTap?.Invoke ((T)o); } + + public Func BuildCell + { + get => o => CellCreator?.Invoke(o); + set => CellCreator = o => value.Invoke((T)o); + } + + // todo: this doesn't do anything, just added this for prototyping purposes. + public Func BuildHeader { get; set; } + + // todo: doesn't do anything, just added this for right now as a sample. + public Color BackgroundColor { get; set; } } public class ListView : View, IEnumerable, IEnumerable> { @@ -32,7 +45,7 @@ namespace HotUI { public IList List { get; } public IEnumerator GetEnumerator () => List.GetEnumerator (); - public Func CellCreator { get; protected set; } + public Func CellCreator { get; set; } public void Add(Func viewCreator) { if(CellCreator != null) { diff --git a/src/HotUI/Controls/Text.cs b/src/HotUI/Controls/Text.cs index 1fca6924..bdd4f1c5 100644 --- a/src/HotUI/Controls/Text.cs +++ b/src/HotUI/Controls/Text.cs @@ -6,10 +6,17 @@ namespace HotUI { { } + + public Text(object value) + { + Value = value?.ToString(); + } + public Text(string value) { Value = value; } + public Text(Func formatedText) { TextBinding = formatedText;