slint/examples/todo/ui/todo.60

75 lines
2.3 KiB
Text

/* LICENSE BEGIN
This file is part of the SixtyFPS Project -- https://sixtyfps.io
Copyright (c) 2020 Olivier Goffart <olivier.goffart@sixtyfps.io>
Copyright (c) 2020 Simon Hausmann <simon.hausmann@sixtyfps.io>
SPDX-License-Identifier: GPL-3.0-only
This file is also available under commercial licensing terms.
Please contact info@sixtyfps.io for more information.
LICENSE END */
import { SpinBox, Button, CheckBox, Slider, LineEdit, ScrollView, ListView } 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 },
];
VerticalLayout {
HorizontalLayout {
text_edit := LineEdit {
placeholder-text: "What needs to be done?";
accepted(text) => {
todo_added(text);
}
}
btn := Button {
text: "Add New Entry";
enabled: text_edit.text != "";
clicked => {
todo_added(text_edit.text);
}
}
}
list_view := ListView {
for todo in todo_model: Rectangle {
height: 22px;
GridLayout {
CheckBox {
text: todo.title;
checked: todo.checked;
toggled => {
todo.checked = checked;
}
}
}
}
}
HorizontalLayout {
alignment: end;
Button {
text: "Remove Done Items";
clicked => { root.remove_done(); }
}
}
}
}