Milad-Akarie / auto_route_library

Flutter route generator
MIT License
1.59k stars 403 forks source link

Documentation about nested navigation via clicks inside a AutoTabsScaffold ? #941

Closed RageshAntony closed 2 years ago

RageshAntony commented 2 years ago

In an AutoTabsScaffold , how to do nested navigation and pass arguments ?

For example,

AutoTabsScaffold(
        routes:  [
          A(args),
          B(args),
          C(args),
          D(args)
        ],

Now in any one of the 4 rtab outes , how to navigate to it's children with arguments passing ?

Such as ,

A <=> A1 (arg) <=> A2 (arg) <=> A3(arg) B <=> B1 (arg) <=> B2 (arg) <=> B3(arg)

There is no docs about complex manual nested navigation . only about some NavLink widgets that looks like another tabs !!! ..

2) How to pass args to EmptyRouterPage's initial children ?

 AutoRoute(
            page: EmptyRouterPage,
            children: [
          AutoRoute(page: NotificationsView,initial: true,), // need to pass a Class object here ex:  NotificationsView({ this.cable});
          AutoRoute(page: InfoView),
          AutoRoute(page: NavView),

        ]),

Callng it in an AutoTabsScaffold


        routes:  [
          HomeMainViewRoute(cable: cable),
          ListsViewRoute(cable: cable),
          EmptyRouterPageRoute(), , // need to pass a Class object here to its initial child
          SettingsViewRoute(cable: cable)
        ],
RageshAntony commented 2 years ago

@Milad-Akarie please help me ... Sorry it's urgent . In a confusion

Milad-Akarie commented 2 years ago

@RageshAntony replace empty router page with your own regular flutter widget with whatever constructor arguments and have it return an AutoRouter() widget eventually

RageshAntony commented 2 years ago

@RageshAntony replace empty router page with your own regular flutter widget with whatever constructor arguments and have it return an AutoRouter() widget eventually

Please provide an example?

percula commented 2 years ago

I would also appreciate a more complex and working example. I have bottom navigation, with my app structure something like:

BottomNavigationBar: -AList --ADetail ---AMoreDetails -BList --BDetail -C -D

The problem I ran into was routing from "BDetail" to "ADetail". It added "AList" into the stack, so instead of going back to "BDetail" on back press, it went to "AList". In addition, the state from the last "ADetail" I viewed would persist, so when I went: BList > BDetail > ADetail > Back to BDetail > AList ...the "AList" would actually be showing the "ADetail" that I previously viewed, even though it was popped (I believe) AND I told AutoRoute not to maintain state.

I tried fixing this by making a copy of "ADetail" and its children under "BDetail", but I kept running into errors saying that the parent route wasn't added.

Anyway, if you can add a complex example like this, it would be very appreciated. The two examples provided are very basic and not much help past the initial setup of the bottom navigation bar and main pages. I ended up changing over to Beamer, but if AutoRoute can actually do this, I'd certainly resurrect that branch since it's much simpler.

RageshAntony commented 2 years ago

@Milad-Akarie How to refresh each bottomnav tabs when switching them to it ? That is is there any listeners exists ?

something Like ....

autotabs.onBottomNavSwitched((index) { .... });

Babwenbiber commented 2 years ago

You can use the onTap of your bottomnavbar:

onTap: (int index) async {
  if (tabsRouter.activeIndex == index) {
    //todo: implement
  } else {
    //todo: implement
  }
  tabsRouter.setActiveIndex(index);
}

You should have the tabsRouter from the AutoTabsScaffold.bottomNavigatorBuilder

github-actions[bot] commented 2 years ago

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