slovnicki / beamer

A routing package built on top of Router and Navigator's pages API, supporting arbitrary nested navigation, guards and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[QUESTION] How can I keep the bottom navigation bar for some pages which are not directly in the index stack

iammuho opened this issue · comments

Hey everyone,

First of all thank you a lot for this amazing package, it's so clear and work flawless. But I believe, I couldn't solve a problem.

Example I've copied: https://github.com/slovnicki/beamer/tree/master/examples/bottom_navigation_multiple_beamers

Let's assume, I've 2 pages in the bottom navigation bar and these pages lists books (imagine home page and discovery page) and when I go to book detail page from whichever I want to keep the active bottom index + bottom navigation in the book detail page.

As you can understand, books screen/location is not in the bottom bar.

If I need to make it much clear;

class AppLocationBuilder extends BeamLocation<BeamState> {
  AppLocationBuilder({RouteInformation? routeInformation})
      : super(routeInformation);
  @override
  List<String> get pathPatterns => ['/app'];

  @override
  List<BeamPage> buildPages(BuildContext context, BeamState state) {
    return [
      const BeamPage(
        key: ValueKey('app'),
        title: 'App',
        name: 'app',
        child: AppScreen(initialIndex: 0),
      ),
    ];
  }
}

and In the AppScreen;

final routerDelegates = [
    BeamerDelegate(
      initialPath: '/home',
      locationBuilder: (routeInformation, _) {
        if (routeInformation.location!.contains('topic')) {
          return TopicLocationBuilder(routeInformation: routeInformation);
        }
        return HomeLocationBuilder(routeInformation: routeInformation);
      },
    ),
    // Discover
    BeamerDelegate(
      initialPath: '/discover',
      locationBuilder: (routeInformation, _) {
        if (routeInformation.location!.contains('topic')) {
          return TopicLocationBuilder(routeInformation: routeInformation);
        }
        return DiscoverLocationBuilder(routeInformation: routeInformation);
      },
    ),

So how can I move forward with the books locations so when a user clicks books/detail/1 whichever the page, I'll keep the state and bottom bar.

best regards