You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems as though we're only able to provide one dependency of each type, would it perhaps be possible to provide them as named dependencies so we can provide multiple dependencies of the same type? Perhaps using the @Named(" ") annotation
My reason:
I have my root composeable with a DestinationsNavHost which can navigate to a Home composeable screen which holds a DestinationsNavHost controlled by a bottom bar, from that bar we can navigate to a Profile screen, and then within the Profile screen we want an action to navigate to a new screen that should not be within the Home screen's DestinationsNavHost, but within the root's.
At the moment I've made a wrapping class class ParentDestinationsNavigator(val nav: DestinationsNavigator), made my Home screen's DestinationsNavHost(.. dependenciesContainerBuilder = { dependency(ParentDestinationsNavigator(destinationsNavigator))}) and my Profile screen constructor is class Profile(nav: ParentDestinationsNavigator) but would have rather had something like class Profile(@Named("root") nav: DestinationsNavigator) so that the correct DestinationsNavigator is always addressed
perhaps I'm missing a more obvious solution to my requirement
The text was updated successfully, but these errors were encountered:
Yeah this does make sense. I have had a similar idea in my mind for some time. I'm thinking about this specific case of a parent navigator and maybe there is a simpler way to do it.
Anyway, I'll keep this open as a good enhancement :)
You can try it with interface delegation.
This is not a answer, but just some small tweak before named dependency feature get released.
classParentDestinationsNavigator(delegate:DestinationsNavigator) : DestinationsNavigator by delegate
..
@SubNavGraph
@Destination
@Composable
funSubScreen(
parentNavigator:ParentDestinationsNavigator,
navigator:DestinationsNavigator
) {
..// you can use navigate function directly
parentNavigator.navigate(OtherScreenDestination)
}
It seems as though we're only able to provide one dependency of each type, would it perhaps be possible to provide them as named dependencies so we can provide multiple dependencies of the same type? Perhaps using the
@Named(" ")
annotationMy reason:
I have my root composeable with a DestinationsNavHost which can navigate to a Home composeable screen which holds a DestinationsNavHost controlled by a bottom bar, from that bar we can navigate to a Profile screen, and then within the Profile screen we want an action to navigate to a new screen that should not be within the Home screen's DestinationsNavHost, but within the root's.
At the moment I've made a wrapping class
class ParentDestinationsNavigator(val nav: DestinationsNavigator)
, made my Home screen'sDestinationsNavHost(.. dependenciesContainerBuilder = { dependency(ParentDestinationsNavigator(destinationsNavigator))})
and my Profile screen constructor isclass Profile(nav: ParentDestinationsNavigator)
but would have rather had something likeclass Profile(@Named("root") nav: DestinationsNavigator)
so that the correctDestinationsNavigator
is always addressedperhaps I'm missing a more obvious solution to my requirement
The text was updated successfully, but these errors were encountered: