What's the approach in Compose when you have a bot...
# compose
f
What's the approach in Compose when you have a bottom nav hosted in the activity but want a full-screen screen in some destinations? Just hide the bottom nav through a callback + a state variable? I'm worried if this could get out of sync somehow.
s
You can check is it necessary to show bottom bar by route of currentBackStackEntry's destination, where currentBackStackEntry is state:
Copy code
val currentBackStackEntry by navController.currentBackStackEntryAsState()
It must be in sync, otherwise it's a bug in navigation component
f
alright, thank you
Hm looks like this is the wrong approach because recreateing the BottomNavigation will lose its state
but I wanna keep the backstack and scroll positions intact
f
you're using AnimatedVisibility
that's pretty clever
This way it shouldn't lose the state
no it actually does lose scroll position
I'm running your app
s
It's because of paging library bug/behavior 😞
With common lazy list it works perfectly
Check with scroll state of carousel
f
hm weird
I have the same setup but I lose LazyColumn scroll position if I add AnimatedVisibility
s
f
Indeed, that fixed it
Wow, thank you so much
although I don't yet understand why it works like this
Jetpack Compose is definitely tricky
s
f
I already read that but I guess I should read it again 😂
😀 1
But it looks really great like this. You made my day 👍
s
Also this codelab helped me to get state in compose - https://developer.android.com/codelabs/jetpack-compose-state
f
yea I worked through that as well too
but it's tricky to really understand
👌 1
at least the rememberLazyListpart
btw there is also a bug in the bottom nav code from the docs
are you aware of that?
s
About double taps?
Yeah, hope it'll be fixed soon
Maybe in stable release, it's alpha now
f
right
Do you think wrapping the bottom nav item's
onClick
with
Copy code
if (currentDestination?.route != destination.route)
fixes this?
it seems to work
s
It works, but if you gonna add behavior of poping your backStack to startDestination (if you click on bottom bar item that is already selected) - it has to be refactored later (
It seems common pattern in apps
f
yea that's true
c
@Florian if you search this channel Ian lake has discussed this very thing like 20 times in the past few months 😄