mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00

* Get todo example running with napi. * Code review fixes. * Code review feedback. * Code review fixes. * docs fix * Update api/napi/__test__/resources/error.slint Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update api/napi/__test__/resources/test.slint Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix test --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
61 lines
1.2 KiB
JavaScript
Executable file
61 lines
1.2 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import * as slint from "slint-ui";
|
|
|
|
let demo = slint.loadFile("../ui/todo.slint");
|
|
let app = new demo.MainWindow();
|
|
|
|
let model = new slint.ArrayModel([
|
|
{
|
|
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: true
|
|
},
|
|
{
|
|
title: "Test the application",
|
|
checked: false
|
|
},
|
|
{
|
|
title: "Ship to customer",
|
|
checked: false
|
|
},
|
|
{
|
|
title: "???",
|
|
checked: false
|
|
},
|
|
{
|
|
title: "Profit",
|
|
checked: false
|
|
},
|
|
]);
|
|
app.todo_model = model;
|
|
|
|
app.todo_added.setHandler(function (text) {
|
|
model.push({ title: text, checked: false })
|
|
})
|
|
|
|
app.remove_done.setHandler(function () {
|
|
let offset = 0;
|
|
const length = model.length;
|
|
for (let i = 0; i < length; ++i) {
|
|
if (model.rowData(i - offset).checked) {
|
|
model.remove(i - offset, 1);
|
|
offset++;
|
|
}
|
|
}
|
|
})
|
|
|
|
app.run();
|