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

This is a awesome project,why nested homeNavGraph #4

Open
est7 opened this issue Feb 7, 2023 · 7 comments
Open

This is a awesome project,why nested homeNavGraph #4

est7 opened this issue Feb 7, 2023 · 7 comments
Labels
question Further information is requested

Comments

@est7
Copy link

est7 commented Feb 7, 2023

This is a aw project, what I want to know is why a nested graph is generated for homeNavGraph in RootNavGraph, which makes the nested homeNavGraph have to use a new rememberNavController, which makes me confuse when to use rootnavController or nestednavController.

Depending on the google's intent, does it want to integrate the AppBottomBar view has a on-nested view,?

Thank you very much in advance for your help guys, and sorry for my noobiness.

@dmitriy-chernysh
Copy link
Member

Thanks for your support.

Think about the nested nav graph like a host which hosted inner screens (like a domain and subdomains for web pages). Each navigation host has its own navigation controller to navigate back and forward.

RootNavController is used to navigate between top-level screens, nestedNavController - to navigate between nested screens.

In our case:

  • Root Nav Graph (navigation host) hosted Onboarding, Home, and Subscription screens;
  • At the same time Home Nav Graph hosted 3 screens (Chat List, People, Profile); And BottomBar is used to navigate between these 3 screens.
  • People screen is just a navigation host for People List and People Profile screens.
  • If you want to navigate to the top-level screen from the root nav graph (as an example, to Subscription screen), you should use a root nav controller, otherwise you'll catch a runtime error like "this navigation graph doesn't contain this screen".

I'm hoping this explanation should help a bit.
Please check out this video (not mine) for more details, it could be helpful as well https://www.youtube.com/watch?v=gNzPGI9goU0&ab_channel=Stevdza-San

Thanks. And don't worry, we all were noobies.
Appreciate your questions.

@dmitriy-chernysh dmitriy-chernysh added the question Further information is requested label Feb 7, 2023
@dagostinisy
Copy link

dagostinisy commented May 6, 2023

With this approach how to navigate for example from Subscription screens that is declared in root nav graph to Profile screen that is a specific AppBottomBarItem?

If I use Screen.Profile.also(onNavigateTo) I obtain an error that this navigation graph doesn't contain this screen.

Thank you very much in advance for your help.

@dmitriy-chernysh
Copy link
Member

Currently, Subscription is a root-level screen. You cannot navigate from it to nested screen.

As a solution, Subscription screen should be moved to the same nav graph where Profile screen is placed.

@dagostinisy
Copy link

dagostinisy commented May 6, 2023

If you move subscriptionScreen(onNavigateBack = navigateBack) from RootNavGraph to HomeNavGraph and then navigate with Screen.Profile.also(onNavigateTo), obtain the same error: cannot be found in the navigation graph NavGraph,

@dmitriy-chernysh
Copy link
Member

Thanks for letting me know. Will try to check it tomorrow

@dmitriy-chernysh
Copy link
Member

I've added a subscription button (crown icon) to Profile screen . It opens the Subscription screen.
#11

@dagostinisy Hoping it would help to figure out

@davideagostini
Copy link

Ok thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants