You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This app has two NavHosts, one in Main.kt and another (nested) one in Home.kt.
One peculiarity is the chats route (for the chat list) is in the nested NavHost, while the chat/{chatId} route is in the outer NavHost. It feels opposite from the expected, which is that chats should be a parent route for chat/{chatId}. Alternatively, to support large screens, there should be a destination capable of showing both chats and a selected chat/{chatId} destinations side by side.
Also, the nested NavHost isn't really used for navigation; there are no navigate() calls on its NavHostController. Instead, the current destination is external state that is read by NavHost, specifically to set startDestination to the route of the currently selected item in the nav bar. This has some undesirable effects:
The NavHost recomposes entirely whenever the selected item changes.
The NavHost is always on the start destination, so pressing back always exits completely instead of taking the user back to Chats first.
Ideally, the app should have one stable nav graph with all its destinations defined.
The text was updated successfully, but these errors were encountered:
This app has two
NavHost
s, one inMain.kt
and another (nested) one inHome.kt
.One peculiarity is the
chats
route (for the chat list) is in the nestedNavHost
, while thechat/{chatId}
route is in the outerNavHost
. It feels opposite from the expected, which is thatchats
should be a parent route forchat/{chatId}
. Alternatively, to support large screens, there should be a destination capable of showing bothchats
and a selectedchat/{chatId}
destinations side by side.Also, the nested
NavHost
isn't really used for navigation; there are nonavigate()
calls on itsNavHostController
. Instead, the current destination is external state that is read byNavHost
, specifically to setstartDestination
to the route of the currently selected item in the nav bar. This has some undesirable effects:NavHost
recomposes entirely whenever the selected item changes.NavHost
is always on the start destination, so pressing back always exits completely instead of taking the user back to Chats first.Ideally, the app should have one stable nav graph with all its destinations defined.
The text was updated successfully, but these errors were encountered: