-
Notifications
You must be signed in to change notification settings - Fork 139
Description
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
NavHostrecomposes entirely whenever the selected item changes. - The
NavHostis 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.