tunjid / Android-Extensions

An Android library with modules to quickly bootstrap an Android application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong order of selected tabs during back press?

wman1980 opened this issue · comments

Hi @tunjid,

its me again! :)

If I start you example project and click myself through the tabs in the following order

Nav, Lists, Comms, Misc, Comms, Lists, Nav (From left to right and back to left)

I would expect that while I am pressing the back button I would go through

Lists, Comms, Misc, Comms, Lists, Nav and finally app is moved to background

but instead the order is

Lists, Comms, Misc and finally app is moved to background

is that the right behavior?

Here is a little example video:

example.mov

@wman1980 currently that's the intended behavior, I was copying Instagram on this front; each tab is only represented once in the stack for each tab.

Lemme know if you want the scenario you described supported and I'll take a whack at it.

Hm ... not sure.

Another option might also be that there is no tab switching at all during back press and the app moves to background if it reached the root of the current selected tab ...

What would be the default/recommended behavior by material design?

Haven't found anything regarding back tab navigation ...

@wman1980 the closest I was able to find was this: https://material.io/design/navigation/understanding-navigation.html#reverse-navigation

If one were to follow that strictly, what you expect should be the desired behavior. It does bring up the problem that the stack for the tab history can get arbitrarily large. Not world breakingly so, but its one more thing to consider.

Regarding arbitrarily large:

  • you could introduce a backStackType enum
  • that enum could be set to type "instagram" (default), "endless" or "custom(amount)"
  • For type custom you could define a max count of tabs in back history. If that max count is reached you simple delete the first entry within the tabs back history, so that you only have the defined amount in your back history

Hope you get my idea?

@wman1980 sure thing, will do.

Closing this, will be in the next release.