mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-04 18:53:19 +00:00
Move Calendar to its own view
This commit is contained in:
parent
a03e71890c
commit
d26f2f5a9f
19 changed files with 407 additions and 137 deletions
|
@ -3,6 +3,8 @@ import { VCheckBox, VButton, VActionButton, Svg, VTag, VPopupIconMenu, VText, Pa
|
|||
import { Utils } from "../shared/Utils.slint";
|
||||
|
||||
export struct CalendarDayEvent {
|
||||
sourceId: int,
|
||||
id: int,
|
||||
title: string,
|
||||
startsAt: Time,
|
||||
endsAt: Time
|
||||
|
@ -28,7 +30,12 @@ export component Calendar inherits Rectangle {
|
|||
private property <length> available-day-space: self.height - header-height;
|
||||
private property <length> day-start-y: header-height;
|
||||
private property <length> hour-spacing: available-day-space / 24;
|
||||
background: Palette.pane;
|
||||
|
||||
private property <int> contextMenuEventSourceId: -1;
|
||||
|
||||
callback delete-event-request(source-id: int, event-id: int);
|
||||
|
||||
|
||||
|
||||
HorizontalLayout {
|
||||
Rectangle {
|
||||
|
@ -58,6 +65,7 @@ export component Calendar inherits Rectangle {
|
|||
|
||||
}
|
||||
Rectangle {
|
||||
min-width: 400px;
|
||||
//background: green;
|
||||
HorizontalLayout {
|
||||
for day[day-index] in root.days: Rectangle {
|
||||
|
@ -113,6 +121,40 @@ export component Calendar inherits Rectangle {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
eventActionsPopup := VPopupIconMenu {
|
||||
//VActionButton {
|
||||
//icon-svg: Svg.pen;
|
||||
//icon-colorize: Colors.grey;
|
||||
//icon-size: 1.5rem;
|
||||
//border-radius: 0;
|
||||
//clicked => {
|
||||
//taskEdit.show({
|
||||
//title: title,
|
||||
//date: date
|
||||
//});
|
||||
//}
|
||||
//}
|
||||
|
||||
VActionButton {
|
||||
icon-svg: Svg.trash;
|
||||
icon-colorize: Colors.pink;
|
||||
icon-size: 1.5rem;
|
||||
border-radius: 0;
|
||||
clicked => {
|
||||
delete-event-request(event.sourceId, event.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ta := TouchArea {
|
||||
pointer-event(e) => {
|
||||
if (e.button == PointerEventButton.right && e.kind == PointerEventKind.up) {
|
||||
debug(ta.mouse-x, " ", ta.mouse-y);
|
||||
eventActionsPopup.show(ta.mouse-x, ta.mouse-y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,38 +8,18 @@ export struct CreateTaskData {
|
|||
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
|
||||
})
|
||||
}
|
||||
root.create-task({
|
||||
sourceId: AppWindowModels.get-source-id-from-name(sourceInput.current-value),
|
||||
title: newTaskTitleInput.text,
|
||||
date: taskDateInput.date
|
||||
});
|
||||
newTaskTitleInput.edit-text("");
|
||||
}
|
||||
|
||||
|
@ -75,13 +55,6 @@ export component CreateTaskOrEvent inherits Rectangle {
|
|||
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;
|
||||
|
@ -94,22 +67,6 @@ export component CreateTaskOrEvent inherits Rectangle {
|
|||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue