auto_route_library icon indicating copy to clipboard operation
auto_route_library copied to clipboard

common route to all nested nav graphs

Open rubinbasha opened this issue 1 year ago • 7 comments

I am using a AutoTabsScaffold in my home screen of my app. I have used this way to define nested navigation graphs @RoutePage(name: 'FavoritesRouter') class FavoritesRouterPage extends AutoRouter {} I have 5 such graphs and 4 have the possibility to navigate to a new route that is common to the 4 of them.

I have done such definition to all my 4 nested routers: AutoRoute( page: FavoritesRouter.page, children: [ AutoRoute( initial: true, page: FavoritesScreenRoute.page, ), AutoRoute( page: DetailsScreenRoute.page, ), ], ),

Keep in mind I had to declare the DetailsScreenRoute 4 times and I would like to have a way to not do that and just be able to navigate to DetailsScreenRoute and additionally to still have multiple backstacks. I hope this is understandable and reasonable. Looking forward to your feedback

rubinbasha avatar Aug 23 '23 09:08 rubinbasha

Hey @rubinbasha is there a reason why can't DetailsScreenRoute be a root route?

Milad-Akarie avatar Aug 23 '23 09:08 Milad-Akarie

My reason would be that DetailsScreenRoute must still be shown with the Bottom navigation bar visible below it and the tab that started the whole interaction must still be selected. In this case adding just one DetailsScreenRoute to every nested router is feasible, but it might become cumbersome once we add whole flows that can be shared between tabs

rubinbasha avatar Aug 23 '23 09:08 rubinbasha

@rubinbasha where do you imagine declaring such a dynamic route would be? pre-defined graphs allow deep linking to work without any issues, it also helps auto-route automatically find the scope where the target route should go.

This is not the first time we have discussed this use-case here but still, I can't figure out how this would work out.

maybe there should be a way to define a certain route as dynamic ( does not belong to a certain scope ) and have it always be declared in root-level, and users have to manually chose what scope this route goes in in run-time e.g AutoRouter.innerRouterOf(context, FirstTabe.name).push(DynamicRoute());

or have automatically pushed to the nearest scope

Milad-Akarie avatar Aug 23 '23 10:08 Milad-Akarie

I would yes put it in the root level or also something like AutoRoute( path: "/home", page: HomeScreenRoute.page, children: [ tabRoutes ], commonRoutes: [ ] As for scope finding I would just prefer the nearest scope to be automatically used , with the option to define another scope if wanted.

rubinbasha avatar Aug 23 '23 10:08 rubinbasha

@rubinbasha I'll give this more thought and see what I can do, I might end up using an exclusive method for pushing non-scoped routes.

Milad-Akarie avatar Aug 23 '23 10:08 Milad-Akarie

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar Nov 11 '23 08:11 github-actions[bot]

@Milad-Akarie any more thoughts on this? I also have this need for an app. If you need an example it should look to the end users. Think of how X, and Facebook flow. You have posts on the home tab but seen from the notification tab and the profile view via a drawer.

rlee1990 avatar Dec 20 '23 21:12 rlee1990