mobile/dive-details: if menu is open, close that with back button

A second tap on the back button will then end add/edit or close the dive
details and get us back to the dive list.

This fixes an issue where tapping on back with the context menu open
would bring you back to the dive list with the context menu still open,
and because then change the text in the context menu as those are
designed differently.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-03-31 09:40:28 -07:00
parent 91f7689787
commit 2bf394581f

View file

@ -261,15 +261,27 @@ Kirigami.Page {
}
onBackRequested: {
if (state === "edit") {
endEditMode()
event.accepted = true;
} else if (state === "add") {
endEditMode()
pageStack.pop()
event.accepted = true;
// if one of the drawers/menus is open, the back button should close those
if (globalDrawer.visible) {
globalDrawer.close()
event.accepted = true
}
// if we were in view mode, don't accept the event and pop the page
if (contextDrawer.visible) {
contextDrawer.close()
event.accepted = true
}
// if we didn't close either of the drawer, check if we need to close add/edit
if (event.accepted === false) {
if (state === "edit") {
endEditMode()
event.accepted = true;
} else if (state === "add") {
endEditMode()
pageStack.pop()
event.accepted = true;
}
}
// if we were in view mode and no menus are open, don't accept the event and pop the page
}
onCurrentItemChanged: {