Dekko
Loading...
Searching...
No Matches
StageArea.qml
1/* Copyright (C) 2016 - 2017 Dan Chapman <dpniel@ubuntu.com>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18import QtQuick 2.4
19import Lomiri.Components 1.3
20import Dekko.Controls 1.0
21import QuickFlux 1.0
22import Dekko.Mail.API 1.0
23// A stage area is a root container used for an area of the MainStage
24// A StageArea has it's own internal page stack and should be used
25// by all child pages of this StageArea
26Item {
27 id: stageArea
28 clip: true // Don't leak into another area
29 // Set a page url to load on creation
30 property var baseUrl: undefined
31 // Set a base component to load on creation
32 property Component baseComponent: null
33 property alias stackCount: internalStack.depth
34 property alias currentItem: internalStack.currentItem
35 property bool immediatePush: false
36 property alias delegate: internalStack.delegate
37 property bool pushBeforeReplace: false
38
39 property string stageID: ""
40
41 StackView {
42 id: internalStack
43 anchors.fill: parent // make sure our stack takes the full size
44 initialItem: baseComponent !== null ? baseComponent : baseUrl
45 }
46
47 function pop() {
48 internalStack.pop()
49 }
50
51 function popImmediate() {
52 internalStack.pop()
53 }
54
55 AppListener {
56 Filter {
57 type: ViewKeys.pushToStageArea
58 onDispatched: {
59 if (message.stageID === stageID) {
60 if (immediatePush) {
61 internalStack.push({item: message.page, immediate: true, properties: message.properties})
62 } else {
63 internalStack.push({item: message.page, properties: message.properties})
64 }
65 }
66 }
67 }
68 Filter {
69 type: ViewKeys.replaceTopStageAreaItem
70 onDispatched: {
71 if (message.stageID === stageID) {
72 if (pushBeforeReplace && stackCount === 1) {
73 ViewActions.pushToStageArea(stageID, message.page, message.properties)
74 return
75 }
76 if (immediatePush) {
77 internalStack.push({item: message.page, replace: true, immediate: true, properties: message.properties})
78 } else {
79 internalStack.push({item: message.page, replace: true, properties: message.properties})
80 }
81 }
82 }
83 }
84
85 Filter {
86 type: ViewKeys.popStageArea
87 onDispatched: {
88 if (message.stageID === stageID) {
89 internalStack.pop()
90 }
91 }
92 }
93 }
94}
95