mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
75 lines
2.3 KiB
Text
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 {
|
|
width: 400px;
|
|
height: 600px;
|
|
signal todo_added(string);
|
|
signal 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(); }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|