Skip to content

App uses nested NavHosts with unintuitive routing #96

@jdkoren

Description

@jdkoren

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions