| 1 |
/* Copyright (C) 2016 - 2017 Dan Chapman <[email protected]> |
| 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 |
*/ |
| 18 |
import QtQuick 2.4 |
| 19 |
import Lomiri.Components 1.3 |
| 20 |
import Dekko.Controls 1.0 |
| 21 |
import QuickFlux 1.0 |
| 22 |
import 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 |
| 26 |
Item { |
| 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 |
anchors.fill: parent |
| 42 |
|
| 43 |
StackView { |
| 44 |
id: internalStack |
| 45 |
anchors.fill: parent // make sure our stack takes the full size |
| 46 |
initialItem: baseComponent !== null ? baseComponent : baseUrl |
| 47 |
} |
| 48 |
|
| 49 |
function pop() { |
| 50 |
internalStack.pop() |
| 51 |
} |
| 52 |
|
| 53 |
function popImmediate() { |
| 54 |
internalStack.pop() |
| 55 |
} |
| 56 |
|
| 57 |
AppListener { |
| 58 |
Filter { |
| 59 |
type: ViewKeys.pushToStageArea |
| 60 |
onDispatched: { |
| 61 |
if (message.stageID === stageID) { |
| 62 |
if (immediatePush) { |
| 63 |
internalStack.push({item: message.page, immediate: true, properties: message.properties}) |
| 64 |
} else { |
| 65 |
internalStack.push({item: message.page, properties: message.properties}) |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
Filter { |
| 71 |
type: ViewKeys.replaceTopStageAreaItem |
| 72 |
onDispatched: { |
| 73 |
if (message.stageID === stageID) { |
| 74 |
if (pushBeforeReplace && stackCount === 1) { |
| 75 |
ViewActions.pushToStageArea(stageID, message.page, message.properties) |
| 76 |
return |
| 77 |
} |
| 78 |
if (immediatePush) { |
| 79 |
internalStack.push({item: message.page, replace: true, immediate: true, properties: message.properties}) |
| 80 |
} else { |
| 81 |
internalStack.push({item: message.page, replace: true, properties: message.properties}) |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
Filter { |
| 88 |
type: ViewKeys.popStageArea |
| 89 |
onDispatched: { |
| 90 |
if (message.stageID === stageID) { |
| 91 |
internalStack.pop() |
| 92 |
} |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
|