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

Navigate between destinations in separate nav graphs programmatically #2

Open
premacck opened this issue Oct 10, 2024 · 0 comments
Open

Comments

@premacck
Copy link

Thanks for this amazing sample. I was working on a POC of having navigation components in an existing app with millions of active users, and I found your sample to be quite informative.

However, I had a requirement which I was trying to accomplish on top of your sample.
For the sake of simplicity, I'm calling the root pages (all the containerFragments defined in main_navigation) as L0 pages, and all the pages that open inside the heirarchy as non-L0 pages.

So here's what I'm trying to accomplish:

Navigation from one L0 / Non-L0 page to another L0 page.

Let's say I want to go from tradingFragment to profileFragment.
If I directly put the destination id R.id.profileFragment in the findRootNavigator.navigate(), then the app crashes with the error:

Navigation action/destination com.hakvardanyan.navigationsample:id/profileFragment cannot be found from the current destination Destination(com.hakvardanyan.navigationsample:id/mainFragment) label=MainFragment class=com.hakvardanyan.navigationsample.main.MainFragment

The same happens when I try to navigate to R.id.profileContainerFragment:

Navigation action/destination com.hakvardanyan.navigationsample:id/profileContainerFragment cannot be found from the current destination Destination(com.hakvardanyan.navigationsample:id/mainFragment) label=MainFragment class=com.hakvardanyan.navigationsample.main.MainFragment

I tried <includeing the nav graph of TradingFragment (home_navigation), ProfileFragment (profile_navigation), and even ProfileContainerFragment (main_navigation) in that of MainFragment (app_navigation). But the same issue is still there.

Do I need to create the destination programmatically and add it in the same nav graph every time I need to navigate to an L0 page in another tab? Do you think there could be a scalable way to achieve this through non-XML ways?

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

1 participant