Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Implement tabs using a separate [GoRouter] instance for each tab #25

Closed
DMouayad opened this issue Oct 2, 2023 · 2 comments · Fixed by #31
Closed

Implement tabs using a separate [GoRouter] instance for each tab #25

DMouayad opened this issue Oct 2, 2023 · 2 comments · Fixed by #31
Assignees
Labels
enhancement New feature or request

Comments

@DMouayad
Copy link
Owner

DMouayad commented Oct 2, 2023

What we're trying to accomplish: to have a separate GoRouter for each tab.
Reason:

  • Simplify navigation in each tab.
  • Add a new tab without changing the router config.
@DMouayad DMouayad added the enhancement New feature or request label Oct 2, 2023
@DMouayad DMouayad added the help wanted Extra attention is needed label Oct 4, 2023
@DMouayad
Copy link
Owner Author

DMouayad commented Oct 4, 2023

First try:

  • created primary(app-level) GoRouter with the following config:
  GoRouter(
      debugLogDiagnostics: kIsDebug,
      navigatorKey: _rootNavigatorKey,
      initialLocation: '/',
      routes: [
        GoRoute(
          path: '/',
          name: 'Home',
          builder: (context, state) => const WideHomeScreen(),
          routes: [
            ExplorePageRoute(),
            ListeningHistoryPageRoute(),
            LibraryAlbumsPageRoute(),
            LibraryTracksPageRoute(),
            LibraryArtistsPageRoute(),
            LibraryFoldersPageRoute(),
            ExploreMusicCategoryPageRoute(),
            ArtistPageRoute(),
            AlbumPageRoute(),
            PlaylistPageRoute(),
          ],
        ),
        DesktopSplashScreenRoute(),
      ],
    );

where in the WideHomeScreen body will have:

  
    PageView.builder(
      itemCount: tabsCount,
      itemBuilder: (context, index) {
        return Router.withConfig(config: tabRouter);
      },
    );

@DMouayad
Copy link
Owner Author

DMouayad commented Oct 5, 2023

Additional steps:

  • create a PageController to specify current tab.
  • Update (vertical&horizontal)tab's title based on current location.
  • update routers when re-ordering tabs.
  • Add unit tests for TabsState.
  • Add unit tests for TabsHelper.
  • Add widget tests for VerticalTabs and HorizontalTabs

@DMouayad DMouayad removed the help wanted Extra attention is needed label Oct 7, 2023
@DMouayad DMouayad self-assigned this Oct 7, 2023
@DMouayad DMouayad linked a pull request Oct 17, 2023 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant