Any guides to compose navigation with bottomNav wi...
# compose
c
Any guides to compose navigation with bottomNav with a sign in flow? I used these docs when setting up my app https://developer.android.com/jetpack/compose/navigation#bottom-nav but now when I open the app on a cold launch (and the user isn't logged in), I see my HomeScreen for a split second with my bottom nav and then I go to my sign in screen which doesn't have bottom nav and it's just kinda jarring from the user POV. Curious if there's some best practices with bottom nav and sign in combined.
n
Would something like this work?
Copy code
val navController = rememberNavController()
Scaffold(
  bottomBar = {
if(user.isloggedIn() {
   BottomNavigation()
  }
}
)
?
1
and for the content part:
Copy code
when(user.isLoggedIn){
   true -> HomeScreen()
   false -> Login()
}
1
you shouldn’t see the flicker then
but user.isLoggedIn should be a
state
though, with the default value of
false
i
Note that this next Navigation release removes the initial flicker caused by Navigation's state not being set for the first composition
👀 1
👍 2
c
Interesting. Maybe That's the issue. Any other tips or should I wait for that?
n
oh there’s a bug? does my solution not work?
c
I was mostly just commenting on the fact that maybe my impl wasn't "wrong" at all, it's just that navigation lib needs an update. Regarding your solution Nick, I haven't tried it but I was curious to what Ians opinion on it is. So far I have all of my user.isLoggedIn checking being done on the composable Screen level as per Ians recommendation and so I'd like to keep all of that logic there.
👍 1
n
ahh that sounds like a better way.