From f8ff4eb3c4313b518945bbeadfd5d34d4ed7a630 Mon Sep 17 00:00:00 2001 From: Vyn Date: Wed, 18 Jun 2025 13:54:33 +0200 Subject: [PATCH] Fix tasks view resizing for no reason + Wrap text correctly --- external/selenite | 2 +- src/components/CreateTaskOrEvent.slint | 2 +- src/windows/AppWindow/AppWindow.slint | 7 +- .../AppWindow/views/CalendarView.slint | 10 +- src/windows/AppWindow/views/TasksView.slint | 296 ++++++++---------- 5 files changed, 141 insertions(+), 176 deletions(-) diff --git a/external/selenite b/external/selenite index b549a6a..acbd562 160000 --- a/external/selenite +++ b/external/selenite @@ -1 +1 @@ -Subproject commit b549a6a47c543ca83d7d37027e55ecd782781e11 +Subproject commit acbd56205d758bf74d7f121ce8085898acbacc9f diff --git a/src/components/CreateTaskOrEvent.slint b/src/components/CreateTaskOrEvent.slint index 996b74f..ac3d77b 100644 --- a/src/components/CreateTaskOrEvent.slint +++ b/src/components/CreateTaskOrEvent.slint @@ -37,7 +37,7 @@ export component CreateTaskOrEvent inherits Rectangle { duration: 250ms; } newTaskTitleInput := VTextInput { - placeholder: "Add new Task / Event"; + placeholder: "Enter new task"; started-writting() => { sourceInput.current-index = AppWindowModels.default-source-index; } diff --git a/src/windows/AppWindow/AppWindow.slint b/src/windows/AppWindow/AppWindow.slint index 042113f..e268388 100644 --- a/src/windows/AppWindow/AppWindow.slint +++ b/src/windows/AppWindow/AppWindow.slint @@ -12,15 +12,15 @@ import { VButton } from "../../../external/selenite/components/Button.slint"; export component AppWindow inherits Window { title: "Mirai"; - min-height: 100px; - max-height: 4000px; // needed, otherwise the window wants to fit the content (on Swaywm) + //min-height: 100px; + //max-height: 4000px; // needed, otherwise the window wants to fit the content (on Swaywm) background: Palette.pane; private property show-tasks: false; HorizontalLayout { VerticalLayout { - HorizontalLayout { + VerticalLayout { padding: 16px; alignment: LayoutAlignment.stretch; spacing: 8px; @@ -37,6 +37,7 @@ export component AppWindow inherits Window { SideBar {} } VerticalLayout { + if show-tasks : MainView { horizontal-stretch: 1; diff --git a/src/windows/AppWindow/views/CalendarView.slint b/src/windows/AppWindow/views/CalendarView.slint index 716a764..a4d5487 100644 --- a/src/windows/AppWindow/views/CalendarView.slint +++ b/src/windows/AppWindow/views/CalendarView.slint @@ -64,12 +64,11 @@ export component CalendarView inherits Rectangle { } } - - VerticalLayout { + padding: 16px; + spacing: 16px; HorizontalLayout { alignment: start; - padding: 16px; VButton { text: "New event"; icon-svg: Svg.plus; @@ -79,6 +78,11 @@ export component CalendarView inherits Rectangle { } } } + Rectangle { + horizontal-stretch: 1; + background: Palette.background.brighter(0.2); + height: 1px; + } Calendar { delete-event-request(source-id, event-id) => { debug("DEELTE", source-id);AppWindowActions.delete-event(source-id, event-id) } init => { debug("cal len", AppWindowModels.calendar.length) } diff --git a/src/windows/AppWindow/views/TasksView.slint b/src/windows/AppWindow/views/TasksView.slint index b31163e..3c1c80e 100644 --- a/src/windows/AppWindow/views/TasksView.slint +++ b/src/windows/AppWindow/views/TasksView.slint @@ -15,187 +15,148 @@ export component MainView inherits Rectangle { private property icon-not-visible: Svg.not-visible; private property completed-tasks-visible: false; - HorizontalLayout { - - VerticalLayout { + VerticalLayout { + padding: 16px; + spacing: 16px; + HorizontalLayout { + alignment: start; + spacing: 8px; + VButton { + text: "Show/Hide completed tasks"; + clicked => { + AppWindowActions.toggle-show-completed-tasks(); + completed-tasks-visible = !completed-tasks-visible; + } + icon-svg: completed-tasks-visible ? icon-visible : icon-not-visible; + icon-colorize: Palette.control-foreground; + } + } + Rectangle { horizontal-stretch: 1; - padding: 16px; - spacing: 16px; - HorizontalLayout { - horizontal-stretch: 1; - alignment: start; - spacing: 8px; - VButton { - text: "Show/Hide completed tasks"; - clicked => { - AppWindowActions.toggle-show-completed-tasks(); - completed-tasks-visible = !completed-tasks-visible; - } - icon-svg: completed-tasks-visible ? icon-visible : icon-not-visible; - icon-colorize: Palette.control-foreground; - } - } - Rectangle { - horizontal-stretch: 1; - background: Palette.background.brighter(0.2); - height: 1px; - } + background: Palette.background.brighter(0.2); + height: 1px; + } - CreateTaskOrEvent { - sources: AppWindowModels.sources; - create-task(data) => { - AppWindowActions.create-task({ - sourceId: data.sourceId, - eventId: -1, - title: data.title, - scheduled: data.date.year != 0, - date: data.date - }) - } + CreateTaskOrEvent { + sources: AppWindowModels.sources; + create-task(data) => { + AppWindowActions.create-task({ + sourceId: data.sourceId, + eventId: -1, + title: data.title, + scheduled: data.date.year != 0, + date: data.date + }) } - - Flickable { - horizontal-stretch: 1; - VerticalLayout { - alignment: start; - spacing: 16px; - if AppWindowModels.days.length == 0 && AppWindowModels.unscheduled-tasks.length == 0 : VText { - text: "There is no task to show"; - horizontal-alignment: center; - vertical-alignment: center; - } - for day[dayIndex] in AppWindowModels.days: VerticalLayout { - Rectangle { + } + + Flickable { + max-width: 9999px; // The window keeps resizing down if we don't set the max width + horizontal-stretch: 1; + VerticalLayout { + alignment: start; + if AppWindowModels.days.length == 0 && AppWindowModels.unscheduled-tasks.length == 0 : VText { + text: "There is no task to show"; + horizontal-alignment: center; + vertical-alignment: center; + } + for day[dayIndex] in AppWindowModels.days: VerticalLayout { + spacing: day.tasks.length > 0 ? 16px : 0px; + if day.tasks.length > 0 : Rectangle { + + if dayIndex != 0 : Rectangle { + height: 1px; background: Palette.card-background; - border-radius: 8px; - VerticalLayout { - padding: 16px; - HorizontalLayout { - alignment: start; + } + //background: Palette.card-background; + border-radius: 8px; + VerticalLayout { + HorizontalLayout { + alignment: start; + VText { + text: Utils.format-date(day.date); + color: day.isLate ? Palette.orange : Palette.foreground; + font-size: 1.2rem; + } + VerticalLayout { + alignment: center; VText { - text: Utils.format-date(day.date); - color: day.isLate ? Palette.orange : Palette.foreground; - font-size: 1.2rem; - } - VerticalLayout { - alignment: center; - VText { - text: day.relativeDaysDiff == 0 ? " - today" : - day.relativeDaysDiff == 1 ? " - tomorrow" : - day.relativeDaysDiff == -1 ? " - yesterday" : - day.relativeDaysDiff > 0 ? " - in \{day.relativeDaysDiff} days" : - " - \{-day.relativeDaysDiff} days ago"; - color: Palette.foreground-hint; - font-size: 1rem; - } + text: day.relativeDaysDiff == 0 ? " - today" : + day.relativeDaysDiff == 1 ? " - tomorrow" : + day.relativeDaysDiff == -1 ? " - yesterday" : + day.relativeDaysDiff > 0 ? " - in \{day.relativeDaysDiff} days" : + " - \{-day.relativeDaysDiff} days ago"; + color: Palette.foreground-hint; + font-size: 1rem; } } - for event[eventIndex] in day.events: VerticalLayout { - padding-top: 16px; - EventGroup { - event: event; - add-task(data) => { - AppWindowActions.create-task({ - sourceId: event.sourceId, - eventId: event.id, - title: data.title, - }); - } - edit-task(taskId, data) => { - AppWindowActions.save-task({ - id: taskId, - sourceId: event.sourceId, - title: data.title, - }); - } - delete-task(taskId) => { - AppWindowActions.delete-task-clicked(event.sourceId, taskId) - } - toggle-check-task(taskId) => { - AppWindowActions.task-clicked(event.sourceId, taskId); - } - delete => { - //AppWindowActions.delete-event-clicked(event.sourceId, event.id) - } - edit(data) => { - //AppWindowActions.save-event({ - //sourceId: event.sourceId, - //id: event.id, - //title: data.title, - ////date: event.date, - //startsAt: event.startsAt, - //endsAt: event.endsAt, - //}); - } + } + + for task[taskIndex] in day.tasks: VerticalLayout { + padding-top: taskIndex == 0 ? 16px : 0px; + padding-bottom: 8px; + TaskLine { + title: task.title; + source-name: AppWindowModels.get-source-name-from-id(task.sourceId); + scheduled: task.date.year != 0; + date: day.date; + checked: task.checked; + allow-edit-date: true; + delete => { + AppWindowActions.delete-task-clicked(task.sourceId, task.id) } - } - for task[taskIndex] in day.tasks: VerticalLayout { - padding-top: taskIndex == 0 ? 16px : 0px; - padding-bottom: 8px; - TaskLine { - title: task.title; - source-name: AppWindowModels.get-source-name-from-id(task.sourceId); - scheduled: task.date.year != 0; - date: day.date; - checked: task.checked; - allow-edit-date: true; - delete => { - AppWindowActions.delete-task-clicked(task.sourceId, task.id) - } - toggle-check => { - AppWindowActions.task-clicked(task.sourceId, task.id); - } - edited(data) => { - AppWindowActions.save-task({ - id: task.id, - sourceId: task.sourceId, - title: data.title, - scheduled: data.scheduled, - date: data.date - }) - } + toggle-check => { + AppWindowActions.task-clicked(task.sourceId, task.id); + } + edited(data) => { + AppWindowActions.save-task({ + id: task.id, + sourceId: task.sourceId, + title: data.title, + scheduled: data.scheduled, + date: data.date + }) } } } } } - if AppWindowModels.unscheduled-tasks.length > 0 : VerticalLayout { - Rectangle { - background: Palette.card-background; - border-radius: 8px; - VerticalLayout { - padding: 16px; - HorizontalLayout { - alignment: start; - VText { - text: "Unscheduled"; - color: Palette.foreground; - font-size: 1.2rem; - } + } + if AppWindowModels.unscheduled-tasks.length > 0 : VerticalLayout { + Rectangle { + //background: Palette.card-background; + border-radius: 8px; + VerticalLayout { + HorizontalLayout { + alignment: start; + VText { + text: "Unscheduled"; + color: Palette.foreground; + font-size: 1.2rem; } - for task[taskIndex] in AppWindowModels.unscheduled-tasks: VerticalLayout { - padding-top: taskIndex == 0 ? 16px : 0px; - padding-bottom: 8px; - TaskLine { - title: task.title; - source-name: AppWindowModels.get-source-name-from-id(task.sourceId); - checked: task.checked; - allow-edit-date: true; - delete => { - AppWindowActions.delete-task-clicked(task.sourceId, task.id) - } - toggle-check => { - AppWindowActions.task-clicked(task.sourceId, task.id); - } - edited(data) => { - AppWindowActions.save-task({ - id: task.id, - sourceId: task.sourceId, - title: data.title, - scheduled: data.scheduled, - date: data.date - }) - } + } + for task[taskIndex] in AppWindowModels.unscheduled-tasks: VerticalLayout { + padding-top: taskIndex == 0 ? 16px : 0px; + padding-bottom: 8px; + TaskLine { + title: task.title; + source-name: AppWindowModels.get-source-name-from-id(task.sourceId); + checked: task.checked; + allow-edit-date: true; + delete => { + AppWindowActions.delete-task-clicked(task.sourceId, task.id) + } + toggle-check => { + AppWindowActions.task-clicked(task.sourceId, task.id); + } + edited(data) => { + AppWindowActions.save-task({ + id: task.id, + sourceId: task.sourceId, + title: data.title, + scheduled: data.scheduled, + date: data.date + }) } } } @@ -205,5 +166,4 @@ export component MainView inherits Rectangle { } } } - }