feat(StatusStackModal): introduce `prevAction` API

This adds a possible `prevAction` hook to `stackLayout.currentItem`
which is triggered (if it exists) when the stack modal's back button is
hit.
This commit is contained in:
Pascal Precht 2022-07-13 15:00:17 +02:00 committed by Michał Cieślak
parent cf5461799f
commit 85ca2dc3b3
1 changed files with 9 additions and 4 deletions

View File

@ -60,10 +60,15 @@ StatusModal {
rotation: 180
visible: replaceItem || stackLayout.currentIndex > 0
onClicked: {
if (replaceItem)
replaceItem = null;
else
stackLayout.currentIndex--;
if (replaceItem) {
replaceItem = null;
} else {
let prevAction = stackLayout.currentItem.prevAction
stackLayout.currentIndex--;
if (typeof(prevAction) == "function") {
prevAction()
}
}
}
}