Skip to content

Commit 7eb9f82

Browse files
authored
Merge pull request #318 from Esri/anmacdonald/resolved_stackview
Stackview transitions now handle more than 2 items.
2 parents a7069a4 + 540cbe2 commit 7eb9f82

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

Import/Esri/ArcGISRuntime/Toolkit/Controls/PopupStackView.qml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import QtQuick 2.11
1818
import QtQuick.Controls 2.4
19-
import QtQuick.Dialogs 1.2
2019

2120
/*!
2221
\qmltype PopupStackView
@@ -193,10 +192,8 @@ Item {
193192
*/
194193
function show() {
195194
currentIndex = 0;
196-
popupStack.clear();
197195
if (popupManagers !== null && popupManagers.length > 0) {
198196
popup1.popupManagerInternal = popupManagers[currentIndex]
199-
popupStack.push(popup1);
200197
}
201198
visible = true;
202199
}
@@ -289,36 +286,42 @@ Item {
289286

290287
/*! internal */
291288
function nextPopup() {
289+
if (popupStack.busy)
290+
return;
291+
292292
if (currentIndex + 1 === popupManagers.length)
293293
return;
294294

295295
currentIndex += 1;
296296

297297
if (popupStack.currentItem === popup1) {
298-
popup2.popupManagerInternal = popupManagers[currentIndex]
299-
popupStack.push(popup2);
300-
}
301-
else
302-
{
303-
popup1.popupManagerInternal = popupManagers[currentIndex]
304-
popupStack.push(popup1);
298+
swapPopups(popup1, popup2);
299+
} else {
300+
swapPopups(popup2, popup1);
305301
}
306-
307302
}
308303

309304
/*! internal */
310305
function previousPopup() {
306+
if (popupStack.busy)
307+
return;
308+
311309
if (currentIndex === 0)
312310
return;
313311

314312
currentIndex -= 1;
315313

316-
if (popupStack.currentItem === popup2)
317-
popup1.popupManagerInternal = popupManagers[currentIndex];
318-
else
319-
popup2.popupManagerInternal = popupManagers[currentIndex];
314+
if (popupStack.currentItem === popup1) {
315+
swapPopups(popup1, popup2);
316+
}
317+
else {
318+
swapPopups(popup2, popup1);
319+
}
320+
}
320321

321-
popupStack.pop();
322+
function swapPopups(frontPopup, backPopup) {
323+
backPopup.popupManagerInternal = popupManagers[currentIndex];
324+
popupStack.replace(frontPopup, backPopup);
322325
}
323326

324327
/*! internal */
@@ -477,6 +480,10 @@ Item {
477480
StackView {
478481
id: popupStack
479482
anchors.fill: parent
483+
484+
Component.onCompleted: {
485+
push(popup1);
486+
}
480487
}
481488

482489
Rectangle {

0 commit comments

Comments
 (0)