Hi, in compose navigation I have an issue using bo...
# compose
r
Hi, in compose navigation I have an issue using bottom nav bar when I use back gesture if I have those tabs: - Home Tab - Home - Post - Profile Tab - Profile Tab - Post now if I'm in Home Tab Home screen -> then open a post then click on Profile Tab then click on "back" I go back to Home Tab but the state is not restored, how to restore the state when I'm back to first tab?
cuz we call
restoreState
only when we navigate to a new tab, but when we're back to previous tab, how to restore it?
d
You can consider using nested graphs or multiple NavHosts
r
I use
navigation {}
and it works great but the only issue is when going back I tried multiple nav hosts but that had many other issues
a
I had faced the same issue. Do you need to use
navigation{}
? I fixed it by not relying on nested graphs (i didn't need them anyways)
r
yeah its better, imagine you're using instagram, in the search tab, and you have someone's profile open, then went to check your home tab, it will be annoying if the search tab lost its state and you couldn't find that profile again xD
navigation
is great, really easy to use and much less poilerplate than multi NavHosts, but it has this one issue I fixed it by adding a
BackHandler
in the tab so when I hit
back
I navigate and restore the state of the home tab - but its not really optimal, a native support would make a ton of sense