2017-06-18 23:50:22 +00:00
|
|
|
using System;
|
2017-06-24 20:34:47 +00:00
|
|
|
using System.Collections.Generic;
|
2017-06-18 23:50:22 +00:00
|
|
|
using Ooui;
|
|
|
|
|
|
|
|
namespace Samples
|
|
|
|
{
|
|
|
|
public class TodoSample
|
|
|
|
{
|
2017-06-24 21:52:34 +00:00
|
|
|
List items = new List ();
|
2017-06-24 20:34:47 +00:00
|
|
|
|
2017-06-24 22:21:48 +00:00
|
|
|
class Item : ListItem
|
2017-06-18 23:50:22 +00:00
|
|
|
{
|
2017-06-24 22:21:48 +00:00
|
|
|
public Item (string text)
|
|
|
|
{
|
|
|
|
var check = new Input {
|
|
|
|
Type = InputType.Checkbox,
|
|
|
|
};
|
|
|
|
var label = new Label {
|
|
|
|
Text = text,
|
|
|
|
For = check
|
|
|
|
};
|
|
|
|
check.Changed += (s,e) => {
|
|
|
|
label.Style.TextDecoration =
|
|
|
|
check.IsChecked ? "line-through" : "none";
|
|
|
|
};
|
|
|
|
AppendChild (check);
|
|
|
|
AppendChild (label);
|
|
|
|
}
|
2017-06-24 21:52:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Element MakeTodo ()
|
|
|
|
{
|
2017-06-24 20:34:47 +00:00
|
|
|
var input = new Input ();
|
|
|
|
var button = new Button ("Add the item");
|
2017-06-18 23:50:22 +00:00
|
|
|
button.Clicked += (s, e) => {
|
2017-06-24 21:52:34 +00:00
|
|
|
if (string.IsNullOrWhiteSpace (input.Value))
|
|
|
|
return;
|
2017-06-24 22:21:48 +00:00
|
|
|
var item = new Item (input.Value);
|
2017-06-24 21:52:34 +00:00
|
|
|
items.AppendChild (item);
|
|
|
|
input.Value = "";
|
2017-06-18 23:50:22 +00:00
|
|
|
};
|
2017-06-24 20:34:47 +00:00
|
|
|
var app = new Div ();
|
|
|
|
app.AppendChild (input);
|
|
|
|
app.AppendChild (button);
|
|
|
|
app.AppendChild (items);
|
|
|
|
return app;
|
2017-06-18 23:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Publish ()
|
|
|
|
{
|
|
|
|
var b = MakeTodo ();
|
|
|
|
|
|
|
|
UI.Publish ("/todo", MakeTodo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|