diff --git a/lib/features/feed/presentation/pages/feed_screen.dart b/lib/features/feed/presentation/pages/feed_screen.dart index 408f00c4..cdeac843 100644 --- a/lib/features/feed/presentation/pages/feed_screen.dart +++ b/lib/features/feed/presentation/pages/feed_screen.dart @@ -72,7 +72,7 @@ class _FeedScreenContentState extends State { final consultantsScrollController = ScrollController(); @override void initState() { - chipsLabelList = hidePlans ? ['Все', 'Рецепты', 'Диеты', 'Консультанты'] : ['Все', 'Рецепты', 'Диеты', 'Планы питания', 'Консультанты']; + chipsLabelList = hidePlans ? ['Все', 'Консультанты', 'Рецепты', 'Диеты'] : ['Все', 'Планы питания', 'Консультанты', 'Рецепты', 'Диеты']; consultantsScrollController.addListener(_onScrollConsultants); _checkRegistrationDate(context); // Инициализация глобальных кубитов при первом открытии экрана @@ -115,7 +115,7 @@ class _FeedScreenContentState extends State { Widget build(BuildContext context) { FlutterNativeSplash.remove(); return Scaffold( - floatingActionButton: _selectedChipIndex == 1 + floatingActionButton: ((_selectedChipIndex == 2 && hidePlans) || (_selectedChipIndex == 3 && !hidePlans)) ? FloatingActionButton.small( heroTag: 'recipesTagsFilter', backgroundColor: appTheme.blueA400, @@ -137,11 +137,13 @@ class _FeedScreenContentState extends State { body: NestedScrollView( controller: switch (_selectedChipIndex) { 0 => blogPostsScrollController, - 1 => recipesScrollController, - 2 => dietsScrollController, - 3 when !hidePlans => plansScrollController, - 3 when hidePlans => consultantsScrollController, - 4 when !hidePlans => consultantsScrollController, + 1 when !hidePlans => plansScrollController, + 1 when hidePlans => consultantsScrollController, + 2 when !hidePlans => consultantsScrollController, + 2 when hidePlans => recipesScrollController, + 3 when !hidePlans => recipesScrollController, + 3 when hidePlans => dietsScrollController, + 4 when !hidePlans => dietsScrollController, _ => blogPostsScrollController, }, headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { @@ -173,11 +175,13 @@ class _FeedScreenContentState extends State { children: [ CustomSearchBar( searchController: switch (_selectedChipIndex) { - 1 => recipesController, - 2 => dietsController, - 3 when !hidePlans => plansController, - 3 when hidePlans => consultantsController, - 4 when !hidePlans => consultantsController, + 1 when !hidePlans => plansController, + 1 when hidePlans => consultantsController, + 2 when !hidePlans => consultantsController, + 2 when hidePlans => recipesController, + 3 when !hidePlans => recipesController, + 3 when hidePlans => dietsController, + 4 when !hidePlans => dietsController, _ => postsController, }, onChanged: (query) { @@ -187,18 +191,20 @@ class _FeedScreenContentState extends State { case 0: context.read().loadFeedBlogPostList(query: query); break; - case 1: - context.read().loadRecipesList(query: query); - break; - case 2: - context.read().loadDiets(query: query); - break; - case 3 when !hidePlans: + case 1 when !hidePlans: context.read().loadPlans(query: query); break; + case 1 when hidePlans: + case 2 when !hidePlans: + context.read().getConsultants(); + break; + case 2 when hidePlans: + case 3 when !hidePlans: + context.read().loadRecipesList(query: query); + break; case 3 when hidePlans: case 4 when !hidePlans: - context.read().getConsultants(); + context.read().loadDiets(query: query); break; } }); @@ -208,18 +214,20 @@ class _FeedScreenContentState extends State { case 0: context.read().loadFeedBlogPostList(); break; - case 1: - context.read().loadRecipesList(); - break; - case 2: - context.read().loadDiets(); - break; - case 3 when !hidePlans: + case 1 when !hidePlans: context.read().loadPlans(); break; + case 1 when hidePlans: + case 2 when !hidePlans: + context.read().getConsultants(); + break; + case 2 when hidePlans: + case 3 when !hidePlans: + context.read().loadRecipesList(); + break; case 3 when hidePlans: case 4 when !hidePlans: - context.read().getConsultants(); + context.read().loadDiets(); break; } }); @@ -228,18 +236,28 @@ class _FeedScreenContentState extends State { ), const SizedBox(width: 12), switch (_selectedChipIndex) { - 1 => AddItemButton( + 1 when !hidePlans => AddItemButton( + onTap: state.profile?.roles.contains('consultant') ?? false ? () => GoRouter.of(context).pushNamed(CreatePlanScreen.name) : null, + ), + 2 when hidePlans => AddItemButton( onTap: state.profile?.roles.contains('consultant') ?? false ? () => GoRouter.of(context).pushNamed(RecipeCreateScreen.name) : null, ), - 2 => AddItemButton( + 3 when !hidePlans => AddItemButton( + onTap: state.profile?.roles.contains('consultant') ?? false ? () => GoRouter.of(context).pushNamed(RecipeCreateScreen.name) : null, + ), + 3 when hidePlans => AddItemButton( onTap: state.profile?.roles.contains('consultant') ?? false ? () async { await GoRouter.of(context).pushNamed(CreateDietScreen.name); } : null, ), - 3 when !hidePlans => AddItemButton( - onTap: state.profile?.roles.contains('consultant') ?? false ? () => GoRouter.of(context).pushNamed(CreatePlanScreen.name) : null, + 4 when !hidePlans => AddItemButton( + onTap: state.profile?.roles.contains('consultant') ?? false + ? () async { + await GoRouter.of(context).pushNamed(CreateDietScreen.name); + } + : null, ), _ => const AddItemButton(key: AppKeys.feedScreenBlogPostCreationButton), }, @@ -252,11 +270,13 @@ class _FeedScreenContentState extends State { }, body: switch (_selectedChipIndex) { 0 => BlogPosts(handleVisibility: context.read().handleVisibility), - 1 => Recipes(handleVisibility: context.read().handleVisibility), - 2 => Diets(handleVisibility: context.read().handleVisibility), - 3 when !hidePlans => Plans(handleVisibility: context.read().handleVisibility), - 3 when hidePlans => const Consultants(), - 4 when !hidePlans => const Consultants(), + 1 when !hidePlans => Plans(handleVisibility: context.read().handleVisibility), + 1 when hidePlans => const Consultants(), + 2 when !hidePlans => const Consultants(), + 2 when hidePlans => Recipes(handleVisibility: context.read().handleVisibility), + 3 when !hidePlans => Recipes(handleVisibility: context.read().handleVisibility), + 3 when hidePlans => Diets(handleVisibility: context.read().handleVisibility), + 4 when !hidePlans => Diets(handleVisibility: context.read().handleVisibility), _ => Center(child: Text(chipsLabelList[_selectedChipIndex])), }, ),