From e2e83ba5ea981f908a9b203ca8b82ba14f27073c Mon Sep 17 00:00:00 2001 From: dorian Date: Thu, 27 Dec 2018 15:01:05 +0100 Subject: [PATCH] finished up pull to refresh at the event and foodplan form --- qml/Components/EventView.qml | 2 +- qml/Components/FoodPlanView.qml | 8 +++++++ qml/Forms/EventForm.qml | 13 +++++----- qml/Forms/FoodPlanForm.qml | 42 +++++++++++++++++++++++++++++---- 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/qml/Components/EventView.qml b/qml/Components/EventView.qml index 85cfb17..c3fb188 100644 --- a/qml/Components/EventView.qml +++ b/qml/Components/EventView.qml @@ -15,7 +15,7 @@ ListView { } onContentYChanged: { - if(contentY < -150){ + if(contentY < -125){ eventList.refresh() } } diff --git a/qml/Components/FoodPlanView.qml b/qml/Components/FoodPlanView.qml index ca7a937..bc15e8b 100644 --- a/qml/Components/FoodPlanView.qml +++ b/qml/Components/FoodPlanView.qml @@ -5,9 +5,17 @@ import QtQuick.Controls 2.4 ListView { id: foodList + signal refresh() + anchors.fill: parent anchors.margins: 10 + onContentYChanged: { + if(contentY < -125){ + foodList.refresh() + } + } + model: FoodPlanModel { id: foodPlanModel } diff --git a/qml/Forms/EventForm.qml b/qml/Forms/EventForm.qml index d1d44bc..5f47628 100644 --- a/qml/Forms/EventForm.qml +++ b/qml/Forms/EventForm.qml @@ -51,21 +51,21 @@ Page { NumberAnimation { id: newItemAnimation - target: pageLoader + target: pageLoader.item property: "opacity" from: 0 - to: 100 - duration: 500 + to: 1 + duration: 200 easing.type: Easing.InExpo } NumberAnimation { id: oldItemAnimation - target: pageLoader + target: pageLoader.item property: "opacity" - from: 100 + from: 1 to: 0 - duration: 500 + duration: 200 easing.type: Easing.InExpo onRunningChanged: { @@ -82,7 +82,6 @@ Page { loadTimer.start() } } - } Timer { diff --git a/qml/Forms/FoodPlanForm.qml b/qml/Forms/FoodPlanForm.qml index 46892d9..b688d67 100644 --- a/qml/Forms/FoodPlanForm.qml +++ b/qml/Forms/FoodPlanForm.qml @@ -38,29 +38,61 @@ Page { Loader { id: pageLoader + + property string newSource: "" + + onNewSourceChanged: { + oldItemAnimation.start() + } + anchors.fill: parent source: "./LoadingForm.qml" - onSourceChanged: animation.start() + onSourceChanged: newItemAnimation.start() NumberAnimation { - id: animation + id: newItemAnimation target: pageLoader.item property: "opacity" from: 0 - to: 100 - duration: 500 + to: 1 + duration: 200 easing.type: Easing.InExpo } + + NumberAnimation { + id: oldItemAnimation + target: pageLoader.item + property: "opacity" + from: 1 + to: 0 + duration: 200 + easing.type: Easing.InExpo + + onRunningChanged: { + if(!running){ + pageLoader.source = pageLoader.newSource + } + } + } + + Connections { + target: pageLoader.item + onRefresh: { + pageLoader.newSource = "./LoadingForm.qml" + loadTimer.start() + } + } } Timer { + id: loadTimer interval: 500 running: true repeat: false onTriggered: { root.status = serverConn.getFoodPlan() - pageLoader.source = "../Components/FoodPlanView.qml" + pageLoader.newSource = "../Components/FoodPlanView.qml" } }