@@ -549,6 +549,194 @@ GoRouter createRouter({
549549 // the FeedSliverAppBar, so it is no longer a main navigation branch.
550550 // Its sub-routes (Settings, Saved Items, etc.) are now defined as
551551 // 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;
572+
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,
593+ );
594+ },
595+ routes: [
596+ GoRoute (
597+ path: Routes .settings,
598+ name: Routes .settingsName,
599+ builder: (context, state) => const SettingsPage (),
600+ routes: [
601+ 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,
630+ builder: (context, state) =>
631+ const NotificationSettingsPage (),
632+ ),
633+ GoRoute (
634+ path: Routes .settingsLanguage,
635+ name: Routes .settingsLanguageName,
636+ builder: (context, state) =>
637+ const LanguageSettingsPage (),
638+ ),
639+ ],
640+ ),
641+ ],
642+ ),
643+ GoRoute (
644+ path: Routes .manageFollowedItems,
645+ name: Routes .manageFollowedItemsName,
646+ builder: (context, state) =>
647+ const ManageFollowedItemsPage (),
648+ routes: [
649+ GoRoute (
650+ path: Routes .followedTopicsList,
651+ name: Routes .followedTopicsListName,
652+ 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+ ],
676+ ),
677+ GoRoute (
678+ path: Routes .followedCountriesList,
679+ name: Routes .followedCountriesListName,
680+ 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+ ],
690+ ),
691+ ],
692+ ),
693+ GoRoute (
694+ path: Routes .accountSavedHeadlines,
695+ name: Routes .accountSavedHeadlinesName,
696+ builder: (context, state) {
697+ return const SavedHeadlinesPage ();
698+ },
699+ routes: [
700+ 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+ },
728+ ),
729+ ],
730+ ),
731+ GoRoute (
732+ path: Routes .accountSavedFilters,
733+ name: Routes .accountSavedFiltersName,
734+ builder: (context, state) => const SavedFiltersPage (),
735+ ),
736+ ],
737+ ),
738+ ],
739+ ),
552740 ],
553741 ),
554742 ],
0 commit comments