Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App uses nested NavHosts with unintuitive routing #96

Open
jdkoren opened this issue Aug 30, 2024 · 1 comment
Open

App uses nested NavHosts with unintuitive routing #96

jdkoren opened this issue Aug 30, 2024 · 1 comment
Assignees

Comments

@jdkoren
Copy link
Contributor

jdkoren commented Aug 30, 2024

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.

@ashnohe
Copy link
Contributor

ashnohe commented Dec 11, 2024

#114

@ashnohe ashnohe self-assigned this Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants