@@ -532,209 +532,189 @@ GoRouter createRouter({
532532 ),
533533 ],
534534 ),
535- ],
536- ),
537- // --- Branch 2: Discover ---
538- StatefulShellBranch (
539- routes: [
540- GoRoute (
541- path: Routes .discover,
542- name: Routes .discoverName,
543- builder: (context, state) => const DiscoverPage (),
544- ),
545- ],
546- ),
547- // --- Branch 3: Account (REMOVED) ---
548- // The Account page is now accessed via a modal bottom sheet from
549- // the FeedSliverAppBar, so it is no longer a main navigation branch.
550- // Its sub-routes (Settings, Saved Items, etc.) are now defined as
551- // top-level routes to be pushed from the modal sheet.
552- StatefulShellBranch (
553- routes: [
554- // This GoRoute is a placeholder to keep the shell branch valid
555- // while allowing its sub-routes to be defined. The path will
556- // never be directly navigated to.
557- GoRoute (
558- path: Routes .account,
559- name: Routes .accountName,
560- builder: (context, state) => const SizedBox .shrink (),
561- routes: [
562- // ShellRoute for settings to provide SettingsBloc to children
563- ShellRoute (
564- builder:
565- (
566- BuildContext context,
567- GoRouterState state,
568- Widget child,
569- ) {
570- final appBloc = context.read <AppBloc >();
571- final userId = appBloc.state.user? .id;
535+ // --- Account-related routes (Nested under Feed) ---
536+ // These routes are for pages launched from the AccountSheet, which
537+ // is shown from the Feed page. Nesting them here ensures that
538+ // go_router can navigate correctly from a context within the
539+ // first shell branch.
572540
573- return BlocProvider <SettingsBloc >(
574- create: (context) {
575- final settingsBloc = SettingsBloc (
576- userAppSettingsRepository: context
577- .read <DataRepository <UserAppSettings >>(),
578- inlineAdCacheService: inlineAdCacheService,
579- );
580- if (userId != null ) {
581- settingsBloc.add (
582- SettingsLoadRequested (userId: userId),
583- );
584- } else {
585- logger.warning (
586- 'User ID is null when creating SettingsBloc. '
587- 'Settings will not be loaded.' ,
588- );
589- }
590- return settingsBloc;
591- },
592- child: child,
541+ // ShellRoute for settings to provide SettingsBloc to children
542+ ShellRoute (
543+ builder:
544+ (BuildContext context, GoRouterState state, Widget child) {
545+ final appBloc = context.read <AppBloc >();
546+ final userId = appBloc.state.user? .id;
547+
548+ return BlocProvider <SettingsBloc >(
549+ create: (context) {
550+ final settingsBloc = SettingsBloc (
551+ userAppSettingsRepository: context
552+ .read <DataRepository <UserAppSettings >>(),
553+ inlineAdCacheService: inlineAdCacheService,
593554 );
555+ if (userId != null ) {
556+ settingsBloc.add (
557+ SettingsLoadRequested (userId: userId),
558+ );
559+ } else {
560+ logger.warning (
561+ 'User ID is null when creating SettingsBloc. '
562+ 'Settings will not be loaded.' ,
563+ );
564+ }
565+ return settingsBloc;
594566 },
567+ child: child,
568+ );
569+ },
570+ routes: [
571+ GoRoute (
572+ path: Routes .settings,
573+ name: Routes .settingsName,
574+ builder: (context, state) => const SettingsPage (),
595575 routes: [
596576 GoRoute (
597- path: Routes .settings,
598- name: Routes .settingsName,
599- builder: (context, state) => const SettingsPage (),
577+ path: Routes .settingsAppearance,
578+ name: Routes .settingsAppearanceName,
579+ builder: (context, state) =>
580+ const AppearanceSettingsPage (),
600581 routes: [
601582 GoRoute (
602- path: Routes .settingsAppearance,
603- name: Routes .settingsAppearanceName,
604- builder: (context, state) =>
605- const AppearanceSettingsPage (),
606- routes: [
607- GoRoute (
608- path: Routes .settingsAppearanceTheme,
609- name: Routes .settingsAppearanceThemeName,
610- builder: (context, state) =>
611- const ThemeSettingsPage (),
612- ),
613- GoRoute (
614- path: Routes .settingsAppearanceFont,
615- name: Routes .settingsAppearanceFontName,
616- builder: (context, state) =>
617- const FontSettingsPage (),
618- ),
619- ],
620- ),
621- GoRoute (
622- path: Routes .settingsFeed,
623- name: Routes .settingsFeedName,
624- builder: (context, state) =>
625- const FeedSettingsPage (),
626- ),
627- GoRoute (
628- path: Routes .settingsNotifications,
629- name: Routes .settingsNotificationsName,
583+ path: Routes .settingsAppearanceTheme,
584+ name: Routes .settingsAppearanceThemeName,
630585 builder: (context, state) =>
631- const NotificationSettingsPage (),
586+ const ThemeSettingsPage (),
632587 ),
633588 GoRoute (
634- path: Routes .settingsLanguage ,
635- name: Routes .settingsLanguageName ,
589+ path: Routes .settingsAppearanceFont ,
590+ name: Routes .settingsAppearanceFontName ,
636591 builder: (context, state) =>
637- const LanguageSettingsPage (),
592+ const FontSettingsPage (),
638593 ),
639594 ],
640595 ),
596+ GoRoute (
597+ path: Routes .settingsFeed,
598+ name: Routes .settingsFeedName,
599+ builder: (context, state) => const FeedSettingsPage (),
600+ ),
601+ GoRoute (
602+ path: Routes .settingsNotifications,
603+ name: Routes .settingsNotificationsName,
604+ builder: (context, state) =>
605+ const NotificationSettingsPage (),
606+ ),
607+ GoRoute (
608+ path: Routes .settingsLanguage,
609+ name: Routes .settingsLanguageName,
610+ builder: (context, state) =>
611+ const LanguageSettingsPage (),
612+ ),
641613 ],
642614 ),
615+ ],
616+ ),
617+ GoRoute (
618+ path: Routes .manageFollowedItems,
619+ name: Routes .manageFollowedItemsName,
620+ builder: (context, state) => const ManageFollowedItemsPage (),
621+ routes: [
643622 GoRoute (
644- path: Routes .manageFollowedItems,
645- name: Routes .manageFollowedItemsName,
646- builder: (context, state) =>
647- const ManageFollowedItemsPage (),
623+ path: Routes .followedTopicsList,
624+ name: Routes .followedTopicsListName,
625+ builder: (context, state) => const FollowedTopicsListPage (),
648626 routes: [
649627 GoRoute (
650- path: Routes .followedTopicsList ,
651- name: Routes .followedTopicsListName ,
628+ path: Routes .addTopicToFollow ,
629+ name: Routes .addTopicToFollowName ,
652630 builder: (context, state) =>
653- const FollowedTopicsListPage (),
654- routes: [
655- GoRoute (
656- path: Routes .addTopicToFollow,
657- name: Routes .addTopicToFollowName,
658- builder: (context, state) =>
659- const AddTopicToFollowPage (),
660- ),
661- ],
662- ),
663- GoRoute (
664- path: Routes .followedSourcesList,
665- name: Routes .followedSourcesListName,
666- builder: (context, state) =>
667- const FollowedSourcesListPage (),
668- routes: [
669- GoRoute (
670- path: Routes .addSourceToFollow,
671- name: Routes .addSourceToFollowName,
672- builder: (context, state) =>
673- const AddSourceToFollowPage (),
674- ),
675- ],
631+ const AddTopicToFollowPage (),
676632 ),
633+ ],
634+ ),
635+ GoRoute (
636+ path: Routes .followedSourcesList,
637+ name: Routes .followedSourcesListName,
638+ builder: (context, state) =>
639+ const FollowedSourcesListPage (),
640+ routes: [
677641 GoRoute (
678- path: Routes .followedCountriesList ,
679- name: Routes .followedCountriesListName ,
642+ path: Routes .addSourceToFollow ,
643+ name: Routes .addSourceToFollowName ,
680644 builder: (context, state) =>
681- const FollowedCountriesListPage (),
682- routes: [
683- GoRoute (
684- path: Routes .addCountryToFollow,
685- name: Routes .addCountryToFollowName,
686- builder: (context, state) =>
687- const AddCountryToFollowPage (),
688- ),
689- ],
645+ const AddSourceToFollowPage (),
690646 ),
691647 ],
692648 ),
693649 GoRoute (
694- path: Routes .accountSavedHeadlines,
695- name: Routes .accountSavedHeadlinesName,
696- builder: (context, state) {
697- return const SavedHeadlinesPage ();
698- },
650+ path: Routes .followedCountriesList,
651+ name: Routes .followedCountriesListName,
652+ builder: (context, state) =>
653+ const FollowedCountriesListPage (),
699654 routes: [
700655 GoRoute (
701- path: Routes .accountArticleDetails,
702- name: Routes .accountArticleDetailsName,
703- builder: (context, state) {
704- final headlineFromExtra = state.extra as Headline ? ;
705- final headlineIdFromPath = state.pathParameters['id' ];
706- return MultiBlocProvider (
707- providers: [
708- BlocProvider (
709- create: (context) => HeadlineDetailsBloc (
710- headlinesRepository: context
711- .read <DataRepository <Headline >>(),
712- ),
713- ),
714- BlocProvider (
715- create: (context) => SimilarHeadlinesBloc (
716- headlinesRepository: context
717- .read <DataRepository <Headline >>(),
718- ),
719- ),
720- ],
721- child: HeadlineDetailsPage (
722- initialHeadline: headlineFromExtra,
723- headlineId:
724- headlineFromExtra? .id ?? headlineIdFromPath,
725- ),
726- );
727- },
656+ path: Routes .addCountryToFollow,
657+ name: Routes .addCountryToFollowName,
658+ builder: (context, state) =>
659+ const AddCountryToFollowPage (),
728660 ),
729661 ],
730662 ),
663+ ],
664+ ),
665+ GoRoute (
666+ path: Routes .accountSavedHeadlines,
667+ name: Routes .accountSavedHeadlinesName,
668+ builder: (context, state) {
669+ return const SavedHeadlinesPage ();
670+ },
671+ routes: [
731672 GoRoute (
732- path: Routes .accountSavedFilters,
733- name: Routes .accountSavedFiltersName,
734- builder: (context, state) => const SavedFiltersPage (),
673+ path: Routes .accountArticleDetails,
674+ name: Routes .accountArticleDetailsName,
675+ builder: (context, state) {
676+ final headlineFromExtra = state.extra as Headline ? ;
677+ final headlineIdFromPath = state.pathParameters['id' ];
678+ return MultiBlocProvider (
679+ providers: [
680+ BlocProvider (
681+ create: (context) => HeadlineDetailsBloc (
682+ headlinesRepository: context
683+ .read <DataRepository <Headline >>(),
684+ ),
685+ ),
686+ BlocProvider (
687+ create: (context) => SimilarHeadlinesBloc (
688+ headlinesRepository: context
689+ .read <DataRepository <Headline >>(),
690+ ),
691+ ),
692+ ],
693+ child: HeadlineDetailsPage (
694+ initialHeadline: headlineFromExtra,
695+ headlineId:
696+ headlineFromExtra? .id ?? headlineIdFromPath,
697+ ),
698+ );
699+ },
735700 ),
736701 ],
737702 ),
703+ GoRoute (
704+ path: Routes .accountSavedFilters,
705+ name: Routes .accountSavedFiltersName,
706+ builder: (context, state) => const SavedFiltersPage (),
707+ ),
708+ ],
709+ ),
710+ // --- Branch 2: Discover ---
711+ StatefulShellBranch (
712+ routes: [
713+ GoRoute (
714+ path: Routes .discover,
715+ name: Routes .discoverName,
716+ builder: (context, state) => const DiscoverPage (),
717+ ),
738718 ],
739719 ),
740720 ],
0 commit comments