You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An example in navigation: (1) Main menu -> (2) songbook -> (3) a song -> (4) main menu -> (5) songbook -> (6) main menu.
Now using back navigation, the stack just pops as presented. Instead you expect the stack to not include duplicates, so when step 5 is reached, all views until the identical step 2 should be popped, so the stack looks like (1) main menu -> (2) songbook instead.
Honestly I'm not entirely sure that I understand what you are suggesting.
Currently we just use the default browser behavior. But I assume what you are trying to get at is something like a tree structure, where pressing the back button will always go one step up in the tree.
E.g. If we were to somehow navigate to /songbook/songA from /stregsystem the back button will bring us to /songbook and not /stregsystem.
I'm not sure that I am able to explain it better 🤔
I think the idea is just that the same page can't be in the backstack twice, if it already exists, then past entries up until that page should be removed. I haven't implemented it myself, but that's the way I understand it. The link I referred originally has a pretty good demonstration/example of the undesirable situation
Looking back at the link and your original example, I think I get it now. The main thing that got me confused is that the example you provided marks the (4)->(5) transition as the where the unwinding happens, but it is at the (3)->(4) transition as the main menu is already on the stack.
Basically in pseudo code:
navigateTo(path) {
if backStack.contains(path) {
backStack = backStack.takeWhile(x => x != path)
}
backStack.push(path)
}
With how simple the page flow is in the app, I don't see any issue with using this approach.
An example in navigation: (1) Main menu -> (2) songbook -> (3) a song -> (4) main menu -> (5) songbook -> (6) main menu.
Now using back navigation, the stack just pops as presented. Instead you expect the stack to not include duplicates, so when step 5 is reached, all views until the identical step 2 should be popped, so the stack looks like
(1) main menu -> (2) songbook
instead.That's my understanding anyway, source: https://developer.android.com/guide/navigation/backstack/circular
The text was updated successfully, but these errors were encountered: