feat(tests); recipe create

This commit is contained in:
mso7nueh
2025-10-17 17:11:27 +03:00
parent bb68ea963c
commit b9136a80de
11 changed files with 606 additions and 168 deletions

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/app_keys.dart';
import 'package:eatvio_app/core/data/selectionPopupModel/selection_popup_model.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/custom_drop_down.dart';
@@ -58,6 +59,7 @@ class _InfoAboutRecipeWidgetState extends State<InfoAboutRecipeWidget> {
return Column(
children: [
CustomTextFormField(
key: AppKeys.recipeCreateScreenTitleField,
hintText: 'Например: тар-тар из говядины',
hasError: state.titleValidationError != null,
initialValue: state.entity.title,
@@ -68,12 +70,7 @@ class _InfoAboutRecipeWidgetState extends State<InfoAboutRecipeWidget> {
}
},
),
if (state.titleValidationError != null) ...[
const SizedBox(height: 4),
ValidationErrorWidget(
error: state.titleValidationError!,
),
],
if (state.titleValidationError != null) ...[const SizedBox(height: 4), ValidationErrorWidget(error: state.titleValidationError!)],
],
);
},
@@ -82,15 +79,14 @@ class _InfoAboutRecipeWidgetState extends State<InfoAboutRecipeWidget> {
const Text('Тип блюда'),
const SizedBox(height: 4),
CustomDropDown(
key: AppKeys.recipeCreateScreenTypeDropdown,
items: items,
value: selectedType,
onChanged: (newSelectedType) {
setState(() {
selectedType = newSelectedType;
});
widget.createRecipeCubit.changeType(
TypeOfRecipe.fromString(selectedType.title) ?? TypeOfRecipe.other,
);
widget.createRecipeCubit.changeType(TypeOfRecipe.fromString(selectedType.title) ?? TypeOfRecipe.other);
},
),
const SizedBox(height: 12),
@@ -108,6 +104,7 @@ class _InfoAboutRecipeWidgetState extends State<InfoAboutRecipeWidget> {
return Column(
children: [
CustomTextFormField(
key: AppKeys.recipeCreateScreenDescriptionField,
hintText: 'Расскажите, почему вы выбрали именно этот рецепт? Опишите, каким будет готовое блюдо и в чём его достоинства.',
minLines: 5,
initialValue: state.entity.description,
@@ -122,9 +119,7 @@ class _InfoAboutRecipeWidgetState extends State<InfoAboutRecipeWidget> {
),
if (state.descriptionValidationError != null) ...[
const SizedBox(height: 4),
ValidationErrorWidget(
error: state.descriptionValidationError!,
),
ValidationErrorWidget(error: state.descriptionValidationError!),
],
],
);
@@ -140,16 +135,14 @@ class _InfoAboutRecipeWidgetState extends State<InfoAboutRecipeWidget> {
children: [
Container(
decoration: state.imageValidationError != null
? BoxDecoration(border: Border.all(width: 1, color: appTheme.red), borderRadius: BorderRadius.circular(8))
? BoxDecoration(
border: Border.all(width: 1, color: appTheme.red),
borderRadius: BorderRadius.circular(8),
)
: null,
child: ImageWidget(image: state.entity.image),
child: ImageWidget(key: AppKeys.recipeCreateScreenImageWidget, image: state.entity.image),
),
if (state.imageValidationError != null) ...[
const SizedBox(height: 4),
ValidationErrorWidget(
error: state.imageValidationError!,
),
],
if (state.imageValidationError != null) ...[const SizedBox(height: 4), ValidationErrorWidget(error: state.imageValidationError!)],
],
);
},

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/app_keys.dart';
import 'package:eatvio_app/core/theme/theme_helper.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';
@@ -40,11 +41,7 @@ class _IngredientsWidgetState extends State<IngredientsWidget> {
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
'Ингредиенты ',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
color: Color(0xFF323F4B),
),
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: Color(0xFF323F4B)),
),
),
ReorderableListView(
@@ -63,46 +60,29 @@ class _IngredientsWidgetState extends State<IngredientsWidget> {
ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
key: Key('$index'),
leading: Icon(
Icons.drag_handle_rounded,
color: Colors.grey.shade600,
),
leading: Icon(Icons.drag_handle_rounded, color: Colors.grey.shade600),
title: Text(state.entity.ingredients[index].name),
subtitle: Text('${state.entity.ingredients[index].portion} ${state.entity.ingredients[index].unit == 'gr' ? 'гр' : 'шт'}'),
trailing: IconButton(
onPressed: () {
createRecipeCubit.removeIngredient(index);
},
icon: Icon(
Icons.delete_outline_rounded,
color: Colors.grey.shade600,
),
icon: Icon(Icons.delete_outline_rounded, color: Colors.grey.shade600),
),
),
],
),
ListTile(
key: AppKeys.recipeCreateScreenAddIngredientButton,
onTap: () {
nameController.clear();
gramsController.clear();
pcsController.clear();
_modalBottomSheet(
createRecipeCubit: createRecipeCubit,
);
_modalBottomSheet(createRecipeCubit: createRecipeCubit);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
title: Text(
'Добавить ингредиент',
style: TextStyle(
color: appTheme.blueA400,
),
),
leading: Icon(
Icons.add_rounded,
color: appTheme.blueA400,
),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
title: Text('Добавить ингредиент', style: TextStyle(color: appTheme.blueA400)),
leading: Icon(Icons.add_rounded, color: appTheme.blueA400),
),
],
),
@@ -121,9 +101,7 @@ class _IngredientsWidgetState extends State<IngredientsWidget> {
return showModalBottomSheet(
useRootNavigator: true,
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
),
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(12))),
isScrollControlled: true,
builder: (context) {
return AddPortionWidget(

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/app_keys.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
import 'package:eatvio_app/features/create_recipe/presentation/bloc/create_recipe_cubit/create_recipe_cubit.dart';
@@ -44,6 +45,7 @@ class _PortionWidgetState extends State<PortionWidget> {
Column(
children: [
CustomTextFormField(
key: AppKeys.recipeCreateScreenPortionsField,
hintText: '1',
hasError: state.servingsValidationError != null,
initialValue: state.entity.countOfPortions?.toString(),
@@ -57,9 +59,7 @@ class _PortionWidgetState extends State<PortionWidget> {
),
if (state.servingsValidationError != null) ...[
const SizedBox(height: 4),
ValidationErrorWidget(
error: state.servingsValidationError!,
),
ValidationErrorWidget(error: state.servingsValidationError!),
],
],
),
@@ -77,6 +77,7 @@ class _PortionWidgetState extends State<PortionWidget> {
Column(
children: [
CustomTextFormField(
key: AppKeys.recipeCreateScreenCaloriesField,
hintText: '100',
hasError: state.energyPerServingValidationError != null,
initialValue: state.entity.energyInOnePortion?.toString(),
@@ -91,9 +92,7 @@ class _PortionWidgetState extends State<PortionWidget> {
),
if (state.energyPerServingValidationError != null) ...[
const SizedBox(height: 4),
ValidationErrorWidget(
error: state.energyPerServingValidationError!,
),
ValidationErrorWidget(error: state.energyPerServingValidationError!),
],
],
),

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/app_keys.dart';
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';
@@ -22,9 +23,7 @@ class _StepsWidgetState extends State<StepsWidget> {
bloc: widget.createRecipeCubit,
builder: (BuildContext context, CreateRecipeState state) {
return Material(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
@@ -32,11 +31,7 @@ class _StepsWidgetState extends State<StepsWidget> {
children: [
const Text(
'Пошаговая инструкция',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
color: Color(0xFF323F4B),
),
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: Color(0xFF323F4B)),
),
const SizedBox(height: 12),
ListView.separated(
@@ -49,20 +44,11 @@ class _StepsWidgetState extends State<StepsWidget> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 4,
),
decoration: BoxDecoration(
color: appTheme.blueA400,
borderRadius: BorderRadius.circular(8),
),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(color: appTheme.blueA400, borderRadius: BorderRadius.circular(8)),
child: Text(
'Шаг ${index + 1}',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
),
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w600),
),
),
GestureDetector(
@@ -77,6 +63,7 @@ class _StepsWidgetState extends State<StepsWidget> {
const Text('Описание'),
const SizedBox(height: 4),
CustomTextFormField(
key: Key('${AppKeys.recipeCreateScreenStepDescriptionField}_$index'),
hintText: 'Например: подготовьте ингредиенты',
initialValue: widget.createRecipeCubit.state.entity.steps[index].description,
maxLines: 5,
@@ -89,6 +76,7 @@ class _StepsWidgetState extends State<StepsWidget> {
const Text('Фото шага'),
const SizedBox(height: 4),
StepImageWidget(
key: Key('${AppKeys.recipeCreateScreenStepImageWidget}_$index'),
index: index,
createRecipeCubit: widget.createRecipeCubit,
),
@@ -98,26 +86,20 @@ class _StepsWidgetState extends State<StepsWidget> {
separatorBuilder: (BuildContext context, int index) => const SizedBox(height: 24),
),
InkWell(
key: AppKeys.recipeCreateScreenAddStepButton,
onTap: () {
context.read<CreateRecipeCubit>().addStep();
},
borderRadius: BorderRadius.circular(20),
child: Ink(
width: MediaQuery.of(context).size.width - 32,
decoration: BoxDecoration(
color: appTheme.blueA400,
borderRadius: BorderRadius.circular(20),
),
decoration: BoxDecoration(color: appTheme.blueA400, borderRadius: BorderRadius.circular(20)),
child: Container(
padding: const EdgeInsets.all(16),
alignment: Alignment.center,
child: const Text(
'Добавить шаг',
style: TextStyle(
fontSize: 16,
color: Colors.white,
fontWeight: FontWeight.w600,
),
style: TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.w600),
),
),
),

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/app_keys.dart';
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';
@@ -26,9 +27,11 @@ class _TagsWidgetState extends State<TagsWidget> {
const Text('Теги'),
const SizedBox(height: 4),
CustomTextFormField(
key: AppKeys.recipeCreateScreenTagField,
hintText: 'Например: без майонеза',
controller: tagController,
suffix: IconButton(
key: AppKeys.recipeCreateScreenAddTagButton,
onPressed: () {
if (tagController.text.isNotEmpty) {
context.read<CreateRecipeCubit>().addTag(tagController.text);
@@ -37,10 +40,7 @@ class _TagsWidgetState extends State<TagsWidget> {
});
}
},
icon: Icon(
Icons.done,
color: appTheme.blueA400,
),
icon: Icon(Icons.done, color: appTheme.blueA400),
),
),
const SizedBox(height: 12),
@@ -56,22 +56,13 @@ class _TagsWidgetState extends State<TagsWidget> {
borderRadius: BorderRadius.circular(16),
child: Ink(
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
color: Colors.grey.shade200,
),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(16), color: Colors.grey.shade200),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
state.entity.tags[i],
),
Text(state.entity.tags[i]),
const SizedBox(width: 4),
Icon(
Icons.delete_outline_rounded,
color: Colors.grey.shade600,
size: 20,
),
Icon(Icons.delete_outline_rounded, color: Colors.grey.shade600, size: 20),
],
),
),

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/app_keys.dart';
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_diet/presentation/widgets/error_widget.dart';
@@ -43,20 +44,12 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
builder: (context) => const AlertDialog(
content: Text(
'Общее время приготовления - это период времени от начала приготовления блюда до подачи его на стол.',
style: TextStyle(
fontWeight: FontWeight.w500,
color: Color(0xFF323F4B),
height: 1.2,
),
style: TextStyle(fontWeight: FontWeight.w500, color: Color(0xFF323F4B), height: 1.2),
),
),
);
},
child: Icon(
Icons.help_outline_rounded,
color: appTheme.blueA400,
size: 20,
),
child: Icon(Icons.help_outline_rounded, color: appTheme.blueA400, size: 20),
),
],
),
@@ -68,6 +61,7 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
child: Column(
children: [
CustomTextFormField(
key: AppKeys.recipeCreateScreenTotalHoursField,
hintText: 'Часов',
hasError: state.cookingTimeValidationError != null,
textInputType: TextInputType.number,
@@ -83,9 +77,7 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
),
if (state.cookingTimeValidationError != null) ...[
const SizedBox(height: 4),
ValidationErrorWidget(
error: state.cookingTimeValidationError!,
),
ValidationErrorWidget(error: state.cookingTimeValidationError!),
],
],
),
@@ -95,6 +87,7 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
child: Column(
children: [
CustomTextFormField(
key: AppKeys.recipeCreateScreenTotalMinutesField,
hintText: 'Минут',
hasError: state.cookingTimeValidationError != null,
textInputType: TextInputType.number,
@@ -110,9 +103,7 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
),
if (state.cookingTimeValidationError != null) ...[
const SizedBox(height: 4),
ValidationErrorWidget(
error: state.cookingTimeValidationError!,
),
ValidationErrorWidget(error: state.cookingTimeValidationError!),
],
],
),
@@ -131,20 +122,12 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
builder: (context) => const AlertDialog(
content: Text(
'Активное время приготовления - это период времени, требующий активного участия в приготовлении блюда. Оно включает мытье и очистку продуктов, нарезку, шинковку, взбивание, перемешивание, размешивание, перекладывание и т.п.',
style: TextStyle(
fontWeight: FontWeight.w500,
color: Color(0xFF323F4B),
height: 1.2,
),
style: TextStyle(fontWeight: FontWeight.w500, color: Color(0xFF323F4B), height: 1.2),
),
),
);
},
child: Icon(
Icons.help_outline_rounded,
color: appTheme.blueA400,
size: 20,
),
child: Icon(Icons.help_outline_rounded, color: appTheme.blueA400, size: 20),
),
],
),
@@ -156,6 +139,7 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
child: Column(
children: [
CustomTextFormField(
key: AppKeys.recipeCreateScreenActiveHoursField,
hintText: 'Часов',
hasError: state.activeTimeValidationError != null,
initialValue: state.entity.activeCookHours?.toString(),
@@ -172,9 +156,7 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
),
if (state.activeTimeValidationError != null) ...[
const SizedBox(height: 4),
ValidationErrorWidget(
error: state.activeTimeValidationError!,
),
ValidationErrorWidget(error: state.activeTimeValidationError!),
],
],
),
@@ -184,6 +166,7 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
child: Column(
children: [
CustomTextFormField(
key: AppKeys.recipeCreateScreenActiveMinutesField,
hintText: 'Минут',
hasError: state.activeTimeValidationError != null,
initialValue: state.entity.activeCookMinutes?.toString(),
@@ -200,9 +183,7 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
),
if (state.activeTimeValidationError != null) ...[
const SizedBox(height: 4),
ValidationErrorWidget(
error: state.activeTimeValidationError!,
),
ValidationErrorWidget(error: state.activeTimeValidationError!),
],
],
),