-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtodo.mobl
69 lines (61 loc) · 1.43 KB
/
todo.mobl
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
64
65
66
67
68
69
application todo
title "Zodo"
database "zodo"
import mobl
entity Task {
name : String (searchable)
description : Text (searchable)
done : Bool
}
screen addTask() {
var newTask : Task = Task{}
backButton("Back", onclick={ screen return; })
basicView("Add") {
inputs {
inputString(newTask.name, placeholder="Task name")
}
button("Add", onclick={
add(newTask);
screen return;
})
}
}
screen editTask(t : Task) {
topRightButton("Done", onclick={ screen return; })
basicView("Edit") {
inputs {
inputString(t.name, placeholder="Task name")
inputString(t.description, placeholder="Task description")
}
button("Delete", onclick={
remove(t);
screen return;
})
}
}
screen root() {
template defaultView(t : Task, editing : Bool) {
item(onswipe={ editing = true; }) {
inputCheckbox(t.done, onclick={}) " "
outputString(t.name)
}
}
template editView(t : Task, editing : Bool) {
item(onswipe={ editing = false; }) {
inputCheckbox(t.done, onclick={}) " "
outputString(t.name)
sideButton("Delete", onclick={ remove(t); })
}
}
topRightButton("Add", onclick={ addTask(); })
var searchQuery = ""
basicView("Tasks") {
searchbox(searchQuery)
group {
list(t in Task.searchPrefix(searchQuery)) {
var editing = false
(editing ? editView : defaultView)(t, editing)
}
}
}
}