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

2 navgraph with same destination name #538

Closed
WildOrangutan opened this issue Nov 20, 2023 · 3 comments
Closed

2 navgraph with same destination name #538

WildOrangutan opened this issue Nov 20, 2023 · 3 comments

Comments

@WildOrangutan
Copy link

Hey,

I have 2 nav-graphs, that are not nested in root navgraph. If I use same name for a destination, I get

com.ramcosta.composedestinations.codegen.commons.IllegalDestinationsSetup: Multiple Destinations with 'terms_of_service' as their route name.

I would expect that destinations are generated based on package name. For example, in case of shared terms of service screen:

  • com.my.app.signin.destinations.TermsOfServiceDestination
  • com.my.app.signup.destinations.TermsOfServiceDestination

That doesn't happen, but instead com.my.app.destinations.TermsOfServiceDestination is generated, which I guess is causing the conflict.

Am I doing something wrong here?

// 1st nav (com.my.app.signin package)
@NavGraph
annotation class SignInNavGraph(
    val start: Boolean = false,
)

@Composable
@Destination
@SignInNavGraph(start = true)
fun TermsOfService(navigator: DestinationsNavigator) {
    TermsOfServiceScreen()
}

// 2nd nav graph (com.my.app.signup package)
@NavGraph
annotation class SignUpInNavGraph(
    val start: Boolean = false,
)

@Composable
@Destination
@SignUpInNavGraph(start = true)
fun TermsOfService(navigator: DestinationsNavigator) {
    TermsOfServiceScreen()
}
@raamcosta
Copy link
Owner

raamcosta commented Nov 20, 2023

Hi!

if you need a route different from the defaul one (taken from the composable name),@Destination has a parameter you can use to set whatever route you want.

That would be my recommendation 🙂

@WildOrangutan
Copy link
Author

Thank you for a one solution.

Would it maybe make sense, to also add a feature, so you could specify under which package specific nav-graph gets generated?

@raamcosta
Copy link
Owner

At this point, there's no plan to do something like that. In this case, I would call your composables SignUpTermsOfService and SignInTermsOfService. Even if they're in different packages, it also would help developers understand where they are at a glance. That or specify a route, although I believe Composable names also need to be unique in current version (that will go away with v2).

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