Commit 4d57e786 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

Vertical swiping mechanism changed

Vertical date swipes functionality has been substituted with a simpler
approach that improves overall performance
parent 068a2d3e
Pipeline #19842 passed with stage
in 6 minutes and 4 seconds
......@@ -24,8 +24,31 @@ Kirigami.Page {
id: root
property alias selectedDate: calendarMonthView.selectedDate
/**
* @brief The active calendar, which is the host of todos, events, etc.
*
*/
property var calendar
/**
* @brief The index of the last contextual action triggered
*
*/
property int latestContextualAction: -1
/**
* @brief When set to a valid contextual action index, that contextual action is triggered
*
*/
property int triggerAction: -1
/**
* @brief Emited when the hosted SwipeView index is set to the first or the last container item
*
*/
signal pageEnd(var lastDate, var lastActionIndex)
title: calendarMonthView.displayedMonthName + " " + calendarMonthView.displayedYear
actions {
......@@ -55,18 +78,30 @@ Kirigami.Page {
iconName: "view-calendar-tasks"
text: i18n("Tasks")
onTriggered: pageStack.push(todosCardView)
onTriggered: {
latestContextualAction = 0
pageStack.push(todosCardView);
}
},
Kirigami.Action {
iconName: "tag-events"
text: i18n("Events")
onTriggered: pageStack.push(eventsCardView)
onTriggered: {
latestContextualAction = 1
pageStack.push(eventsCardView);
}
}
]
}
Component.onCompleted: {
if(triggerAction >= 0)
{
contextualActions[triggerAction].trigger();
}
}
CalendarMonthView {
id: calendarMonthView
......@@ -83,6 +118,8 @@ Kirigami.Page {
pageStack.pop(null);
}
}
onViewEnd: pageEnd(lastDate, (pageStack.depth > 1) ? root.latestContextualAction : -1)
}
Component {
......
/*
* Copyright 2019 Dimitris Kardarakos <dimkard@posteo.net>
* Copyright 2019-2020 Dimitris Kardarakos <dimkard@posteo.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
......@@ -39,15 +39,23 @@ Controls2.SwipeView {
property alias showHeader: monthView.showHeader
property alias showMonthName: monthView.showMonthName
property alias showYear: monthView.showYear
property int backMonthPad: 720
property int fwdMonthPad: 480
property int previousIndex
property var cal
property var manageIndex: function () {}
/**
* @brief When set, we take over the handling of the container items indexes programmatically
*
*/
property bool manualIndexing: false
signal nextMonth
signal previousMonth
signal goToday
/**
* @brief It should be emitted when the SwipeView currentIndex is set to the first or the last one
*
* @param lastDate p_lastDate:...
*/
signal viewEnd(var lastDate)
onNextMonth: {
mm.goNextMonth();
......@@ -66,6 +74,22 @@ Controls2.SwipeView {
onCurrentItemChanged: manageIndex()
function manageIndex ()
{
if(!manualIndexing)
{
return;
}
(currentIndex < previousIndex) ? previousMonth() : nextMonth();
previousIndex = currentIndex;
if(currentIndex != 1)
{
viewEnd(root.selectedDate) //Inform parents about the date to set as selected when re-pushing this page
}
}
Connections {
target: cal
......@@ -74,16 +98,13 @@ Controls2.SwipeView {
}
Component.onCompleted: {
currentIndex = backMonthPad;
currentIndex = 1;
previousIndex = currentIndex;
manageIndex = function() {
(currentIndex < previousIndex) ? mm.goPreviousMonth() : mm.goNextMonth();
previousIndex = currentIndex;
monthView.parent = currentItem;
};
manualIndexing = true;
orientation = Qt.Vertical //Change orientation after the object has been instantiated. Otherwise, we get a non-intuitive animation when swiping upwards
}
orientation: Qt.Vertical
orientation: Qt.Horizontal
DaysOfMonthIncidenceModel {
id: mm
......@@ -93,12 +114,7 @@ Controls2.SwipeView {
calendar: cal
}
Repeater {
id: backRepeater
model: backMonthPad
delegate: Item {}
}
Item {}
Item {
MonthView {
......@@ -118,10 +134,5 @@ Controls2.SwipeView {
}
}
Repeater {
id: forwardRepeater
model: fwdMonthPad
delegate: Item {}
}
Item {}
}
......@@ -24,6 +24,8 @@ import org.kde.phone.calindori 0.1 as Calindori
Kirigami.ApplicationWindow {
id: root
signal switchToMonthPage(var sDate, var cActionIndex)
globalDrawer: CalindoriGlobalDrawer {
id: globalDrawer
......@@ -60,6 +62,13 @@ Kirigami.ApplicationWindow {
CalendarMonthPage {
calendar: localCalendar
onPageEnd: switchToMonthPage(lastDate, lastActionIndex)
}
}
onSwitchToMonthPage: {
pageStack.clear();
pageStack.push(calendarMonthPage, {selectedDate: sDate, triggerAction: cActionIndex});
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment