From 06de6c5d1cd5d208c80cfc5aa61cf055e417c3f2 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Mon, 19 May 2025 17:50:52 +0300 Subject: [PATCH] fix(recipe): tags error --- lib/core/const.dart | 4 +- .../presentation/widgets/tags_widget.dart | 125 +++++++++--------- .../presentation/pages/profile_screen.dart | 1 + 3 files changed, 63 insertions(+), 67 deletions(-) diff --git a/lib/core/const.dart b/lib/core/const.dart index 4f38a54e..31c47e9c 100644 --- a/lib/core/const.dart +++ b/lib/core/const.dart @@ -1,5 +1,5 @@ -// String baseUrl = 'https://eatvio.ru'; -String baseUrl = 'https://dev2.eatvio.com'; +String baseUrl = 'https://eatvio.ru'; +// String baseUrl = 'https://dev2.eatvio.com'; const List durationValues = [7, 14, 21]; diff --git a/lib/features/create_recipe/presentation/widgets/tags_widget.dart b/lib/features/create_recipe/presentation/widgets/tags_widget.dart index baac0c3b..affc9e90 100644 --- a/lib/features/create_recipe/presentation/widgets/tags_widget.dart +++ b/lib/features/create_recipe/presentation/widgets/tags_widget.dart @@ -1,6 +1,7 @@ import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/core/widgets/custom_text_form_field.dart'; import 'package:eatvio_app/features/create_recipe/presentation/bloc/create_recipe_cubit/create_recipe_cubit.dart'; +import 'package:eatvio_app/features/create_recipe/presentation/bloc/create_recipe_cubit/create_recipe_state.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -14,79 +15,73 @@ class TagsWidget extends StatefulWidget { class _TagsWidgetState extends State { late final CreateRecipeCubit createRecipeCubit; final tagController = TextEditingController(); - late final List tags; - - @override - void initState() { - super.initState(); - createRecipeCubit = context.read(); - tags = createRecipeCubit.state.entity.tags; - } @override Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text('Теги'), - const SizedBox(height: 4), - CustomTextFormField( - hintText: 'Например: без майонеза', - controller: tagController, - suffix: IconButton( - onPressed: () { - if (tagController.text.isNotEmpty) { - setState(() { - tags.add(tagController.text); - tagController.clear(); - }); - } - }, - icon: Icon( - Icons.done, - color: appTheme.blueA400, - ), - ), - ), - const SizedBox(height: 12), - Wrap( - spacing: 8, - runSpacing: 8, + return BlocBuilder( + builder: (BuildContext context, CreateRecipeState state) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - for (int i = 0; i < tags.length; i++) ...[ - InkWell( - onTap: () { - setState(() { - tags.remove(tags[i]); - }); + const Text('Теги'), + const SizedBox(height: 4), + CustomTextFormField( + hintText: 'Например: без майонеза', + controller: tagController, + suffix: IconButton( + onPressed: () { + if (tagController.text.isNotEmpty) { + context.read().addTag(tagController.text); + setState(() { + tagController.clear(); + }); + } }, - borderRadius: BorderRadius.circular(16), - child: Ink( - padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(16), - color: Colors.grey.shade200, - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - tags[i], - ), - const SizedBox(width: 4), - Icon( - Icons.delete_outline_rounded, - color: Colors.grey.shade600, - size: 20, - ), - ], - ), + icon: Icon( + Icons.done, + color: appTheme.blueA400, ), ), - ], + ), + const SizedBox(height: 12), + Wrap( + spacing: 8, + runSpacing: 8, + children: [ + for (int i = 0; i < state.entity.tags.length; i++) ...[ + InkWell( + onTap: () { + context.read().removeTag(state.entity.tags[i]); + }, + borderRadius: BorderRadius.circular(16), + child: Ink( + padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + color: Colors.grey.shade200, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + state.entity.tags[i], + ), + const SizedBox(width: 4), + Icon( + Icons.delete_outline_rounded, + color: Colors.grey.shade600, + size: 20, + ), + ], + ), + ), + ), + ], + ], + ), ], - ), - ], + ); + }, ); } } diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index 699aa021..ad6c9b9d 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -756,6 +756,7 @@ class _ProfileScreenState extends State { ) : Tooltip( message: state.profile.badges[i].description, + margin: const EdgeInsets.symmetric(horizontal: 32), triggerMode: TooltipTriggerMode.tap, textStyle: const TextStyle( color: Colors.black,