Refactor the whole structure, no more separation for C++ and Slint files

This commit is contained in:
Vyn 2024-11-04 14:45:27 +01:00
parent d6c781faa2
commit 893fcc11e3
35 changed files with 920 additions and 518 deletions

View file

@ -0,0 +1,123 @@
import { AppWindowModels } from "../windows/AppWindow/Models.slint";
import { Date, Time, Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VActionButton, VTag, VText, Svg, VTextInput, Palette } from "@selenite";
export struct CreateTaskData {
sourceId: int,
title: string,
date: Date
}
export struct CreateEventData {
sourceId: int,
title: string,
date: Date,
startsAt: Time,
endsAt: Time
}
export component CreateTaskOrEvent inherits Rectangle {
in property <[string]> sources;
private property <int> task-or-event: 1;
callback create-task(CreateTaskData);
callback create-event(CreateEventData);
function accepted() {
if (task-or-event == 1) {
root.create-task({
sourceId: AppWindowModels.get-source-id-from-name(sourceInput.current-value),
title: newTaskTitleInput.text,
date: taskDateInput.date
})
} else {
root.create-event({
sourceId: AppWindowModels.get-source-id-from-name(sourceInput.current-value),
title: newTaskTitleInput.text,
date: taskDateInput.date,
startsAt: eventStartTimeInput.time,
endsAt: eventEndTimeInput.time
})
}
newTaskTitleInput.edit-text("");
}
Rectangle {
border-color: newTaskTitleInput.text != "" ? Palette.card-background : transparent;
border-width: newTaskTitleInput.text != "" ? 4px : 0px;
border-radius: newTaskTitleInput.text != "" ? 8px : 0px;
animate border-color, border-width {
duration: 250ms;
}
VerticalLayout {
spacing: 8px;
padding: newTaskTitleInput.text != "" ? 16px : 0px;
animate padding {
duration: 250ms;
}
newTaskTitleInput := VTextInput {
placeholder: "Add new Task / Event";
started-writting() => {
sourceInput.current-index = AppWindowModels.default-source-index;
}
accepted => { accepted() }
}
Rectangle {
min-height: 0px;
max-height: newTaskTitleInput.text != "" ? 512px : 0px;
opacity: newTaskTitleInput.text != "" ? 1 : 0;
clip: true;
animate max-height, opacity {
duration: 250ms;
}
HorizontalLayout {
alignment: start;
spacing: 8px;
VerticalLayout {
alignment: end;
VButton {
text: task-or-event == 1 ? "Task" : "Event";
clicked => { task-or-event = task-or-event == 1 ? 0 : 1 }
}
}
VText { text: "for"; vertical-alignment: bottom;}
VerticalLayout {
alignment: end;
sourceInput := ComboBox {
model: root.sources;
}
}
VText { text: "on"; vertical-alignment: bottom;}
taskDateInput := VDatePicker {
enabled: true;
}
Rectangle {
min-width: 0;
max-width: task-or-event == 0 ? 9999px : 0px;
opacity: task-or-event == 0 ? 1 : 0;
clip: true;
animate max-width, opacity {
duration: 250ms;
}
HorizontalLayout {
spacing: 4px;
VText { text: "between"; vertical-alignment: bottom; }
eventStartTimeInput := VTimePicker { }
VText { text: "and"; vertical-alignment: bottom; }
eventEndTimeInput := VTimePicker { }
}
}
VButton {
text: "Create";
icon-svg: Svg.correct;
icon-colorize: greenyellow;
clicked => { accepted() }
}
}
}
}
}
}