mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 01:33:19 +00:00
Add new 'Add task/event' bar directly in the main view
This commit is contained in:
parent
534da46a26
commit
2aa039e5fc
18 changed files with 399 additions and 51 deletions
|
@ -1,6 +1,42 @@
|
|||
import { Date, Time } from "std-widgets.slint";
|
||||
|
||||
export struct NewTaskData {
|
||||
sourceId: int,
|
||||
eventId: int,
|
||||
title: string,
|
||||
scheduled: bool,
|
||||
date: Date
|
||||
}
|
||||
|
||||
export struct SaveTaskData {
|
||||
sourceId: int,
|
||||
id: int,
|
||||
title: string,
|
||||
scheduled: bool,
|
||||
date: Date,
|
||||
}
|
||||
|
||||
export struct NewEventParams {
|
||||
sourceId: int,
|
||||
title: string,
|
||||
date: Date,
|
||||
startsAt: Time,
|
||||
endsAt: Time
|
||||
}
|
||||
|
||||
export struct SaveEventParams {
|
||||
sourceId: int,
|
||||
id: int,
|
||||
title: string,
|
||||
date: Date,
|
||||
startsAt: Time,
|
||||
endsAt: Time
|
||||
}
|
||||
|
||||
export struct Source {
|
||||
name: string,
|
||||
selected: bool
|
||||
}
|
||||
|
||||
export struct TaskData {
|
||||
sourceId: int,
|
||||
|
@ -36,7 +72,9 @@ struct OpenNewTaskFormParams {
|
|||
}
|
||||
|
||||
export global Backend {
|
||||
in-out property<[Source]> sources-selected;
|
||||
in-out property<[string]> sources;
|
||||
in-out property<bool> no-source-selected;
|
||||
in-out property<[string]> tags;
|
||||
in-out property<[Day]> visible_tasks;
|
||||
in-out property<[TaskData]> unscheduled-tasks;
|
||||
|
@ -53,5 +91,10 @@ export global Backend {
|
|||
callback delete_task_clicked(int, int);
|
||||
callback delete_event_clicked(int, int);
|
||||
|
||||
callback createTask(NewTaskData);
|
||||
callback saveTask(SaveTaskData);
|
||||
callback createEvent(NewEventParams);
|
||||
callback saveEvent(SaveEventParams);
|
||||
|
||||
pure callback formatDate(Date) -> string;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ export component EventGroup {
|
|||
VText {
|
||||
text: Utils.timeToString(event.endsAt);
|
||||
color: Palette.accent;
|
||||
font-size: 0.8rem;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { Backend, TaskData } from "Backend.slint";
|
||||
import { Button, VerticalBox, CheckBox, ScrollView } from "std-widgets.slint";
|
||||
import { Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
|
||||
import { SideBar } from "SideBar.slint";
|
||||
import { TaskLine } from "TaskLine.slint";
|
||||
import { EventGroup } from "EventGroup.slint";
|
||||
import { VPopupIconMenu, VCheckBox, VButton, VTag, VText, Palette } from "@vynui";
|
||||
import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Palette } from "@vynui";
|
||||
import { NewTaskData, SaveTaskData } from "Backend.slint";
|
||||
|
||||
export component MainView inherits Rectangle {
|
||||
|
||||
|
@ -37,6 +38,7 @@ export component MainView inherits Rectangle {
|
|||
icon-source: @image-url("./images/add.png");
|
||||
icon-colorize: Colors.greenyellow;
|
||||
}
|
||||
|
||||
VButton {
|
||||
text: "New event";
|
||||
clicked => { Backend.open_new_event_form() }
|
||||
|
@ -58,6 +60,95 @@ export component MainView inherits Rectangle {
|
|||
background: Palette.background.brighter(0.2);
|
||||
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: 500ms;
|
||||
}
|
||||
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: 500ms;
|
||||
}
|
||||
|
||||
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 task";
|
||||
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 = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flickable {
|
||||
horizontal-stretch: 1;
|
||||
VerticalLayout {
|
||||
|
|
|
@ -3,6 +3,7 @@ import { ToggleButton, VText, Palette } from "@vynui";
|
|||
|
||||
export component SideBar inherits Rectangle {
|
||||
background: Palette.pane;
|
||||
|
||||
VerticalLayout {
|
||||
alignment: start;
|
||||
padding: 16px;
|
||||
|
@ -13,9 +14,16 @@ export component SideBar inherits Rectangle {
|
|||
}
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
for item[index] in Backend.sources: ToggleButton {
|
||||
text: item;
|
||||
ToggleButton {
|
||||
text: "All";
|
||||
text-alignment: left;
|
||||
active: Backend.no-source-selected;
|
||||
clicked => { Backend.source_clicked(-1) }
|
||||
}
|
||||
for item[index] in Backend.sources-selected: ToggleButton {
|
||||
text: item.name;
|
||||
text-alignment: left;
|
||||
active: item.selected;
|
||||
clicked => { Backend.source_clicked(index) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Date, Time, ComboBox } from "std-widgets.slint";
|
|||
import { VTimePicker, VDatePicker, VButton, VTextInput, VText, Palette } from "@vynui";
|
||||
import { Backend } from "../Backend.slint";
|
||||
|
||||
export struct NewEventParams {
|
||||
struct NewEventParams {
|
||||
sourceId: int,
|
||||
title: string,
|
||||
date: Date,
|
||||
|
@ -10,7 +10,7 @@ export struct NewEventParams {
|
|||
endsAt: Time
|
||||
}
|
||||
|
||||
export struct SaveEventParams {
|
||||
struct SaveEventParams {
|
||||
sourceId: int,
|
||||
id: int,
|
||||
title: string,
|
||||
|
@ -51,15 +51,15 @@ export component EventWindow inherits Window {
|
|||
enabled: eventId == -1;
|
||||
}
|
||||
|
||||
taskDateInput := VDatePicker {
|
||||
label: "Date";
|
||||
}
|
||||
|
||||
taskTitleInput := VTextInput {
|
||||
label: "Title";
|
||||
wrap: word-wrap;
|
||||
}
|
||||
|
||||
taskDateInput := VDatePicker {
|
||||
label: "Date";
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
eventStartTimeInput := VTimePicker {
|
||||
|
@ -71,7 +71,6 @@ export component EventWindow inherits Window {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
VButton {
|
||||
text: eventId == -1 ? "Create" : "Save";
|
||||
clicked => {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Date, ComboBox } from "std-widgets.slint";
|
|||
import { VTextInput, VButton, VDatePicker, VText, VCheckBox, Palette } from "@vynui";
|
||||
import { Backend } from "../Backend.slint";
|
||||
|
||||
export struct NewTaskData {
|
||||
struct NewTaskData {
|
||||
sourceId: int,
|
||||
eventId: int,
|
||||
title: string,
|
||||
|
@ -10,7 +10,7 @@ export struct NewTaskData {
|
|||
date: Date
|
||||
}
|
||||
|
||||
export struct SaveTaskData {
|
||||
struct SaveTaskData {
|
||||
sourceId: int,
|
||||
id: int,
|
||||
title: string,
|
||||
|
@ -50,12 +50,6 @@ export component TaskWindow inherits Window {
|
|||
enabled: taskId == -1 && eventId == -1;
|
||||
}
|
||||
|
||||
taskTitleInput := VTextInput {
|
||||
label: "Content";
|
||||
wrap: word-wrap;
|
||||
accepted => { button.clicked() }
|
||||
}
|
||||
|
||||
scheduledInput := VCheckBox {
|
||||
text: "Scheduled";
|
||||
}
|
||||
|
@ -65,6 +59,12 @@ export component TaskWindow inherits Window {
|
|||
enabled: eventId == -1 && scheduledInput.checked;
|
||||
}
|
||||
|
||||
taskTitleInput := VTextInput {
|
||||
label: "Content";
|
||||
wrap: word-wrap;
|
||||
accepted => { button.clicked() }
|
||||
}
|
||||
|
||||
button := VButton {
|
||||
text: taskId == -1 ? "Create" : "Save";
|
||||
clicked => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue