mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 01:33:19 +00:00
Rework mirai core
This commit is contained in:
parent
f885d355cd
commit
36a2fe9220
62 changed files with 27689 additions and 765 deletions
|
@ -5,6 +5,7 @@ import { TaskLine } from "TaskLine.slint";
|
|||
import { EventGroup } from "EventGroup.slint";
|
||||
import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Palette } from "@vynui";
|
||||
import { NewTaskData, SaveTaskData } from "Backend.slint";
|
||||
import { CreateTaskOrEvent } from "components/CreateTaskOrEvent.slint";
|
||||
|
||||
export component MainView inherits Rectangle {
|
||||
|
||||
|
@ -61,92 +62,8 @@ export component MainView inherits Rectangle {
|
|||
height: 1px;
|
||||
}
|
||||
|
||||
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 {
|
||||
in-out property <int> task-or-event: 1;
|
||||
spacing: 8px;
|
||||
padding: newTaskTitleInput.text != "" ? 16px : 0px;
|
||||
animate padding {
|
||||
duration: 250ms;
|
||||
}
|
||||
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: Backend.sources;
|
||||
}
|
||||
}
|
||||
VText { text: "on"; vertical-alignment: bottom;}
|
||||
taskDateInput := VDatePicker {
|
||||
label: "Date";
|
||||
enabled: true;
|
||||
}
|
||||
HorizontalLayout {
|
||||
visible: task-or-event == 0;
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
VText { text: "between"; vertical-alignment: bottom; }
|
||||
eventStartTimeInput := VTimePicker {
|
||||
label: "Starts at";
|
||||
}
|
||||
VText { text: "and"; vertical-alignment: bottom; }
|
||||
eventEndTimeInput := VTimePicker {
|
||||
label: "Ends at";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
newTaskTitleInput := VTextInput {
|
||||
placeholder: "Add new Task / Event";
|
||||
accepted => {
|
||||
if (task-or-event == 1) {
|
||||
Backend.createTask({
|
||||
sourceId: sourceInput.current-index,
|
||||
eventId: -1,
|
||||
title: newTaskTitleInput.text,
|
||||
scheduled: taskDateInput.date.year != 0,
|
||||
date: taskDateInput.date
|
||||
})
|
||||
} else {
|
||||
Backend.createEvent({
|
||||
sourceId: sourceInput.current-index,
|
||||
title: newTaskTitleInput.text,
|
||||
date: taskDateInput.date,
|
||||
startsAt: eventStartTimeInput.time,
|
||||
endsAt: eventEndTimeInput.time,
|
||||
});
|
||||
}
|
||||
newTaskTitleInput.text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
CreateTaskOrEvent {
|
||||
|
||||
}
|
||||
|
||||
Flickable {
|
||||
|
@ -195,6 +112,7 @@ export component MainView inherits Rectangle {
|
|||
padding-bottom: 8px;
|
||||
TaskLine {
|
||||
task: task;
|
||||
date: day.date;
|
||||
source-index: task.sourceId;
|
||||
task-index: task.id;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
import { Backend, TaskData } from "Backend.slint";
|
||||
import { ToggleButton } from "@vynui";
|
||||
import { VPopupIconMenu, VTag, VButton, VCheckBox, Palette } from "@vynui";
|
||||
import { TaskEdit } from "components/TaskEdit.slint";
|
||||
import { Date } from "std-widgets.slint";
|
||||
|
||||
export component TaskLine {
|
||||
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;
|
||||
|
||||
|
@ -16,72 +20,81 @@ export component TaskLine {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
popup := VPopupIconMenu {
|
||||
VButton {
|
||||
icon-source: @image-url("./images/edit.png");
|
||||
icon-colorize: Colors.grey;
|
||||
icon-size: 1.5rem;
|
||||
border-radius: 0;
|
||||
clicked => { Backend.open_edit_task_form(source-index, task-index) }
|
||||
}
|
||||
|
||||
VButton {
|
||||
icon-source: @image-url("./images/delete.png");
|
||||
icon-colorize: Colors.pink;
|
||||
icon-size: 1.5rem;
|
||||
border-radius: 0;
|
||||
clicked => { Backend.delete_task_clicked(source-index, task-index) }
|
||||
taskEdit := TaskEdit {
|
||||
accepted(task) => {
|
||||
Backend.saveTask({
|
||||
id: task.id,
|
||||
sourceId: task.sourceId,
|
||||
title: task.title,
|
||||
scheduled: task.date.year != 0,
|
||||
date: task.date
|
||||
});
|
||||
taskEdit.close();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
alignment: end;
|
||||
spacing: 8px;
|
||||
// Not needed anymore, to remove later
|
||||
/*VButton {
|
||||
if !taskEdit.should-show : Rectangle {
|
||||
popup := VPopupIconMenu {
|
||||
VButton {
|
||||
icon-source: @image-url("./images/edit.png");
|
||||
icon-colorize: Colors.grey;
|
||||
clicked => { Backend.open_edit_task_form(source-index, task-index) }
|
||||
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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
VButton {
|
||||
icon-source: @image-url("./images/delete.png");
|
||||
icon-colorize: Colors.pink;
|
||||
clicked => { Backend.delete_task_clicked(source-index, task-index) }
|
||||
}*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
95
ui/components/CreateTaskOrEvent.slint
Normal file
95
ui/components/CreateTaskOrEvent.slint
Normal file
|
@ -0,0 +1,95 @@
|
|||
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, Palette } from "@vynui";
|
||||
import { NewTaskData, SaveTaskData } from "../Backend.slint";
|
||||
|
||||
export component CreateTaskOrEvent inherits Rectangle {
|
||||
|
||||
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 {
|
||||
in-out property <int> task-or-event: 1;
|
||||
spacing: 8px;
|
||||
padding: newTaskTitleInput.text != "" ? 16px : 0px;
|
||||
animate padding {
|
||||
duration: 250ms;
|
||||
}
|
||||
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: Backend.sources;
|
||||
}
|
||||
}
|
||||
VText { text: "on"; vertical-alignment: bottom;}
|
||||
taskDateInput := VDatePicker {
|
||||
label: "Date";
|
||||
enabled: true;
|
||||
}
|
||||
HorizontalLayout {
|
||||
visible: task-or-event == 0;
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
VText { text: "between"; vertical-alignment: bottom; }
|
||||
eventStartTimeInput := VTimePicker {
|
||||
label: "Starts at";
|
||||
}
|
||||
VText { text: "and"; vertical-alignment: bottom; }
|
||||
eventEndTimeInput := VTimePicker {
|
||||
label: "Ends at";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
newTaskTitleInput := VTextInput {
|
||||
placeholder: "Add new Task / Event";
|
||||
accepted => {
|
||||
if (task-or-event == 1) {
|
||||
Backend.createTask({
|
||||
sourceId: sourceInput.current-index,
|
||||
eventId: -1,
|
||||
title: newTaskTitleInput.text,
|
||||
scheduled: taskDateInput.date.year != 0,
|
||||
date: taskDateInput.date
|
||||
})
|
||||
} else {
|
||||
Backend.createEvent({
|
||||
sourceId: sourceInput.current-index,
|
||||
title: newTaskTitleInput.text,
|
||||
date: taskDateInput.date,
|
||||
startsAt: eventStartTimeInput.time,
|
||||
endsAt: eventEndTimeInput.time,
|
||||
});
|
||||
}
|
||||
newTaskTitleInput.text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
51
ui/components/TaskEdit.slint
Normal file
51
ui/components/TaskEdit.slint
Normal file
|
@ -0,0 +1,51 @@
|
|||
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, Palette } from "@vynui";
|
||||
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 {
|
||||
background: Palette.background;
|
||||
border-radius: 8px;
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
|
||||
newTaskTitleInput := VTextInput {
|
||||
text: root.task.title;
|
||||
accepted => {
|
||||
root.accepted({
|
||||
id: task.id,
|
||||
sourceId: task.sourceId,
|
||||
title: newTaskTitleInput.text,
|
||||
scheduled: taskDateInput.date.year != 0,
|
||||
date: taskDateInput.date
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
alignment: start;
|
||||
spacing: 8px;
|
||||
taskDateInput := VDatePicker {
|
||||
date: task.date;
|
||||
enabled: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue