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?
Raed Ghazal
10/05/2024, 12:47 PM
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
Daniel Weidensdörfer
10/06/2024, 7:30 AM
You can consider using nested graphs or multiple NavHosts
r
Raed Ghazal
10/06/2024, 7:42 AM
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
Akshat
10/07/2024, 7:35 AM
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
Raed Ghazal
10/07/2024, 7:36 AM
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
Raed Ghazal
10/07/2024, 7:37 AM
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