PageStack.backNavigation: bug when returning to first page? [answered]
Background
I am trying to create application with behaviour similar to (but not identical with) Maps application. First page is for different app functions, where user can enter map page. PageStack navigation is disabled when drawer is closed, but again enabled when drawer is opened.
Problem
When PageStack.backNavigation is manually disabled/enabled on second page level and user returns to first page, navigation indicator stays visible even though the stack contains only one page. In every other case where PageStack.backNavigation is not manually accessed, indicator disappears. In addition to this, when navigation indicator is visible on first level, user can flick back and leave first page, and the program stalls.
Is there something I am doing wrong or is this a bug in pageStack?
I guess I could somehow define on first page that on opening it, pageStack.backNavigation = false
and on leaving page, pageStack.backNavigation = true
, but it seems hackish. Surely it is designed to happen automatically? Or does this automation stop when backNavigation is accessed manually? If so, is there a way to turn it back on?
Example program:
FirstPage.qml
import QtQuick 2.0
import Sailfish.Silica 1.0
Page {
id: firstpage
SilicaFlickable {
anchors.fill: parent
PullDownMenu {
MenuItem {
text: "Page 2"
onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml"))
}
}
ViewPlaceholder {
text: "Go to second page and come back here"
enabled: true
}
}
}
SecondPage.qml
import QtQuick 2.0
import Sailfish.Silica 1.0
import QtLocation 5.0
import QtPositioning 5.0
Page {
id: secondpage
Drawer {
id: drawer
open: false
anchors.fill: parent
background: SilicaListView {
anchors.fill: parent
model: 4
header: PageHeader { title: "Drawer" }
delegate: BackgroundItem {
id: someItem
contentHeight: Theme.itemSizeSmall
Label {
x: Theme.paddingLarge
text: "List Item " + index
anchors.verticalCenter: parent.verticalCenter
color: someItem.highlighted ? Theme.highlightColor : Theme.primaryColor
}
}
}
Map {
id: map
plugin : Plugin {name : "osm"}
anchors.fill: parent
center: QtPositioning.coordinate(60.17, 24.95)
MouseArea {
anchors.fill: parent
onClicked: {
drawer.open = !drawer.open
pageStack.backNavigation = drawer.open
}
}
}
}
Component.onCompleted: {
if (!drawer.open){
pageStack.backNavigation = false
}
}
}
Figures showing what happens:
First page:
Second page, navigation is disabled
Tap on map and drawer opens, navigation is enabled
- Navigate back to first page, navigation does not disappear
Try to navigate "back" from first page and program ends up unresponsive