forked from eatvio/eatvio_app
fix(recipe): Fix
This commit is contained in:
@@ -145,6 +145,10 @@ class RecipeCreateCubit extends Cubit<RecipeCreateState> {
|
||||
await recipeRepository.publishRecipe(recipe);
|
||||
}
|
||||
|
||||
editRecipe(RecipeModel recipe, String id) async {
|
||||
await recipeRepository.editRecipe(recipe, id);
|
||||
}
|
||||
|
||||
uploadRecipeImage(XFile? pickedFile) {
|
||||
try {
|
||||
if (state is RecipeCreateStateLoaded) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/features/diary/models/product.dart';
|
||||
@@ -17,6 +18,7 @@ import 'package:image_picker/image_picker.dart';
|
||||
class RecipeCreateScreen extends StatelessWidget {
|
||||
RecipeCreateScreen({Key? key}) : super(key: key);
|
||||
Widget build(BuildContext context) {
|
||||
context.read<RecipeCreateCubit>().loadRecipeCreate();
|
||||
return BlocBuilder<RecipeCreateCubit, RecipeCreateState>(
|
||||
builder: (context, state) {
|
||||
if (state is RecipeCreateStateLoaded) {
|
||||
@@ -53,8 +55,29 @@ class RecipeCreateScreen extends StatelessWidget {
|
||||
List<String> _options = state.autocompleteList.map((Product item) => item.name).toList();
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
actions: [
|
||||
InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Ink(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 4),
|
||||
Text(
|
||||
'Новый рецепт',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
backgroundColor: Color.fromARGB(255, 240, 242, 245),
|
||||
resizeToAvoidBottomInset: true,
|
||||
@@ -145,7 +168,7 @@ class RecipeCreateScreen extends StatelessWidget {
|
||||
optionsBuilder: _buildOptions(_options),
|
||||
fieldViewBuilder: (
|
||||
BuildContext context,
|
||||
productEditingController,
|
||||
TextEditingController productEditingController,
|
||||
FocusNode focusNodeName,
|
||||
VoidCallback onFieldSubmitted,
|
||||
) {
|
||||
@@ -472,9 +495,7 @@ class RecipeCreateScreen extends StatelessWidget {
|
||||
image: state.recipeImage?.path,
|
||||
video_url: state.youtubeLinkController.text.isNotEmpty ? state.youtubeLinkController.text : null,
|
||||
);
|
||||
print(recipe.toJson());
|
||||
print(recipe.toString());
|
||||
print(recipe);
|
||||
print(jsonDecode(jsonEncode(recipe)));
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,29 @@ class RecipeEditScreen extends StatelessWidget {
|
||||
List<String> _options = state.autocompleteList.map((Product item) => item.name).toList();
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
actions: [
|
||||
InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Ink(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 4),
|
||||
Text(
|
||||
state.titleController.text,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
backgroundColor: Color.fromARGB(255, 240, 242, 245),
|
||||
resizeToAvoidBottomInset: true,
|
||||
@@ -155,7 +176,7 @@ class RecipeEditScreen extends StatelessWidget {
|
||||
optionsBuilder: _buildOptions(_options),
|
||||
fieldViewBuilder: (
|
||||
BuildContext context,
|
||||
productEditingController,
|
||||
TextEditingController productEditingController,
|
||||
FocusNode focusNodeName,
|
||||
VoidCallback onFieldSubmitted,
|
||||
) {
|
||||
@@ -304,7 +325,7 @@ class RecipeEditScreen extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
backgroundColor: appTheme.blueA400,
|
||||
onPressed: () => context.read<RecipeCreateCubit>().publishRecipe(createRecipeFromState(state)),
|
||||
onPressed: () => context.read<RecipeCreateCubit>().editRecipe(createRecipeFromState(state), recipeID),
|
||||
label: Text(
|
||||
'Опубликовать',
|
||||
style: theme.textTheme.titleSmall,
|
||||
|
||||
Reference in New Issue
Block a user