Add scrollbar for tasks

This commit is contained in:
Vyn 2024-04-12 16:38:22 +02:00
parent 317b515e22
commit 6ef9740db9
2 changed files with 72 additions and 72 deletions

View file

@ -63,7 +63,6 @@ Rectangle {
Component.onCompleted: set(new Date()) // today Component.onCompleted: set(new Date()) // today
onClicked: { onClicked: {
const formattedDate = Qt.formatDate(date, 'yyyy-MM-dd') const formattedDate = Qt.formatDate(date, 'yyyy-MM-dd')
print('onClicked', formattedDate)
newTodoDate.text = formattedDate newTodoDate.text = formattedDate
datePicker.close() datePicker.close()
} }

View file

@ -10,89 +10,90 @@ import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import Mirai import Mirai
ColumnLayout { ScrollView {
id: scroll
clip: true
contentHeight: layout.height
QtObject { ColumnLayout {
id: internal id: layout
property string todayDate: Qt.formatDate(new Date(), 'yyyy-MM-dd') anchors.right: parent.right
property string tomorrowDate: Qt.formatDate(new Date(new Date().setDate(new Date().getDate() + 1)), 'yyyy-MM-dd') anchors.left: parent.left
} QtObject {
id: internal
property string todayDate: Qt.formatDate(new Date(), 'yyyy-MM-dd')
property string tomorrowDate: Qt.formatDate(new Date(new Date().setDate(new Date().getDate() + 1)), 'yyyy-MM-dd')
}
Repeater { Repeater {
model: backend.tasks model: backend.tasks
Rectangle { Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height Layout.preferredHeight: childrenRect.height
id: task id: task
required property var modelData required property var modelData
required property int index required property int index
color: "transparent" color: "transparent"
HoverHandler { HoverHandler {
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
}
ColumnLayout {
anchors.left: parent.left
anchors.right: parent.right
Component {
id: dateForTasks
AppText {
topPadding: 32
bottomPadding: 16
text: task.modelData.date === internal.todayDate ? "Today"
: task.modelData.date === internal.tomorrowDate ? "Tomorrow"
: task.modelData.date
color: task.modelData.date < internal.todayDate ? colorPalette.selected.palette.pink
// : task.modelData.date === internal.todayDate ? colorPalette.selected.palette.sapphire
: colorPalette.selected.text
font.pointSize: 24
}
}
Loader {
sourceComponent: task.modelData.shouldShowDate ? dateForTasks : undefined
} }
TaskItem {
id: taskItem
task: task.modelData
}
}
Menu { ColumnLayout {
id: contextMenu anchors.left: parent.left
MenuItem { anchors.right: parent.right
text: "Edit"
onClicked: { Component {
root.editTask(task.modelData, task.index) id: dateForTasks
AppText {
topPadding: 32
bottomPadding: 16
text: task.modelData.date === internal.todayDate ? "Today"
: task.modelData.date === internal.tomorrowDate ? "Tomorrow"
: task.modelData.date
color: task.modelData.date < internal.todayDate ? colorPalette.selected.palette.pink
// : task.modelData.date === internal.todayDate ? colorPalette.selected.palette.sapphire
: colorPalette.selected.text
font.pointSize: 24
}
}
Loader {
sourceComponent: task.modelData.shouldShowDate ? dateForTasks : undefined
}
TaskItem {
id: taskItem
task: task.modelData
} }
} }
MenuItem {
text: "Delete" Menu {
onClicked: { id: contextMenu
backend.removeTodo(task.index) MenuItem {
text: "Edit"
onClicked: {
root.editTask(task.modelData, task.index)
}
}
MenuItem {
text: "Delete"
onClicked: {
backend.removeTodo(task.index)
}
} }
} }
} MouseArea {
id: mouse
MouseArea { anchors.fill: parent
id: mouse acceptedButtons: Qt.RightButton
anchors.fill: parent onClicked: {
acceptedButtons: Qt.RightButton contextMenu.popup()
propagateComposedEvents: true }
onClicked: {
contextMenu.popup()
} }
} }
} }
} }
Item {
Layout.fillHeight: true
}
} }