added basic pull to refresh on event form

This commit is contained in:
Dorian Zedler 2018-12-27 11:30:12 +01:00
parent 74b9233a9e
commit 8400d2db1c
4 changed files with 65 additions and 21 deletions

View file

@ -5,6 +5,8 @@ import QtQuick.Controls 2.4
ListView { ListView {
id: eventList id: eventList
signal refresh()
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 anchors.margins: 10
@ -12,6 +14,12 @@ ListView {
id: foodPlanModel id: foodPlanModel
} }
onContentYChanged: {
if(contentY < -150){
eventList.refresh()
}
}
delegate: Button { delegate: Button {
id: delegate id: delegate

View file

@ -17,49 +17,82 @@ Page {
onOpened: { onOpened: {
} }
// Image{ // Image{
// source: "qrc:/graphics/chat_background.jpg"; // source: "qrc:/graphics/chat_background.jpg";
// height: parent.height // height: parent.height
// width: parent.width // width: parent.width
// fillMode: Image.Tile // fillMode: Image.Tile
// horizontalAlignment: Image.AlignLeft // horizontalAlignment: Image.AlignLeft
// verticalAlignment: Image.AlignTop // verticalAlignment: Image.AlignTop
// } // }
// LinearGradient { // LinearGradient {
// anchors.fill: parent // anchors.fill: parent
// start: Qt.point(0, 0) // start: Qt.point(0, 0)
// end: Qt.point(0, parent.height) // end: Qt.point(0, parent.height)
// gradient: Gradient { // gradient: Gradient {
// GradientStop { position: 0.0; color: "#4db2b3" } // GradientStop { position: 0.0; color: "#4db2b3" }
// GradientStop { position: 1.0; color: "#8f4dae" } // GradientStop { position: 1.0; color: "#8f4dae" }
// } // }
// } // }
Loader { Loader {
id: pageLoader id: pageLoader
property string newSource: ""
onNewSourceChanged: {
oldItemAnimation.start()
}
anchors.fill: parent anchors.fill: parent
source: "./LoadingForm.qml" source: "./LoadingForm.qml"
onSourceChanged: animation.start() onSourceChanged: newItemAnimation.start()
NumberAnimation { NumberAnimation {
id: animation id: newItemAnimation
target: pageLoader.item target: pageLoader
property: "opacity" property: "opacity"
from: 0 from: 0
to: 100 to: 100
duration: 500 duration: 500
easing.type: Easing.InExpo easing.type: Easing.InExpo
} }
NumberAnimation {
id: oldItemAnimation
target: pageLoader
property: "opacity"
from: 100
to: 0
duration: 500
easing.type: Easing.InExpo
onRunningChanged: {
if(!running){
pageLoader.source = pageLoader.newSource
}
}
}
Connections {
target: pageLoader.item
onRefresh: {
pageLoader.newSource = "./LoadingForm.qml"
loadTimer.start()
}
}
} }
Timer { Timer {
id: loadTimer
interval: 500 interval: 500
running: true running: true
repeat: false repeat: false
onTriggered: { onTriggered: {
status = serverConn.getEvents(day) status = serverConn.getEvents(day)
pageLoader.source = "../Components/EventView.qml" pageLoader.newSource = "../Components/EventView.qml"
} }
} }

View file

@ -4,6 +4,8 @@ import QtQuick.Controls 2.4
Page { Page {
id: root id: root
signal refresh()
BusyIndicator { BusyIndicator {
anchors.centerIn: parent anchors.centerIn: parent
} }

View file

@ -415,6 +415,7 @@ int ServerConn::getEvents(QString day){
if(blocksOK != 3) { if(blocksOK != 3) {
// if there are more or less than 3 filled blocks, the data is invalid // if there are more or less than 3 filled blocks, the data is invalid
this->m_events.clear();
return(900); return(900);
} }