Only show 1 Calendar day on phone

This commit is contained in:
Vyn 2024-05-21 12:14:05 +02:00
parent da3f33849a
commit bf50484d40
3 changed files with 11 additions and 10 deletions

View file

@ -16,8 +16,7 @@ Window {
height: 480
visible: true
title: qsTr("Hello World")
property bool isPhone: root.width < root.height
property string selectedView: "list"
@ -99,13 +98,13 @@ Window {
}
function setFittingLayout() {
if (width > height) {
desktopLayout.visible = true
phoneLayout.visible = false
} else {
if (root.isPhone) {
desktopLayout.visible = false
phoneLayout.visible = true
phoneLayout.setCurrentIndex(1)
phoneLayout.setCurrentIndex(1)
} else {
desktopLayout.visible = true
phoneLayout.visible = false
}
}
onWidthChanged: setFittingLayout()

View file

@ -10,6 +10,7 @@ import QtQuick.Layouts
import Mirai
ColumnLayout {
property int numberOfDaysPerPage: 7
id: control
spacing: 32
QtObject {
@ -33,7 +34,7 @@ ColumnLayout {
AppButton {
text: "<"
onClicked: {
internal.weekStartDate.setDate(internal.weekStartDate.getDate() - 7)
internal.weekStartDate.setDate(internal.weekStartDate.getDate() - control.numberOfDaysPerPage)
}
}
@ -47,7 +48,7 @@ ColumnLayout {
AppButton {
text: ">"
onClicked: {
internal.weekStartDate.setDate(internal.weekStartDate.getDate() + 7)
internal.weekStartDate.setDate(internal.weekStartDate.getDate() + control.numberOfDaysPerPage)
}
}
}
@ -79,7 +80,7 @@ ColumnLayout {
}
Repeater {
model: 7
model: control.numberOfDaysPerPage
Rectangle {
Layout.fillWidth: true

View file

@ -18,6 +18,7 @@ ColumnLayout {
Calendar {
width: parent.width
height: parent.height
numberOfDaysPerPage: root.isPhone ? 1 : 7
}
}
}