mirai/ui/components/TaskEdit.slint

59 lines
1.4 KiB
Text

import { Backend, TaskData } from "../Backend.slint";
import { Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Svg, Palette } from "@selenite";
import { NewTaskData, SaveTaskData } from "../Backend.slint";
export component TaskEdit inherits VerticalLayout {
in-out property <SaveTaskData> task;
out property <bool> should-show;
public function show(task: SaveTaskData) {
root.task = task;
should-show = true;
}
public function close() {
should-show = false;
}
callback accepted(SaveTaskData);
if !should-show : Rectangle {}
if should-show : Rectangle {
function modify() {
root.accepted({
id: task.id,
sourceId: task.sourceId,
title: newTaskTitleInput.text,
scheduled: taskDateInput.date.year != 0,
date: taskDateInput.date
});
}
background: Palette.background;
border-radius: 8px;
VerticalLayout {
padding: 16px;
spacing: 8px;
newTaskTitleInput := VTextInput {
text: root.task.title;
accepted => { modify() }
}
HorizontalLayout {
alignment: start;
spacing: 8px;
taskDateInput := VDatePicker {
date: task.date;
enabled: true;
}
VButton {
text: "Modify";
icon-svg: Svg.correct;
icon-colorize: greenyellow;
clicked => { modify() }
}
}
}
}
}