fix(recipe): tags error

This commit is contained in:
mso7nueh
2025-05-19 17:50:52 +03:00
parent 9c75fd7c9e
commit 06de6c5d1c
3 changed files with 63 additions and 67 deletions

View File

@@ -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<int> durationValues = [7, 14, 21];

View File

@@ -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<TagsWidget> {
late final CreateRecipeCubit createRecipeCubit;
final tagController = TextEditingController();
late final List<String> tags;
@override
void initState() {
super.initState();
createRecipeCubit = context.read<CreateRecipeCubit>();
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<CreateRecipeCubit, CreateRecipeState>(
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<CreateRecipeCubit>().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<CreateRecipeCubit>().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,
),
],
),
),
),
],
],
),
],
),
],
);
},
);
}
}

View File

@@ -756,6 +756,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
)
: Tooltip(
message: state.profile.badges[i].description,
margin: const EdgeInsets.symmetric(horizontal: 32),
triggerMode: TooltipTriggerMode.tap,
textStyle: const TextStyle(
color: Colors.black,