mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-02 01:13:19 +00:00
100 lines
2.1 KiB
Text
100 lines
2.1 KiB
Text
import { Backend, TaskData } from "../Backend.slint";
|
|
import { ToggleButton } from "@selenite";
|
|
import { VPopupIconMenu, VTag, VButton, VActionButton, VCheckBox, Svg, Palette } from "@selenite";
|
|
import { TaskEdit } from "./TaskEdit.slint";
|
|
import { Date } from "std-widgets.slint";
|
|
|
|
export component TaskLine inherits VerticalLayout {
|
|
in property<TaskData> task;
|
|
in property<Date> date;
|
|
in property<int> event-index: -1;
|
|
in property<int> source-index: -1;
|
|
in property<int> task-index: -1;
|
|
|
|
private property<length> popup-x: 200px;
|
|
private property<length> popup-y: 200px;
|
|
|
|
init => {
|
|
if (task-index == -1) {
|
|
debug("Error: missing task-index")
|
|
}
|
|
}
|
|
|
|
taskEdit := TaskEdit {
|
|
accepted(task) => {
|
|
Backend.save-task({
|
|
id: task.id,
|
|
sourceId: task.sourceId,
|
|
title: task.title,
|
|
scheduled: task.date.year != 0,
|
|
date: task.date
|
|
});
|
|
taskEdit.close();
|
|
}
|
|
}
|
|
|
|
if !taskEdit.should-show : Rectangle {
|
|
popup := VPopupIconMenu {
|
|
VActionButton {
|
|
icon-svg: Svg.pen;
|
|
icon-colorize: Colors.grey;
|
|
icon-size: 1.5rem;
|
|
border-radius: 0;
|
|
clicked => {
|
|
taskEdit.show({
|
|
sourceId: task.sourceId,
|
|
id: task.id,
|
|
title: task.title,
|
|
scheduled: root.date.year != 0,
|
|
date: date,
|
|
});
|
|
}
|
|
}
|
|
|
|
VActionButton {
|
|
icon-svg: Svg.trash;
|
|
icon-colorize: Colors.pink;
|
|
icon-size: 1.5rem;
|
|
border-radius: 0;
|
|
clicked => {
|
|
Backend.delete-task-clicked(source-index, task-index)
|
|
}
|
|
}
|
|
}
|
|
|
|
ta := TouchArea {
|
|
clicked => {
|
|
checkbox.checked = !checkbox.checked;
|
|
Backend.task-clicked(source-index, task-index);
|
|
}
|
|
pointer-event(e) => {
|
|
if (e.button == PointerEventButton.right && e.kind == PointerEventKind.up) {
|
|
popup.show(ta.mouse-x, ta.mouse-y);
|
|
}
|
|
}
|
|
z: 10;
|
|
}
|
|
|
|
HorizontalLayout {
|
|
alignment: space-between;
|
|
HorizontalLayout {
|
|
alignment: start;
|
|
spacing: 8px;
|
|
checkbox := VCheckBox {
|
|
text: task.title;
|
|
checked: task.checked;
|
|
toggled => {
|
|
Backend.task-clicked(source-index, task-index)
|
|
}
|
|
}
|
|
for tag[tag-index] in task.tags: VTag {
|
|
text: tag;
|
|
size: 0.8rem;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|