Additions for prototyping only

This commit is contained in:
Jon Lipsky 2019-06-25 07:12:19 -07:00
Родитель 2e92a5073b
Коммит b52c1b62bc
4 изменённых файлов: 68 добавлений и 2 удалений

Просмотреть файл

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>

Просмотреть файл

@ -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<Song> Songs = new List<Song>
{
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<Song>(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"); });
}
}

Просмотреть файл

@ -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<T, View> 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<object, View> 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<Func<object,View>> {
@ -32,7 +45,7 @@ namespace HotUI {
public IList List { get; }
public IEnumerator GetEnumerator () => List.GetEnumerator ();
public Func<object, View> CellCreator { get; protected set; }
public Func<object, View> CellCreator { get; set; }
public void Add(Func<object,View> viewCreator)
{
if(CellCreator != null) {

Просмотреть файл

@ -6,10 +6,17 @@ namespace HotUI {
{
}
public Text(object value)
{
Value = value?.ToString();
}
public Text(string value)
{
Value = value;
}
public Text(Func<string> formatedText)
{
TextBinding = formatedText;