From 4cdb4c0bef0a52a9c3ae4b472d95fcba8197aa9c Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 22 Aug 2017 23:18:27 -0600 Subject: functions for pushing and replacing views --- components/kube/contents/ui/Kube.qml | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/components/kube/contents/ui/Kube.qml b/components/kube/contents/ui/Kube.qml index 5e4238bb..5a3d21df 100644 --- a/components/kube/contents/ui/Kube.qml +++ b/components/kube/contents/ui/Kube.qml @@ -215,31 +215,41 @@ Controls2.ApplicationWindow { onMessageReceived: kubeViews.pop(Controls2.StackView.Immediate) } + ///Replace the current view (we can't go back to the old view, and we destroy the old view) + function replaceView(view) { + if (currentItem != view) { + kubeViews.replace(null, view, {}, Controls2.StackView.Immediate) + } + } + + ///Push a new view on the stack (the old view remains, and we can go back once done) + function pushView(view, properties) { + kubeViews.push(view, properties, Controls2.StackView.Immediate) + } + //TODO replacing here while a composer is open is destructive function setPeopleView() { - if (currentItem != peopleView) { - kubeViews.replace(null, peopleView, Controls2.StackView.Immediate) - } + replaceView(peopleView) } + function setMailView() { - if (currentItem != mailView) { - kubeViews.replace(null, mailView, Controls2.StackView.Immediate) - } + replaceView(mailView) } + function setAccountsView() { - kubeViews.push(accountsView, {}, Controls2.StackView.Immediate) + pushView(accountsView, {}) } + function setLogView() { - if (currentItem != logView) { - kubeViews.replace(null, logView, Controls2.StackView.Immediate) - } + replaceView(logView) } function openComposer(newMessage, recipients) { - kubeViews.push(composerView, {newMessage: newMessage, recipients: recipients}, Controls2.StackView.Immediate) + pushView(composerView, {newMessage: newMessage, recipients: recipients}) } + function openComposerWithMail(mail, openAsDraft) { - kubeViews.push(composerView, {message: mail, loadAsDraft: openAsDraft}, Controls2.StackView.Immediate) + pushView(composerView, {message: mail, loadAsDraft: openAsDraft}) } onCurrentItemChanged: { -- cgit v1.2.3