161
161
The pushed page may be an Item, Component or URL.
163
163
function push(page, properties) {
164
if (internal.stack.size() > 0) internal.stack.top().active = false;
165
internal.stack.push(internal.createWrapper(page, properties));
166
internal.stackUpdated();
164
internal.finishPreviousAction();
165
internal.pageToPush = page;
166
internal.propertiesToPush = properties;
167
if (internal.animateHeader && internal.stack.size() > 0) {
168
internal.headStyle.animateOutFinished.connect(internal.createAndPush);
169
internal.headStyle.animateOut();
171
internal.createAndPush();
172
178
Do not do anything if 0 or 1 items are on the stack.
181
internal.finishPreviousAction();
175
182
if (internal.stack.size() < 1) {
176
183
print("WARNING: Trying to pop an empty PageStack. Ignoring.");
179
internal.stack.top().active = false;
180
if (internal.stack.top().canDestroy) internal.stack.top().destroyObject();
181
internal.stack.pop();
182
internal.stackUpdated();
186
// do not animate if there is no page to animate back in after popping
187
if (internal.animateHeader && internal.stack.size() > 1) {
188
internal.headStyle.animateOutFinished.connect(internal.popAndDestroy);
189
internal.headStyle.animateOut();
191
internal.popAndDestroy();
210
property Item headStyle: (pageStack.__propagated
211
&& pageStack.__propagated.header
212
&& pageStack.__propagated.header.__styleInstance)
213
? pageStack.__propagated.header.__styleInstance
216
function headerCanAnimate() {
217
if (!headStyle) return false;
218
if (!headStyle.hasOwnProperty("animateIn")) return false;
219
if (!headStyle.hasOwnProperty("animateOut")) return false;
220
if (!headStyle.hasOwnProperty("animateInFinished")) return false;
221
if (!headStyle.hasOwnProperty("animateOutFinished")) return false;
225
// FIXME: Replace false by headerCanAnimate() below to enable
226
// header animations.
227
property bool animateHeader: false
229
// Call this function before pushing or popping to ensure correct order
230
// of pushes/pops on the stack. This terminates any currently running
231
// header transition.
232
function finishPreviousAction() {
233
// no action required when animating IN because the PageStack was
234
// already updated before that transition started.
235
if (internal.animateHeader && internal.headStyle.state == "OUT") {
236
// force instant update of the PageStack without waiting for
237
// the OUT animation to finish:
238
internal.headStyle.animateOutFinished();
242
// The page and properties to push on the stack when the OUT animation
244
property var pageToPush
245
property var propertiesToPush
247
// Called when the header animate OUT transition finishes for push() or instantly
248
// when header animations are disabled.
249
function createAndPush() {
250
if (internal.animateHeader) {
251
headStyle.animateOutFinished.disconnect(internal.createAndPush);
253
if (internal.stack.size() > 0) internal.stack.top().active = false;
254
internal.stack.push(internal.createWrapper(pageToPush, propertiesToPush));
255
internal.stackUpdated();
258
// Called when header animate OUT transition finishes for pop() or instantly
259
// when header animations are disabled.
260
function popAndDestroy() {
261
if (internal.animateHeader) {
262
headStyle.animateOutFinished.disconnect(internal.popAndDestroy);
264
internal.stack.top().active = false;
265
if (internal.stack.top().canDestroy) internal.stack.top().destroyObject();
266
internal.stack.pop();
267
internal.stackUpdated();
202
271
The instance of the stack from javascript
212
281
return wrapperObject;
284
// Update depth and makes the Item on top of the stack active, and
285
// then animates IN the new header contents if header animations are enabled.
215
286
function stackUpdated() {
216
287
pageStack.depth = stack.size();
217
288
if (pageStack.depth > 0) {
218
289
internal.stack.top().active = true;
219
290
currentPage = stack.top().object;
292
if (internal.animateHeader) {
293
headStyle.animateIn();
221
296
currentPage = null;