I have a compose navigation controller issue, as i...
# compose
c
I have a compose navigation controller issue, as in I want to be able to mix
composable
,
dialog
and
dialog<F: Fragment>
destinations so I construct my navController like
Copy code
val context = LocalContext.current
val fragmentManager = LocalFragmentManager.current
val dialogFragmentNavigator = remember(
    context,
    fragmentManager
) { DialogFragmentNavigator(context, fragmentManager) }

val navController = rememberNavController(dialogFragmentNavigator)
but if I add a regular composable
dialog
destination to the graph, it will crash with
Copy code
java.lang.ClassCastException: androidx.navigation.compose.DialogNavigator cannot be cast to androidx.navigation.fragment.DialogFragmentNavigator
it seems like the navigator provider returns the wrong navigator? is it because they are registered with the same name?
Copy code
@Navigator.Name("dialog")
public class DialogFragmentNavigator(...)
and
Copy code
@Navigator.Name("dialog")
public class DialogNavigator : Navigator<Destination>() {
it works fine if I don't have both
dialog
and
dialog<F: Fragment>
destinations
m
I do believe the names are somewhat important here and this seems like you just can't use both together out of the box. It's possible that maybe you could duplicate one of them with a new class name, and alter the annotation. it would be messy and cumbersome, but i don't see how else you could make them work together.
c
yes, that is what I've come to realise too, I'll have to use my own navigator for one of the destinations
I think the names are mostly used for the provider to find them, I'll file a issue and see if it gets picked up