forked from eatvio/eatvio_app
feat: Implement FeedScreen with dynamic content display, search functionality, and filtering options.
This commit is contained in:
@@ -72,7 +72,7 @@ class _FeedScreenContentState extends State<FeedScreenContent> {
|
||||
final consultantsScrollController = ScrollController();
|
||||
@override
|
||||
void initState() {
|
||||
chipsLabelList = hidePlans ? ['Все', 'Рецепты', 'Диеты', 'Консультанты'] : ['Все', 'Рецепты', 'Диеты', 'Планы питания', 'Консультанты'];
|
||||
chipsLabelList = hidePlans ? ['Все', 'Консультанты', 'Рецепты', 'Диеты'] : ['Все', 'Планы питания', 'Консультанты', 'Рецепты', 'Диеты'];
|
||||
consultantsScrollController.addListener(_onScrollConsultants);
|
||||
_checkRegistrationDate(context);
|
||||
// Инициализация глобальных кубитов при первом открытии экрана
|
||||
@@ -115,7 +115,7 @@ class _FeedScreenContentState extends State<FeedScreenContent> {
|
||||
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<FeedScreenContent> {
|
||||
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<FeedScreenContent> {
|
||||
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<FeedScreenContent> {
|
||||
case 0:
|
||||
context.read<FeedCubit>().loadFeedBlogPostList(query: query);
|
||||
break;
|
||||
case 1:
|
||||
context.read<RecipesCubit>().loadRecipesList(query: query);
|
||||
break;
|
||||
case 2:
|
||||
context.read<DietsCubit>().loadDiets(query: query);
|
||||
break;
|
||||
case 3 when !hidePlans:
|
||||
case 1 when !hidePlans:
|
||||
context.read<PlansCubit>().loadPlans(query: query);
|
||||
break;
|
||||
case 1 when hidePlans:
|
||||
case 2 when !hidePlans:
|
||||
context.read<ConsultantsCubit>().getConsultants();
|
||||
break;
|
||||
case 2 when hidePlans:
|
||||
case 3 when !hidePlans:
|
||||
context.read<RecipesCubit>().loadRecipesList(query: query);
|
||||
break;
|
||||
case 3 when hidePlans:
|
||||
case 4 when !hidePlans:
|
||||
context.read<ConsultantsCubit>().getConsultants();
|
||||
context.read<DietsCubit>().loadDiets(query: query);
|
||||
break;
|
||||
}
|
||||
});
|
||||
@@ -208,18 +214,20 @@ class _FeedScreenContentState extends State<FeedScreenContent> {
|
||||
case 0:
|
||||
context.read<FeedCubit>().loadFeedBlogPostList();
|
||||
break;
|
||||
case 1:
|
||||
context.read<RecipesCubit>().loadRecipesList();
|
||||
break;
|
||||
case 2:
|
||||
context.read<DietsCubit>().loadDiets();
|
||||
break;
|
||||
case 3 when !hidePlans:
|
||||
case 1 when !hidePlans:
|
||||
context.read<PlansCubit>().loadPlans();
|
||||
break;
|
||||
case 1 when hidePlans:
|
||||
case 2 when !hidePlans:
|
||||
context.read<ConsultantsCubit>().getConsultants();
|
||||
break;
|
||||
case 2 when hidePlans:
|
||||
case 3 when !hidePlans:
|
||||
context.read<RecipesCubit>().loadRecipesList();
|
||||
break;
|
||||
case 3 when hidePlans:
|
||||
case 4 when !hidePlans:
|
||||
context.read<ConsultantsCubit>().getConsultants();
|
||||
context.read<DietsCubit>().loadDiets();
|
||||
break;
|
||||
}
|
||||
});
|
||||
@@ -228,18 +236,28 @@ class _FeedScreenContentState extends State<FeedScreenContent> {
|
||||
),
|
||||
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<FeedScreenContent> {
|
||||
},
|
||||
body: switch (_selectedChipIndex) {
|
||||
0 => BlogPosts(handleVisibility: context.read<ViewsCubit>().handleVisibility),
|
||||
1 => Recipes(handleVisibility: context.read<ViewsCubit>().handleVisibility),
|
||||
2 => Diets(handleVisibility: context.read<ViewsCubit>().handleVisibility),
|
||||
3 when !hidePlans => Plans(handleVisibility: context.read<ViewsCubit>().handleVisibility),
|
||||
3 when hidePlans => const Consultants(),
|
||||
4 when !hidePlans => const Consultants(),
|
||||
1 when !hidePlans => Plans(handleVisibility: context.read<ViewsCubit>().handleVisibility),
|
||||
1 when hidePlans => const Consultants(),
|
||||
2 when !hidePlans => const Consultants(),
|
||||
2 when hidePlans => Recipes(handleVisibility: context.read<ViewsCubit>().handleVisibility),
|
||||
3 when !hidePlans => Recipes(handleVisibility: context.read<ViewsCubit>().handleVisibility),
|
||||
3 when hidePlans => Diets(handleVisibility: context.read<ViewsCubit>().handleVisibility),
|
||||
4 when !hidePlans => Diets(handleVisibility: context.read<ViewsCubit>().handleVisibility),
|
||||
_ => Center(child: Text(chipsLabelList[_selectedChipIndex])),
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user