slint/examples/todo/ui/todo.slint
Florian Blasius 2324b35d12
napi test driver setup (#3635)
* Export interpreter stuff on private_api namespace

* Update api/napi/src/interpreter/value.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update tests/driver/napi/build.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update tests/driver/napi/Cargo.toml

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>


* Avoid unwanted prompt on Windows when running npm run build twice

Don't generate "napi.js" as then Windows will try to open it when running just "napi",
if nodejs registered .js as extension.

* Remove windows path workaround

It doesn't look like that it is needed.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2023-10-11 12:48:27 +02:00

124 lines
3.6 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT
import { SpinBox, Button, CheckBox, Slider, LineEdit, ScrollView, ListView,
HorizontalBox, VerticalBox, GridBox, StandardButton } from "std-widgets.slint";
export struct TodoItem {
title: string,
checked: bool,
}
component MainWindow inherits Window {
preferred-width: 400px;
preferred-height: 600px;
callback todo-added(string);
callback remove-done();
callback popup_confirmed;
callback show_confirm_popup;
callback apply_sorting_and_filtering();
show_confirm_popup => { confirm_popup.show(); }
confirm_popup := PopupWindow {
x: 40px;
y: 100px;
width: min(confirm_popup_layout.preferred-width, root.width - 80px);
Rectangle {
background: root.background;
border-color: confirm_popup_text.color;
border-width: 1px;
}
confirm_popup_layout := Dialog {
height:100%; width: 100%;
confirm_popup_text := Text {
text: "Some items are not done, are you sure you wish to quit?";
wrap: word-wrap;
}
StandardButton { kind: yes; clicked => { root.popup_confirmed(); } }
StandardButton { kind: no; }
}
}
in property <[TodoItem]> todo-model: [
{ title: "Implement the .slint 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 },
];
in property <bool> show-header: false;
in-out property <bool> is-sort-by-name: false;
in-out property <bool> hide-done-items: false;
VerticalBox {
HorizontalBox {
padding: 0px;
text-edit := LineEdit {
placeholder-text: "What needs to be done?";
accepted(text) => {
root.todo-added(self.text);
self.text = "";
}
}
btn := Button {
text: "Add New Entry";
enabled: text-edit.text != "";
clicked => {
root.todo-added(text-edit.text);
text-edit.text = "";
}
}
}
if (root.show-header) : HorizontalBox {
padding: 0px;
alignment: start;
CheckBox {
text: "Sort by name";
checked <=> root.is-sort-by-name;
toggled => {
root.apply_sorting_and_filtering();
}
}
CheckBox {
text: "Hide done items";
checked <=> root.hide-done-items;
toggled => {
root.apply_sorting_and_filtering();
}
}
}
list-view := ListView {
for todo in root.todo-model: HorizontalLayout {
CheckBox {
text: todo.title;
checked: todo.checked;
toggled => {
todo.checked = self.checked;
}
}
}
}
HorizontalBox {
padding: 0px;
alignment: end;
Button {
text: "Remove Done Items";
clicked => { root.remove-done(); }
}
}
}
}