lulupointu / vrouter

MIT License
202 stars 39 forks source link

VNester inside stacked routes #215

Open alhamed1 opened 1 year ago

alhamed1 commented 1 year ago

I work on an app with a main menu with nested navigation, and in the drawer, I have some routes which I want to be stacked, each one might have nested routes also, but given the routes blew I can't navigate to the accountStatement route.

final guardedRoutes = [
  VNester(
    path: "/",
    widgetBuilder: (child) {
      return RootLayout(
        child: child,
      );
    },
    nestedRoutes: mainRoutes.children
        .map(
          (e) => VWidget(
            buildTransition: (animation, secondaryAnimation, child) =>
                FadeTransition(
              opacity: animation,
              child: child,
            ),
            path: e.value!.route,
            widget: e.value!.child,
          ),
        )
        .toList(),
    stackedRoutes: mainChildren,
  ),
];

final mainChildren = [
  VNester(
    path: AccountStatementPage.route,
    aliases: [
      AccountStatementPage.route,
      AccountStatementPage.route.substring(1),
    ],
    widgetBuilder: (child) {
      return AccountStatementPage(
        child: child,
      );
    },
    nestedRoutes: mainRoutes.children
        .map(
          (e) => VWidget(
            buildTransition: (animation, secondaryAnimation, child) =>
                FadeTransition(
              opacity: animation,
              child: child,
            ),
            path: e.value!.route,
            widget: e.value!.child,
          ),
        )
        .toList(),
  ),
];

examples: / => overview - nested 1 /bookmarks - nested 2 /accountStatement - stacked nested 1 ---> Gives error /accountStatement/preview - stacked nested 2

lulupointu commented 1 year ago

Your code structure is a bit hard to understand since everything is extracted. Could you provide a small reproducible example?