forked from eatvio/eatvio_app
feat(recipe): Layout state and navigation for Recipe create & update
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_create_screen/models/recipe_create_model.dart';
|
||||
part 'recipe_create_event.dart';
|
||||
part 'recipe_create_state.dart';
|
||||
|
||||
/// A bloc that manages the state of a RecipeCreate according to the event that is dispatched to it.
|
||||
class RecipeCreateBloc extends Bloc<RecipeCreateEvent, RecipeCreateState> {
|
||||
RecipeCreateBloc(RecipeCreateState initialState) : super(initialState) {
|
||||
on<RecipeCreateInitialEvent>(_onInitialize);
|
||||
on<CreateRecipe>(_createRecipe);
|
||||
}
|
||||
|
||||
_onInitialize(
|
||||
RecipeCreateInitialEvent event,
|
||||
Emitter<RecipeCreateState> emit,
|
||||
) async {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
}
|
||||
if (state is RecipeCreateLoadedState) {
|
||||
var currentState = state as RecipeCreateLoadedState;
|
||||
emit(currentState.copyWith(
|
||||
recipeModelObj: currentState.recipeModelObj,
|
||||
title: currentState.title,
|
||||
description: currentState.description,
|
||||
youtube_url: currentState.youtube_url));
|
||||
} else {
|
||||
emit(RecipeCreateLoadedState(
|
||||
title: TextEditingController(),
|
||||
description: TextEditingController(),
|
||||
youtube_url: TextEditingController()));
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _createRecipe(
|
||||
CreateRecipe event, Emitter<RecipeCreateState> emit) async {
|
||||
if (state is RecipeCreateLoadedState) {
|
||||
var currentState = state as RecipeCreateLoadedState;
|
||||
|
||||
var response = await sendRecipe(
|
||||
currentState.title?.text,
|
||||
currentState.youtube_url?.text,
|
||||
currentState.description?.text,
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
NavigatorService.pushNamed(AppRoutes.recipeScreen);
|
||||
} else {
|
||||
print(
|
||||
'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<http.Response> sendRecipe(
|
||||
String? title,
|
||||
String? youtube_url,
|
||||
String? description,
|
||||
) async {
|
||||
String url = '${dotenv.env['SERVER_ROOT']!}/recipe/create';
|
||||
|
||||
final Map<String, dynamic> credentials = {
|
||||
'title': title,
|
||||
'description': description,
|
||||
'youtube_url': youtube_url,
|
||||
'status': 'active',
|
||||
};
|
||||
|
||||
var response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: json.encode(credentials),
|
||||
encoding: utf8,
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'recipe_create_bloc.dart';
|
||||
|
||||
/// Abstract class for all events that can be dispatched from the
|
||||
///RecipeCreate widget.
|
||||
///
|
||||
/// Events must be immutable and implement the [Equatable] interface.
|
||||
@immutable
|
||||
abstract class RecipeCreateEvent extends Equatable {}
|
||||
|
||||
/// Event that is dispatched when the RecipeCreate widget is first created.
|
||||
class RecipeCreateInitialEvent extends RecipeCreateEvent {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class CreateRecipe extends RecipeCreateEvent {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'recipe_create_bloc.dart';
|
||||
|
||||
/// Represents the state of RecipeCreate in the application.
|
||||
///
|
||||
|
||||
class RecipeCreateState extends Equatable {
|
||||
RecipeCreateState({
|
||||
this.recipeModelObj,
|
||||
});
|
||||
|
||||
RecipeCreateModel? recipeModelObj;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [recipeModelObj];
|
||||
RecipeCreateState copyWith({RecipeCreateModel? recipeModelObj}) {
|
||||
return RecipeCreateState(
|
||||
recipeModelObj: recipeModelObj ?? this.recipeModelObj,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RecipeCreateLoadedState extends RecipeCreateState {
|
||||
RecipeCreateLoadedState(
|
||||
{this.recipeModelObj, this.title, this.description, this.youtube_url});
|
||||
|
||||
RecipeCreateModel? recipeModelObj;
|
||||
TextEditingController? title;
|
||||
TextEditingController? description;
|
||||
TextEditingController? youtube_url;
|
||||
@override
|
||||
List<Object?> get props => [recipeModelObj, title, description, youtube_url];
|
||||
RecipeCreateLoadedState copyWith({
|
||||
RecipeCreateModel? recipeModelObj,
|
||||
TextEditingController? title,
|
||||
TextEditingController? description,
|
||||
TextEditingController? youtube_url,
|
||||
}) {
|
||||
return RecipeCreateLoadedState(
|
||||
recipeModelObj: recipeModelObj ?? this.recipeModelObj,
|
||||
title: title ?? this.title,
|
||||
description: description ?? this.description,
|
||||
youtube_url: youtube_url ?? this.youtube_url,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RecipeCreateErrorState extends RecipeCreateState {
|
||||
final String errorMessage;
|
||||
|
||||
RecipeCreateErrorState(this.errorMessage);
|
||||
|
||||
@override
|
||||
List<Object> get props => [errorMessage];
|
||||
}
|
||||
|
||||
class RecipeCreateInitialState extends RecipeCreateState {
|
||||
RecipeCreateInitialState({required RecipeCreateModel recipeModelObj})
|
||||
: super(recipeModelObj: recipeModelObj);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// This class defines the variables used in the [recipe_create_screen],
|
||||
/// and is typically used to hold data that is passed between different parts of the application.
|
||||
|
||||
class RecipeCreateModel extends Equatable {
|
||||
final String recipeID;
|
||||
|
||||
RecipeCreateModel({required String recipeID}) : recipeID = recipeID;
|
||||
|
||||
RecipeCreateModel copyWith(String recipeID) {
|
||||
return RecipeCreateModel(recipeID: recipeID);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [recipeID];
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
import 'bloc/recipe_create_bloc.dart';
|
||||
import 'models/recipe_create_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class RecipeCreateScreen extends StatelessWidget {
|
||||
const RecipeCreateScreen({Key? key}) : super(key: key);
|
||||
static Widget builder(BuildContext context) {
|
||||
final recipeID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<RecipeCreateBloc>(
|
||||
create: (context) => RecipeCreateBloc(RecipeCreateState(
|
||||
recipeModelObj: RecipeCreateModel(recipeID: recipeID.toString())))
|
||||
..add(RecipeCreateInitialEvent()),
|
||||
child: RecipeCreateScreen());
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<RecipeCreateBloc, RecipeCreateState>(
|
||||
builder: (context, state) {
|
||||
if (state is RecipeCreateInitialState) {
|
||||
// Это начальное состояние, данные ещё не загружены.
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
);
|
||||
} else if (state is RecipeCreateLoadedState) {
|
||||
// Данные загружены, можно строить экран.
|
||||
return _buildRecipeCreate(context, state);
|
||||
} else if (state is RecipeCreateErrorState) {
|
||||
// Произошла ошибка при загрузке данных.
|
||||
return Center(child: Text(state.errorMessage));
|
||||
} else {
|
||||
// Другие состояния, если они есть.
|
||||
return Container(); // Пустой контейнер для необработанных состояний.
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_buildRecipeCreate(BuildContext context, RecipeCreateLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.title,
|
||||
decoration: InputDecoration(labelText: 'Заголовок'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.description,
|
||||
decoration: InputDecoration(labelText: 'Описание'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.youtube_url,
|
||||
decoration: InputDecoration(labelText: 'Ссылка'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
// Здесь нужно добавить виджет для загрузки картинки
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
context.read<RecipeCreateBloc>().add(CreateRecipe()),
|
||||
child: Text('Создать'),
|
||||
)
|
||||
]),
|
||||
)
|
||||
]),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_edit_screen/models/recipe_edit_model.dart';
|
||||
part 'recipe_edit_event.dart';
|
||||
part 'recipe_edit_state.dart';
|
||||
|
||||
/// A bloc that manages the state of a RecipeEdit according to the event that is dispatched to it.
|
||||
class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
|
||||
RecipeEditBloc(RecipeEditState initialState) : super(initialState) {
|
||||
on<RecipeEditInitialEvent>(_onInitialize);
|
||||
on<EditRecipe>(_editRecipe);
|
||||
}
|
||||
|
||||
_onInitialize(
|
||||
RecipeEditInitialEvent event,
|
||||
Emitter<RecipeEditState> emit,
|
||||
) async {
|
||||
try {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
}
|
||||
final String? recipeID = state.recipeModelObj?.recipeID;
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/recipe/show/$recipeID'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
final data = jsonDecode(response.body);
|
||||
if (data is Map<String, dynamic>) {
|
||||
if (state is RecipeEditLoadedState) {
|
||||
var currentState = state as RecipeEditLoadedState;
|
||||
emit(currentState.copyWith(
|
||||
recipeModelObj: currentState.recipeModelObj,
|
||||
recipe: currentState.recipe,
|
||||
title: currentState.title,
|
||||
description: currentState.description,
|
||||
youtube_url: currentState.youtube_url));
|
||||
} else {
|
||||
emit(RecipeEditLoadedState(
|
||||
recipe: data,
|
||||
title: TextEditingController(text: data['title']),
|
||||
description: TextEditingController(text: data['description']),
|
||||
youtube_url: TextEditingController(text: data['youtube_url'])));
|
||||
}
|
||||
} else {
|
||||
// Один или несколько ключевых полей отсутствуют, обрабатываем ошибку
|
||||
emit(RecipeEditErrorState(
|
||||
'Некоторые необходимые данные отсутствуют.'));
|
||||
}
|
||||
} else {
|
||||
// Статус ответа не равен 200, обрабатываем ошибку
|
||||
emit(RecipeEditErrorState('Ошибка сервера: ${response.statusCode}'));
|
||||
}
|
||||
} catch (e) {
|
||||
// Ошибка при декодировании JSON или другая ошибка выполнения
|
||||
emit(RecipeEditErrorState('Ошибка при получении данных о чатах: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _editRecipe(
|
||||
EditRecipe event, Emitter<RecipeEditState> emit) async {
|
||||
if (state is RecipeEditLoadedState) {
|
||||
var currentState = state as RecipeEditLoadedState;
|
||||
|
||||
var response = await sendRecipe(
|
||||
currentState.recipe,
|
||||
currentState.title?.text,
|
||||
currentState.youtube_url?.text,
|
||||
currentState.description?.text,
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
NavigatorService.pushNamed(AppRoutes.blogPostScreen,
|
||||
arguments: currentState.recipe?['id'].toString());
|
||||
} else {
|
||||
print(
|
||||
'Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<http.Response> sendRecipe(
|
||||
Map<String, dynamic>? recipe,
|
||||
String? title,
|
||||
String? youtube_url,
|
||||
String? description,
|
||||
) async {
|
||||
int id = recipe?['id'];
|
||||
String url = '${dotenv.env['SERVER_ROOT']!}/recipe/update/$id';
|
||||
|
||||
final Map<String, dynamic> credentials = {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'description': description,
|
||||
'youtube_url': youtube_url,
|
||||
};
|
||||
|
||||
var response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: json.encode(credentials),
|
||||
encoding: utf8,
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'recipe_edit_bloc.dart';
|
||||
|
||||
/// Abstract class for all events that can be dispatched from the
|
||||
///RecipeEdit widget.
|
||||
///
|
||||
/// Events must be immutable and implement the [Equatable] interface.
|
||||
@immutable
|
||||
abstract class RecipeEditEvent extends Equatable {}
|
||||
|
||||
/// Event that is dispatched when the RecipeEdit widget is first created.
|
||||
class RecipeEditInitialEvent extends RecipeEditEvent {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class EditRecipe extends RecipeEditEvent {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'recipe_edit_bloc.dart';
|
||||
|
||||
/// Represents the state of RecipeEdit in the application.
|
||||
///
|
||||
|
||||
class RecipeEditState extends Equatable {
|
||||
RecipeEditState({
|
||||
this.recipeModelObj,
|
||||
});
|
||||
|
||||
RecipeEditModel? recipeModelObj;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [recipeModelObj];
|
||||
RecipeEditState copyWith({RecipeEditModel? recipeModelObj}) {
|
||||
return RecipeEditState(
|
||||
recipeModelObj: recipeModelObj ?? this.recipeModelObj,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RecipeEditLoadedState extends RecipeEditState {
|
||||
RecipeEditLoadedState(
|
||||
{this.recipeModelObj,
|
||||
this.recipe,
|
||||
this.title,
|
||||
this.description,
|
||||
this.youtube_url});
|
||||
|
||||
RecipeEditModel? recipeModelObj;
|
||||
Map<String, dynamic>? recipe;
|
||||
TextEditingController? title;
|
||||
TextEditingController? description;
|
||||
TextEditingController? youtube_url;
|
||||
@override
|
||||
List<Object?> get props =>
|
||||
[recipeModelObj, recipe, title, description, youtube_url];
|
||||
RecipeEditLoadedState copyWith({
|
||||
RecipeEditModel? recipeModelObj,
|
||||
Map<String, dynamic>? recipe,
|
||||
TextEditingController? title,
|
||||
TextEditingController? description,
|
||||
TextEditingController? youtube_url,
|
||||
}) {
|
||||
return RecipeEditLoadedState(
|
||||
recipeModelObj: recipeModelObj ?? this.recipeModelObj,
|
||||
recipe: recipe ?? this.recipe,
|
||||
title: title ?? this.title,
|
||||
description: description ?? this.description,
|
||||
youtube_url: youtube_url ?? this.youtube_url,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RecipeEditErrorState extends RecipeEditState {
|
||||
final String errorMessage;
|
||||
|
||||
RecipeEditErrorState(this.errorMessage);
|
||||
|
||||
@override
|
||||
List<Object> get props => [errorMessage];
|
||||
}
|
||||
|
||||
class RecipeEditInitialState extends RecipeEditState {
|
||||
RecipeEditInitialState({required RecipeEditModel recipeModelObj})
|
||||
: super(recipeModelObj: recipeModelObj);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// This class defines the variables used in the [recipe_edit_screen],
|
||||
/// and is typically used to hold data that is passed between different parts of the application.
|
||||
|
||||
class RecipeEditModel extends Equatable {
|
||||
final String recipeID;
|
||||
|
||||
RecipeEditModel({required String recipeID}) : recipeID = recipeID;
|
||||
|
||||
RecipeEditModel copyWith(String recipeID) {
|
||||
return RecipeEditModel(recipeID: recipeID);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [recipeID];
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import 'bloc/recipe_edit_bloc.dart';
|
||||
import 'models/recipe_edit_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class RecipeEditScreen extends StatelessWidget {
|
||||
const RecipeEditScreen({Key? key}) : super(key: key);
|
||||
static Widget builder(BuildContext context) {
|
||||
final recipeID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<RecipeEditBloc>(
|
||||
create: (context) => RecipeEditBloc(RecipeEditState(
|
||||
recipeModelObj: RecipeEditModel(recipeID: recipeID.toString())))
|
||||
..add(RecipeEditInitialEvent()),
|
||||
child: RecipeEditScreen());
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<RecipeEditBloc, RecipeEditState>(
|
||||
builder: (context, state) {
|
||||
if (state is RecipeEditInitialState) {
|
||||
// Это начальное состояние, данные ещё не загружены.
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
);
|
||||
} else if (state is RecipeEditLoadedState) {
|
||||
// Данные загружены, можно строить экран.
|
||||
return _buildRecipeEdit(context, state);
|
||||
} else if (state is RecipeEditErrorState) {
|
||||
// Произошла ошибка при загрузке данных.
|
||||
return Center(child: Text(state.errorMessage));
|
||||
} else {
|
||||
// Другие состояния, если они есть.
|
||||
return Container(); // Пустой контейнер для необработанных состояний.
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_buildRecipeEdit(BuildContext context, RecipeEditLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! +
|
||||
(state.recipe?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
radius: 25,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.title,
|
||||
decoration: InputDecoration(labelText: 'Заголовок'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.description,
|
||||
decoration: InputDecoration(labelText: 'Описание'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
TextFormField(
|
||||
controller: state.youtube_url,
|
||||
decoration: InputDecoration(labelText: 'Ссылка'),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
// Здесь нужно добавить виджет для загрузки картинки
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
context.read<RecipeEditBloc>().add(EditRecipe()),
|
||||
child: Text('Сохранить'),
|
||||
)
|
||||
]),
|
||||
)
|
||||
]),
|
||||
),
|
||||
bottomNavigationBar: _buildBottomBar(context)));
|
||||
}
|
||||
}
|
||||
|
||||
_buildBottomBar(BuildContext context) {
|
||||
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
|
||||
}
|
||||
@@ -33,6 +33,8 @@ import 'package:eatvio_app/presentation/diets/diet_edit_screen/diet_edit_screen.
|
||||
import 'package:eatvio_app/presentation/diets/diet_create_screen/diet_create_screen.dart';
|
||||
import 'package:eatvio_app/presentation/plans/plan_show_screen/plan_show_screen.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_show_screen/recipe_show_screen.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_create_screen/recipe_create_screen.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_screen/blog_post_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart';
|
||||
@@ -104,6 +106,10 @@ class AppRoutes {
|
||||
|
||||
static const String recipeScreen = '/recipe';
|
||||
|
||||
static const String recipeEditScreen = '/recipeEdit';
|
||||
|
||||
static const String recipeCreateScreen = '/recipeCreate';
|
||||
|
||||
static const String dietSelectScreen = '/dietSelect';
|
||||
|
||||
static const String dietScreen = '/diet';
|
||||
@@ -145,19 +151,21 @@ class AppRoutes {
|
||||
diaryEdit: DiaryEditScreen.builder,
|
||||
chatScreen: ChatScreen.builder,
|
||||
chatSelectScreen: ChatSelectScreen.builder,
|
||||
feedScreen: FeedScreen.builder,
|
||||
recipeSelectScreen: RecipeSelectScreen.builder,
|
||||
dietSelectScreen: DietSelectScreen.builder,
|
||||
planSelectScreen: PlanSelectScreen.builder,
|
||||
recipeScreen: RecipeScreen.builder,
|
||||
recipeEditScreen: RecipeEditScreen.builder,
|
||||
recipeCreateScreen: RecipeCreateScreen.builder,
|
||||
dietSelectScreen: DietSelectScreen.builder,
|
||||
dietScreen: DietScreen.builder,
|
||||
dietEditScreen: DietEditScreen.builder,
|
||||
dietCreateScreen: DietCreateScreen.builder,
|
||||
planSelectScreen: PlanSelectScreen.builder,
|
||||
planScreen: PlanScreen.builder,
|
||||
planEditScreen: PlanEditScreen.builder,
|
||||
planCreateScreen: PlanCreateScreen.builder,
|
||||
feedScreen: FeedScreen.builder,
|
||||
blogPostScreen: BlogPostScreen.builder,
|
||||
blogPostEditScreen: BlogPostEditScreen.builder,
|
||||
blogPostCreateScreen: BlogPostCreateScreen.builder,
|
||||
dietEditScreen: DietEditScreen.builder,
|
||||
dietCreateScreen: DietCreateScreen.builder,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user