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 task; in property date; in property event-index: -1; in property source-index: -1; in property task-index: -1; private property popup-x: 200px; private property 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; } } } } }