forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo.60
73 lines (66 loc) · 2.28 KB
/
todo.60
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
70
71
72
73
/* LICENSE BEGIN
This file is part of the SixtyFPS Project -- https://sixtyfps.io
Copyright (c) 2021 Olivier Goffart <[email protected]>
Copyright (c) 2021 Simon Hausmann <[email protected]>
SPDX-License-Identifier: GPL-3.0-only
This file is also available under commercial licensing terms.
Please contact [email protected] for more information.
LICENSE END */
import { SpinBox, Button, CheckBox, Slider, LineEdit, ScrollView, ListView, HorizontalBox, VerticalBox, GridBox } from "sixtyfps_widgets.60";
export struct TodoItem := {
title: string,
checked: bool,
}
MainWindow := Window {
preferred-width: 400px;
preferred-height: 600px;
callback todo-added(string);
callback remove-done();
property <[TodoItem]> todo-model: [
{ title: "Implement the .60 file", checked: true },
{ title: "Do the Rust part", checked: false },
{ title: "Make the C++ code", checked: false },
{ title: "Write some JavaScript code", checked: false },
{ title: "Test the application", checked: false },
{ title: "Ship to customer", checked: false },
{ title: "???", checked: false },
{ title: "Profit", checked: false },
];
VerticalBox {
HorizontalBox {
text-edit := LineEdit {
placeholder-text: "What needs to be done?";
accepted(text) => {
todo-added(text);
self.text = "";
}
}
btn := Button {
text: "Add New Entry";
enabled: text-edit.text != "";
clicked => {
todo-added(text-edit.text);
text-edit.text = "";
}
}
}
list-view := ListView {
for todo in todo-model: HorizontalLayout {
CheckBox {
text: todo.title;
checked: todo.checked;
toggled => {
todo.checked = checked;
}
}
}
}
HorizontalBox {
alignment: end;
Button {
text: "Remove Done Items";
clicked => { root.remove-done(); }
}
}
}
}