From d040f9497924e3fd7d74c52a503df9007c997442 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 30 Apr 2025 10:57:30 +0300 Subject: [PATCH 1/2] feat(recipes): custom popup for recipes --- lib/features/feed/presentation/widgets/recipes_widget.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/features/feed/presentation/widgets/recipes_widget.dart b/lib/features/feed/presentation/widgets/recipes_widget.dart index 2a586190..877aa19b 100644 --- a/lib/features/feed/presentation/widgets/recipes_widget.dart +++ b/lib/features/feed/presentation/widgets/recipes_widget.dart @@ -113,6 +113,7 @@ class _RecipesWidgetState extends State { size: 19, ), ), + // Testing Issue 329 Positioned( right: 12, top: 12, From 2ab148d0d0f32c64ee408d515fa3639d550ec6af Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 30 Apr 2025 17:26:34 +0300 Subject: [PATCH 2/2] feat(menu): add popup to recipe, diet, plan --- lib/core/widgets/custom_popup.dart | 11 +++++- .../presentation/pages/about_diet_screen.dart | 31 ++++----------- .../presentation/widgets/diets_widget.dart | 36 ++++++------------ .../presentation/widgets/plan_widget.dart | 38 +++++++------------ .../presentation/widgets/recipes_widget.dart | 36 ++++++------------ .../presentation/pages/about_plan_screen.dart | 31 ++++----------- .../presentation/about_recipe_screen.dart | 30 ++++++--------- 7 files changed, 74 insertions(+), 139 deletions(-) diff --git a/lib/core/widgets/custom_popup.dart b/lib/core/widgets/custom_popup.dart index 967f6fee..711995f2 100644 --- a/lib/core/widgets/custom_popup.dart +++ b/lib/core/widgets/custom_popup.dart @@ -90,10 +90,16 @@ class CustomPopup extends StatelessWidget { addItem('assets/icons/edit_paint.svg', 'Редактировать', () { if (complainedContentType == ComplainedContent.posts) { GoRouter.of(context).pushNamed('blogPostCreateScreen', extra: feedBlogPostModel); + } else { + showInfoToast('В разработке'); + return; } }); if (complainedContentType == ComplainedContent.plan || complainedContentType == ComplainedContent.diet) { - addItem('assets/icons/remove_from_public.svg', 'Снять с публикации', () {}); + addItem('assets/icons/remove_from_public.svg', 'Снять с публикации', () { + showInfoToast('В разработке'); + return; + }); } addItem('assets/icons/red_trash.svg', 'Удалить', () async { if (complainedContentType == ComplainedContent.posts) { @@ -104,6 +110,9 @@ class CustomPopup extends StatelessWidget { return; } context.read().loadFeedBlogPostList(); + } else { + showInfoToast('В разработке'); + return; } }); } else { diff --git a/lib/features/diets/presentation/pages/about_diet_screen.dart b/lib/features/diets/presentation/pages/about_diet_screen.dart index 0ca2c959..d4a07038 100644 --- a/lib/features/diets/presentation/pages/about_diet_screen.dart +++ b/lib/features/diets/presentation/pages/about_diet_screen.dart @@ -7,6 +7,7 @@ import 'package:eatvio_app/core/enums/product_type.dart'; import 'package:eatvio_app/core/utils/localization_utils.dart'; import 'package:eatvio_app/core/widgets/bookmark_button.dart'; import 'package:eatvio_app/core/widgets/custom_divider.dart'; +import 'package:eatvio_app/core/widgets/custom_popup.dart'; import 'package:eatvio_app/core/widgets/data_error_widget.dart'; import 'package:eatvio_app/core/widgets/info_row.dart'; import 'package:eatvio_app/core/widgets/loader.dart'; @@ -317,31 +318,13 @@ class _AboutDietScreenState extends State { style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black), ), actions: [ - PortalTarget( - visible: isMoreOptionsVisible, - portalFollower: MoreOptions( - path: 'diet/${widget.diet.id}', - complainedContentType: ComplainedContent.diet, - id: widget.diet.id, - ), - anchor: const Aligned( - shiftToWithinBound: AxisFlag(x: true, y: true), - follower: Alignment.topRight, - target: Alignment.bottomRight, - ), - child: IconButton( - onPressed: () { - setState(() { - isMoreOptionsVisible = !isMoreOptionsVisible; - }); - }, - icon: SvgPicture.asset( - 'assets/icons/more_button.svg', - width: 20, - height: 20, - ), - ), + CustomPopup( + isAuthor: widget.diet.author.authorIsMe, + path: 'diet/${widget.diet.id}', + complainedContentType: ComplainedContent.diet, + id: widget.diet.id, ), + const SizedBox(width: 16), ], ), body: SingleChildScrollView( diff --git a/lib/features/feed/presentation/widgets/diets_widget.dart b/lib/features/feed/presentation/widgets/diets_widget.dart index fa9dce69..87091ad8 100644 --- a/lib/features/feed/presentation/widgets/diets_widget.dart +++ b/lib/features/feed/presentation/widgets/diets_widget.dart @@ -3,9 +3,9 @@ import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/enums/product_type.dart'; import 'package:eatvio_app/core/widgets/bookmark_button.dart'; +import 'package:eatvio_app/core/widgets/custom_popup.dart'; import 'package:eatvio_app/core/widgets/info_row.dart'; import 'package:eatvio_app/core/widgets/feed_icon_button.dart'; -import 'package:eatvio_app/features/diets/presentation/widgets/more_options.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; @@ -13,7 +13,6 @@ import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_html/flutter_html.dart'; -import 'package:flutter_portal/flutter_portal.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; import 'package:share_plus/share_plus.dart'; @@ -83,28 +82,17 @@ class _DietsWidgetState extends State { Positioned( right: 12, top: 12, - child: PortalTarget( - visible: isMoreOptionsVisible, - portalFollower: MoreOptions( - path: 'diet/${widget.diet.id}', - complainedContentType: ComplainedContent.diet, - id: widget.diet.id, - ), - anchor: const Aligned(shiftToWithinBound: AxisFlag(x: true, y: true), follower: Alignment.topRight, target: Alignment.bottomRight), - child: InkWell( - onTap: () { - setState(() { - isMoreOptionsVisible = !isMoreOptionsVisible; - }); - }, - child: SizedBox( - width: 32, - height: 24, - child: Material( - color: Colors.white, - borderRadius: BorderRadius.circular(4), - child: const Icon(Icons.more_horiz), - ), + child: SizedBox( + width: 32, + height: 24, + child: Material( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + child: CustomPopup( + isAuthor: widget.diet.author.authorIsMe, + path: 'diet/${widget.diet.id}', + id: widget.diet.id, + complainedContentType: ComplainedContent.diet, ), ), ), diff --git a/lib/features/feed/presentation/widgets/plan_widget.dart b/lib/features/feed/presentation/widgets/plan_widget.dart index 2951d90a..608d647b 100644 --- a/lib/features/feed/presentation/widgets/plan_widget.dart +++ b/lib/features/feed/presentation/widgets/plan_widget.dart @@ -3,10 +3,10 @@ import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/enums/product_type.dart'; import 'package:eatvio_app/core/widgets/bookmark_button.dart'; +import 'package:eatvio_app/core/widgets/custom_popup.dart'; import 'package:eatvio_app/core/widgets/info_row.dart'; import 'package:eatvio_app/core/widgets/feed_icon_button.dart'; import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart'; -import 'package:eatvio_app/features/diets/presentation/widgets/more_options.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; @@ -16,7 +16,6 @@ import 'package:eatvio_app/generated/l10n.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_html/flutter_html.dart'; -import 'package:flutter_portal/flutter_portal.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; import 'package:share_plus/share_plus.dart'; @@ -24,6 +23,7 @@ import 'package:share_plus/share_plus.dart'; class PlanWidget extends StatefulWidget { final PlanModel plan; final int index; + const PlanWidget({ super.key, required this.plan, @@ -87,28 +87,18 @@ class _PlanWidgetState extends State { Positioned( right: 12, top: 12, - child: PortalTarget( - visible: isMoreOptionsVisible, - portalFollower: MoreOptions( - path: 'plan/${widget.plan.id}', - complainedContentType: ComplainedContent.plan, - id: widget.plan.id, - ), - anchor: const Aligned(shiftToWithinBound: AxisFlag(x: true, y: true), follower: Alignment.topRight, target: Alignment.bottomRight), - child: InkWell( - onTap: () { - setState(() { - isMoreOptionsVisible = !isMoreOptionsVisible; - }); - }, - child: SizedBox( - width: 32, - height: 24, - child: Material( - color: Colors.white, - borderRadius: BorderRadius.circular(4), - child: const Icon(Icons.more_horiz), - ), + child: SizedBox( + width: 32, + height: 24, + child: Material( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + child: CustomPopup( + isAuthor: widget.plan.author.authorIsMe, + path: 'plan/${widget.plan.id}', + id: widget.plan.id, + slug: widget.plan.slug, + complainedContentType: ComplainedContent.plan, ), ), ), diff --git a/lib/features/feed/presentation/widgets/recipes_widget.dart b/lib/features/feed/presentation/widgets/recipes_widget.dart index 877aa19b..39ca3ee1 100644 --- a/lib/features/feed/presentation/widgets/recipes_widget.dart +++ b/lib/features/feed/presentation/widgets/recipes_widget.dart @@ -6,8 +6,8 @@ import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/utils/localization_utils.dart'; import 'package:eatvio_app/core/widgets/bookmark_button.dart'; +import 'package:eatvio_app/core/widgets/custom_popup.dart'; import 'package:eatvio_app/core/widgets/feed_icon_button.dart'; -import 'package:eatvio_app/features/diets/presentation/widgets/more_options.dart'; import 'package:eatvio_app/features/feed/models/recipes_model.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart'; @@ -16,7 +16,6 @@ import 'package:eatvio_app/generated/l10n.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_html/flutter_html.dart'; -import 'package:flutter_portal/flutter_portal.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; import 'package:share_plus/share_plus.dart'; @@ -117,28 +116,17 @@ class _RecipesWidgetState extends State { Positioned( right: 12, top: 12, - child: PortalTarget( - visible: isMoreOptionsVisible, - portalFollower: MoreOptions( - complainedContentType: ComplainedContent.recipe, - path: 'recipe/${widget.recipe.slug}', - slug: widget.recipe.slug, - ), - anchor: const Aligned(shiftToWithinBound: AxisFlag(x: true, y: true), follower: Alignment.topRight, target: Alignment.bottomRight), - child: InkWell( - onTap: () { - setState(() { - isMoreOptionsVisible = !isMoreOptionsVisible; - }); - }, - child: SizedBox( - width: 32, - height: 24, - child: Material( - color: Colors.white, - borderRadius: BorderRadius.circular(4), - child: const Icon(Icons.more_horiz), - ), + child: SizedBox( + width: 32, + height: 24, + child: Material( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + child: CustomPopup( + isAuthor: widget.recipe.author.authorIsMe, + path: 'recipe/${widget.recipe.slug}', + slug: widget.recipe.slug, + complainedContentType: ComplainedContent.recipe, ), ), ), diff --git a/lib/features/plans/presentation/pages/about_plan_screen.dart b/lib/features/plans/presentation/pages/about_plan_screen.dart index 2935310f..c4958042 100644 --- a/lib/features/plans/presentation/pages/about_plan_screen.dart +++ b/lib/features/plans/presentation/pages/about_plan_screen.dart @@ -6,6 +6,7 @@ import 'package:eatvio_app/core/enums/complained_content.dart'; import 'package:eatvio_app/core/enums/product_type.dart'; import 'package:eatvio_app/core/utils/localization_utils.dart'; import 'package:eatvio_app/core/widgets/bookmark_button.dart'; +import 'package:eatvio_app/core/widgets/custom_popup.dart'; import 'package:eatvio_app/core/widgets/data_error_widget.dart'; import 'package:eatvio_app/core/widgets/info_row.dart'; import 'package:eatvio_app/core/widgets/loader.dart'; @@ -112,31 +113,13 @@ class _AboutPlanScreenState extends State { style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black), ), actions: [ - PortalTarget( - visible: isMoreOptionsVisible, - portalFollower: MoreOptions( - complainedContentType: ComplainedContent.plan, - path: 'plan/${widget.plan.id}', - slug: widget.plan.slug, - ), - anchor: const Aligned( - shiftToWithinBound: AxisFlag(x: true, y: true), - follower: Alignment.topRight, - target: Alignment.bottomRight, - ), - child: IconButton( - onPressed: () { - setState(() { - isMoreOptionsVisible = !isMoreOptionsVisible; - }); - }, - icon: SvgPicture.asset( - 'assets/icons/more_button.svg', - width: 20, - height: 20, - ), - ), + CustomPopup( + isAuthor: widget.plan.author.authorIsMe, + path: 'plan/${widget.plan.id}', + complainedContentType: ComplainedContent.plan, + slug: widget.plan.slug, ), + const SizedBox(width: 16), ], ), body: const Loader(), diff --git a/lib/features/recipe/presentation/about_recipe_screen.dart b/lib/features/recipe/presentation/about_recipe_screen.dart index 9139e094..cc65a0c2 100644 --- a/lib/features/recipe/presentation/about_recipe_screen.dart +++ b/lib/features/recipe/presentation/about_recipe_screen.dart @@ -8,6 +8,7 @@ import 'package:eatvio_app/core/enums/product_type.dart'; import 'package:eatvio_app/core/utils/localization_utils.dart'; import 'package:eatvio_app/core/utils/toasts.dart'; import 'package:eatvio_app/core/widgets/bookmark_button.dart'; +import 'package:eatvio_app/core/widgets/custom_popup.dart'; import 'package:eatvio_app/core/widgets/data_error_widget.dart'; import 'package:eatvio_app/core/widgets/info_row.dart'; import 'package:eatvio_app/core/widgets/loader.dart'; @@ -54,6 +55,7 @@ class _AboutRecipeScreenState extends State { final textEditingController = TextEditingController(); bool isMoreOptionsVisible = false; bool _jumped = false; + @override void initState() { super.initState(); @@ -142,8 +144,10 @@ class _AboutRecipeScreenState extends State { keyboardType: TextInputType.multiline, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w400, color: Colors.black, height: 1.2), decoration: InputDecoration( - isDense: false, // убираем true, чтобы padding учитывался корректно - contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), // вертикальный паддинг увеличен + isDense: false, + // убираем true, чтобы padding учитывался корректно + contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), + // вертикальный паддинг увеличен hintText: 'Комментарий', hintStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.w400, height: 1.2, color: Color(0xFFAEAEB2)), filled: true, @@ -211,23 +215,13 @@ class _AboutRecipeScreenState extends State { style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black), ), actions: [ - PortalTarget( - visible: isMoreOptionsVisible, - portalFollower: MoreOptions( - complainedContentType: ComplainedContent.recipe, - path: 'recipe/${widget.recipe.slug}', - slug: widget.recipe.slug, - ), - anchor: const Aligned(shiftToWithinBound: AxisFlag(x: true, y: true), follower: Alignment.topRight, target: Alignment.bottomRight), - child: IconButton( - onPressed: () { - setState(() { - isMoreOptionsVisible = !isMoreOptionsVisible; - }); - }, - icon: SvgPicture.asset('assets/icons/more_button.svg', width: 20, height: 20), - ), + CustomPopup( + isAuthor: widget.recipe.author.authorIsMe, + path: 'recipe/${widget.recipe.slug}', + complainedContentType: ComplainedContent.recipe, + slug: widget.recipe.slug, ), + const SizedBox(width: 16), ], ), body: SingleChildScrollView(