forked from eatvio/eatvio_app
feature(registration): remove .env
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_create_screen/models/recipe_create_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:go_router/go_router.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';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
part 'recipe_create_event.dart';
|
||||
part 'recipe_create_state.dart';
|
||||
|
||||
@@ -34,7 +35,8 @@ class RecipeCreateBloc extends Bloc<RecipeCreateEvent, RecipeCreateState> {
|
||||
}
|
||||
if (state is RecipeCreateLoadedState) {
|
||||
var currentState = state as RecipeCreateLoadedState;
|
||||
emit(currentState.copyWith(
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
recipeModelObj: currentState.recipeModelObj,
|
||||
title: currentState.title,
|
||||
token: currentState.token,
|
||||
@@ -42,62 +44,79 @@ class RecipeCreateBloc extends Bloc<RecipeCreateEvent, RecipeCreateState> {
|
||||
video_url: currentState.video_url,
|
||||
steps: currentState.steps,
|
||||
stepDescriptions: currentState.stepDescriptions,
|
||||
tags: currentState.tags,),);
|
||||
tags: currentState.tags,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
final Map<String, dynamic> step = {
|
||||
'description': '',
|
||||
'image': '',
|
||||
};
|
||||
emit(RecipeCreateLoadedState(
|
||||
emit(
|
||||
RecipeCreateLoadedState(
|
||||
token: token,
|
||||
title: TextEditingController(),
|
||||
description: TextEditingController(),
|
||||
video_url: TextEditingController(),
|
||||
tags: TextEditingController(),
|
||||
stepDescriptions: [TextEditingController()],
|
||||
steps: [step],),);
|
||||
steps: [step],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _addStep(
|
||||
AddStep event, Emitter<RecipeCreateState> emit,) async {
|
||||
AddStep event,
|
||||
Emitter<RecipeCreateState> emit,
|
||||
) async {
|
||||
if (state is RecipeCreateLoadedState) {
|
||||
var currentState = state as RecipeCreateLoadedState;
|
||||
|
||||
List<dynamic>? updatedSteps = currentState.steps;
|
||||
List<TextEditingController>? updatedStepDescriptions =
|
||||
currentState.stepDescriptions;
|
||||
List<TextEditingController>? updatedStepDescriptions = currentState.stepDescriptions;
|
||||
|
||||
updatedSteps!.add({
|
||||
'description': '',
|
||||
'image': '',
|
||||
});
|
||||
updatedStepDescriptions!.add(TextEditingController());
|
||||
emit(currentState.copyWith(
|
||||
steps: updatedSteps, stepDescriptions: updatedStepDescriptions,),);
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
steps: updatedSteps,
|
||||
stepDescriptions: updatedStepDescriptions,
|
||||
),
|
||||
);
|
||||
await _reloadScreen(event, emit);
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _removeStep(
|
||||
RemoveStep event, Emitter<RecipeCreateState> emit,) async {
|
||||
RemoveStep event,
|
||||
Emitter<RecipeCreateState> emit,
|
||||
) async {
|
||||
if (state is RecipeCreateLoadedState) {
|
||||
var currentState = state as RecipeCreateLoadedState;
|
||||
|
||||
List<dynamic>? updatedSteps = currentState.steps;
|
||||
List<TextEditingController>? updatedStepDescriptions =
|
||||
currentState.stepDescriptions;
|
||||
List<TextEditingController>? updatedStepDescriptions = currentState.stepDescriptions;
|
||||
|
||||
updatedSteps!.removeAt(event.id);
|
||||
updatedStepDescriptions!.removeAt(event.id);
|
||||
emit(currentState.copyWith(
|
||||
steps: updatedSteps, stepDescriptions: updatedStepDescriptions,),);
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
steps: updatedSteps,
|
||||
stepDescriptions: updatedStepDescriptions,
|
||||
),
|
||||
);
|
||||
await _reloadScreen(event, emit);
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _createRecipe(
|
||||
CreateRecipe event, Emitter<RecipeCreateState> emit,) async {
|
||||
CreateRecipe event,
|
||||
Emitter<RecipeCreateState> emit,
|
||||
) async {
|
||||
if (state is RecipeCreateLoadedState) {
|
||||
var currentState = state as RecipeCreateLoadedState;
|
||||
|
||||
@@ -112,14 +131,19 @@ class RecipeCreateBloc extends Bloc<RecipeCreateEvent, RecipeCreateState> {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('recipeSelectScreen');
|
||||
} else {
|
||||
print(
|
||||
'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}',);
|
||||
'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<http.Response> sendRecipe(String? title, String? video_url,
|
||||
String? description, List<dynamic>? steps,) async {
|
||||
String url = '${dotenv.env['SERVER_ROOT']!}/recipe/create';
|
||||
FutureOr<http.Response> sendRecipe(
|
||||
String? title,
|
||||
String? video_url,
|
||||
String? description,
|
||||
List<dynamic>? steps,
|
||||
) async {
|
||||
String url = '${baseUrl}/api/recipe/create';
|
||||
final Map<String, dynamic> credentials = {
|
||||
'title': title,
|
||||
'description': description,
|
||||
@@ -141,7 +165,9 @@ class RecipeCreateBloc extends Bloc<RecipeCreateEvent, RecipeCreateState> {
|
||||
}
|
||||
|
||||
FutureOr<void> _reloadScreen(
|
||||
RecipeCreateEvent? event, Emitter<RecipeCreateState> emit,) async {
|
||||
RecipeCreateEvent? event,
|
||||
Emitter<RecipeCreateState> emit,
|
||||
) async {
|
||||
print('Reloading..');
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
@@ -150,7 +176,8 @@ class RecipeCreateBloc extends Bloc<RecipeCreateEvent, RecipeCreateState> {
|
||||
}
|
||||
if (state is RecipeCreateLoadedState) {
|
||||
var currentState = state as RecipeCreateLoadedState;
|
||||
emit(currentState.copyWith(
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
recipeModelObj: currentState.recipeModelObj,
|
||||
title: currentState.title,
|
||||
token: currentState.token,
|
||||
@@ -158,7 +185,9 @@ class RecipeCreateBloc extends Bloc<RecipeCreateEvent, RecipeCreateState> {
|
||||
video_url: currentState.video_url,
|
||||
steps: currentState.steps,
|
||||
stepDescriptions: currentState.stepDescriptions,
|
||||
tags: currentState.tags,),);
|
||||
tags: currentState.tags,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,16 @@ class RecipeCreateState extends Equatable {
|
||||
}
|
||||
|
||||
class RecipeCreateLoadedState extends RecipeCreateState {
|
||||
RecipeCreateLoadedState(
|
||||
{this.recipeModelObj,
|
||||
this.token,
|
||||
this.title,
|
||||
this.description,
|
||||
this.video_url,
|
||||
this.tags,
|
||||
this.stepDescriptions,
|
||||
this.steps,});
|
||||
RecipeCreateLoadedState({
|
||||
this.recipeModelObj,
|
||||
this.token,
|
||||
this.title,
|
||||
this.description,
|
||||
this.video_url,
|
||||
this.tags,
|
||||
this.stepDescriptions,
|
||||
this.steps,
|
||||
});
|
||||
|
||||
RecipeCreateModel? recipeModelObj;
|
||||
String? token;
|
||||
@@ -62,14 +63,15 @@ class RecipeCreateLoadedState extends RecipeCreateState {
|
||||
List<TextEditingController>? stepDescriptions,
|
||||
}) {
|
||||
return RecipeCreateLoadedState(
|
||||
recipeModelObj: recipeModelObj ?? this.recipeModelObj,
|
||||
title: title ?? this.title,
|
||||
description: description ?? this.description,
|
||||
video_url: video_url ?? this.video_url,
|
||||
token: token ?? this.token,
|
||||
steps: steps ?? this.steps,
|
||||
tags: tags ?? this.tags,
|
||||
stepDescriptions: stepDescriptions ?? this.stepDescriptions,);
|
||||
recipeModelObj: recipeModelObj ?? this.recipeModelObj,
|
||||
title: title ?? this.title,
|
||||
description: description ?? this.description,
|
||||
video_url: video_url ?? this.video_url,
|
||||
token: token ?? this.token,
|
||||
steps: steps ?? this.steps,
|
||||
tags: tags ?? this.tags,
|
||||
stepDescriptions: stepDescriptions ?? this.stepDescriptions,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +85,5 @@ class RecipeCreateErrorState extends RecipeCreateState {
|
||||
}
|
||||
|
||||
class RecipeCreateInitialState extends RecipeCreateState {
|
||||
RecipeCreateInitialState({required RecipeCreateModel recipeModelObj})
|
||||
: super(recipeModelObj: recipeModelObj);
|
||||
RecipeCreateInitialState({required RecipeCreateModel recipeModelObj}) : super(recipeModelObj: recipeModelObj);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
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/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
|
||||
class RecipeCreateScreen extends StatelessWidget {
|
||||
const RecipeCreateScreen({Key? key}) : super(key: key);
|
||||
@@ -16,9 +16,10 @@ class RecipeCreateScreen extends StatelessWidget {
|
||||
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(),);
|
||||
create: (context) =>
|
||||
RecipeCreateBloc(RecipeCreateState(recipeModelObj: RecipeCreateModel(recipeID: recipeID.toString())))..add(RecipeCreateInitialEvent()),
|
||||
child: RecipeCreateScreen(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -53,29 +54,33 @@ class RecipeCreateScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: refreshPage(context),
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: ListView(children: [
|
||||
_buldAppBar(context),
|
||||
SizedBox(height: 20.v),
|
||||
_buildRecipeInfo(state, context),
|
||||
SizedBox(height: 20.v),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: steps,
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
_buildAdditional(context, state),
|
||||
],),
|
||||
),),);
|
||||
onRefresh: refreshPage(context),
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(color: Colors.grey[200]),
|
||||
child: ListView(
|
||||
children: [
|
||||
_buldAppBar(context),
|
||||
SizedBox(height: 20.v),
|
||||
_buildRecipeInfo(state, context),
|
||||
SizedBox(height: 20.v),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: steps,
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
_buildAdditional(context, state),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buldAppBar(BuildContext context) {
|
||||
@@ -102,10 +107,11 @@ class RecipeCreateScreen extends StatelessWidget {
|
||||
onTap: onTapBack(context),
|
||||
),
|
||||
title: Align(
|
||||
alignment: Alignment.center,
|
||||
child: AppbarSubtitle(
|
||||
text: "Добавление рецепта",
|
||||
),),
|
||||
alignment: Alignment.center,
|
||||
child: AppbarSubtitle(
|
||||
text: "Добавление рецепта",
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -130,41 +136,44 @@ class RecipeCreateScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Изображение")),
|
||||
_buildAddPhoto(context, state),
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Название рецепта")),
|
||||
CustomTextFormField(
|
||||
controller: state.title,
|
||||
hintText: "Введите название рецепта",
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Изображение")),
|
||||
_buildAddPhoto(context, state),
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Название рецепта")),
|
||||
CustomTextFormField(
|
||||
controller: state.title,
|
||||
hintText: "Введите название рецепта",
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Описание")),
|
||||
CustomTextFormField(
|
||||
controller: state.description,
|
||||
hintText: "Введите описание рецепта",
|
||||
maxLines: 4,
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Описание")),
|
||||
CustomTextFormField(
|
||||
controller: state.description,
|
||||
hintText: "Введите описание рецепта",
|
||||
maxLines: 4,
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
],),
|
||||
SizedBox(height: 16.0),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -254,71 +263,74 @@ class RecipeCreateScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Шаг ${i + 1}",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
CustomTextFormField(
|
||||
controller: state.stepDescriptions?[i],
|
||||
hintText: "Введите описание шага",
|
||||
maxLines: 4,
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Шаг ${i + 1}",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
_buildAddPhoto(context, state),
|
||||
SizedBox(height: 16.0),
|
||||
if (isFirstStep && isLastStep)
|
||||
CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeCreateBloc>().add(AddStep()),
|
||||
text: "Добавить шаг",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
if (isLastStep && !isFirstStep) // Добавляем кнопку "Добавить шаг" только для последнего шага
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 5,
|
||||
child: CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeCreateBloc>().add(AddStep()),
|
||||
text: "Добавить шаг",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8), // Add some spacing between the buttons
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: CustomOutlinedButton(
|
||||
text: "х",
|
||||
onPressed: () => context.read<RecipeCreateBloc>().add(RemoveStep(i)),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
),
|
||||
],
|
||||
SizedBox(height: 8.0),
|
||||
CustomTextFormField(
|
||||
controller: state.stepDescriptions?[i],
|
||||
hintText: "Введите описание шага",
|
||||
maxLines: 4,
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!isLastStep && !isFirstStep)
|
||||
CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeCreateBloc>().add(RemoveStep(i)),
|
||||
text: "x",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
],),
|
||||
SizedBox(height: 16.0),
|
||||
_buildAddPhoto(context, state),
|
||||
SizedBox(height: 16.0),
|
||||
if (isFirstStep && isLastStep)
|
||||
CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeCreateBloc>().add(AddStep()),
|
||||
text: "Добавить шаг",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
if (isLastStep && !isFirstStep) // Добавляем кнопку "Добавить шаг" только для последнего шага
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 5,
|
||||
child: CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeCreateBloc>().add(AddStep()),
|
||||
text: "Добавить шаг",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8), // Add some spacing between the buttons
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: CustomOutlinedButton(
|
||||
text: "х",
|
||||
onPressed: () => context.read<RecipeCreateBloc>().add(RemoveStep(i)),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!isLastStep && !isFirstStep)
|
||||
CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeCreateBloc>().add(RemoveStep(i)),
|
||||
text: "x",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -342,40 +354,43 @@ class RecipeCreateScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Теги")),
|
||||
CustomTextFormField(
|
||||
controller: state.tags,
|
||||
hintText: "Введите теги, через запятую",
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Теги")),
|
||||
CustomTextFormField(
|
||||
controller: state.tags,
|
||||
hintText: "Введите теги, через запятую",
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Ссылка на видео (необязательно)")),
|
||||
CustomTextFormField(
|
||||
controller: state.video_url,
|
||||
hintText: "YouTube",
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
SizedBox(height: 8.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Ссылка на видео (необязательно)")),
|
||||
CustomTextFormField(
|
||||
controller: state.video_url,
|
||||
hintText: "YouTube",
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
CustomOutlinedButton(
|
||||
text: "Добавить рецепт",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
],),
|
||||
SizedBox(height: 16.0),
|
||||
CustomOutlinedButton(
|
||||
text: "Добавить рецепт",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_edit_screen/models/recipe_edit_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:go_router/go_router.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';
|
||||
import 'package:go_router/go_router.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.
|
||||
@@ -37,7 +36,7 @@ class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
|
||||
}
|
||||
final String? recipeID = state.recipeModelObj?.recipeID;
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/recipes/show/$recipeID'),
|
||||
Uri.parse(baseUrl + '/api/recipes/show/$recipeID'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
@@ -166,7 +165,7 @@ class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
|
||||
String? description,
|
||||
) async {
|
||||
int id = recipe?['id'];
|
||||
String url = '${dotenv.env['SERVER_ROOT']!}/recipe/update/$id';
|
||||
String url = '${baseUrl}/api/recipe/update/$id';
|
||||
|
||||
final Map<String, dynamic> credentials = {
|
||||
'id': id,
|
||||
@@ -200,7 +199,7 @@ class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
|
||||
}
|
||||
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/recipes/getTags/$id'),
|
||||
Uri.parse(baseUrl + '/api/recipes/getTags/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
|
||||
@@ -22,17 +22,18 @@ class RecipeEditState extends Equatable {
|
||||
}
|
||||
|
||||
class RecipeEditLoadedState extends RecipeEditState {
|
||||
RecipeEditLoadedState(
|
||||
{this.recipeModelObj,
|
||||
this.token,
|
||||
this.recipe,
|
||||
this.title,
|
||||
this.description,
|
||||
this.video_url,
|
||||
this.tagsController,
|
||||
this.stepDescriptions,
|
||||
this.tags,
|
||||
this.steps,});
|
||||
RecipeEditLoadedState({
|
||||
this.recipeModelObj,
|
||||
this.token,
|
||||
this.recipe,
|
||||
this.title,
|
||||
this.description,
|
||||
this.video_url,
|
||||
this.tagsController,
|
||||
this.stepDescriptions,
|
||||
this.tags,
|
||||
this.steps,
|
||||
});
|
||||
|
||||
RecipeEditModel? recipeModelObj;
|
||||
Map<String, dynamic>? recipe;
|
||||
@@ -45,8 +46,7 @@ class RecipeEditLoadedState extends RecipeEditState {
|
||||
List<dynamic>? tags;
|
||||
List<TextEditingController>? stepDescriptions;
|
||||
@override
|
||||
List<Object?> get props =>
|
||||
[recipeModelObj, recipe, title, description, video_url];
|
||||
List<Object?> get props => [recipeModelObj, recipe, title, description, video_url];
|
||||
RecipeEditLoadedState copyWith({
|
||||
RecipeEditModel? recipeModelObj,
|
||||
Map<String, dynamic>? recipe,
|
||||
@@ -84,6 +84,5 @@ class RecipeEditErrorState extends RecipeEditState {
|
||||
}
|
||||
|
||||
class RecipeEditInitialState extends RecipeEditState {
|
||||
RecipeEditInitialState({required RecipeEditModel recipeModelObj})
|
||||
: super(recipeModelObj: recipeModelObj);
|
||||
RecipeEditInitialState({required RecipeEditModel recipeModelObj}) : super(recipeModelObj: recipeModelObj);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/recipe_edit_bloc.dart';
|
||||
import 'models/recipe_edit_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
|
||||
class RecipeEditScreen extends StatelessWidget {
|
||||
const RecipeEditScreen({Key? key}) : super(key: key);
|
||||
@@ -18,8 +17,9 @@ class RecipeEditScreen extends StatelessWidget {
|
||||
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(),);
|
||||
create: (context) => RecipeEditBloc(RecipeEditState(recipeModelObj: RecipeEditModel(recipeID: recipeID.toString())))..add(RecipeEditInitialEvent()),
|
||||
child: RecipeEditScreen(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -109,10 +109,11 @@ class RecipeEditScreen extends StatelessWidget {
|
||||
onTap: onTapBack(context),
|
||||
),
|
||||
title: Align(
|
||||
alignment: Alignment.center,
|
||||
child: AppbarSubtitle(
|
||||
text: "Редактирование рецепта",
|
||||
),),
|
||||
alignment: Alignment.center,
|
||||
child: AppbarSubtitle(
|
||||
text: "Редактирование рецепта",
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -137,52 +138,55 @@ class RecipeEditScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Изображение")),
|
||||
if (state.recipe?['image'] != null)
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.recipe?['image']),
|
||||
width: double.infinity,
|
||||
// Установите ширину равной ширине родительского элемента
|
||||
height: 200.0,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
)
|
||||
else
|
||||
_buildAddPhoto(context, state),
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Название рецепта")),
|
||||
CustomTextFormField(
|
||||
controller: state.title,
|
||||
hintText: "Введите название рецепта",
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Изображение")),
|
||||
if (state.recipe?['image'] != null)
|
||||
CachedNetworkImage(
|
||||
imageUrl: baseUrl + '/storage/' + (state.recipe?['image']),
|
||||
width: double.infinity,
|
||||
// Установите ширину равной ширине родительского элемента
|
||||
height: 200.0,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
)
|
||||
else
|
||||
_buildAddPhoto(context, state),
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Название рецепта")),
|
||||
CustomTextFormField(
|
||||
controller: state.title,
|
||||
hintText: "Введите название рецепта",
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Описание")),
|
||||
CustomTextFormField(
|
||||
controller: state.description,
|
||||
hintText: "Введите описание рецепта",
|
||||
maxLines: 4,
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
SizedBox(height: 16.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Описание")),
|
||||
CustomTextFormField(
|
||||
controller: state.description,
|
||||
hintText: "Введите описание рецепта",
|
||||
maxLines: 4,
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
],),
|
||||
SizedBox(height: 16.0),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -272,83 +276,86 @@ class RecipeEditScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Шаг ${i + 1}",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
CustomTextFormField(
|
||||
controller: state.stepDescriptions?[i],
|
||||
hintText: "Введите описание шага",
|
||||
maxLines: 4,
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Шаг ${i + 1}",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
if (state.steps?[i]['image'] != null)
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.steps?[i]['image']),
|
||||
width: double.infinity,
|
||||
// Установите ширину равной ширине родительского элемента
|
||||
height: 200.0,
|
||||
// Задайте постоянную высоту элемента
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
)
|
||||
else
|
||||
_buildAddPhoto(context, state),
|
||||
SizedBox(height: 16.0),
|
||||
if (isFirstStep && isLastStep)
|
||||
CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeEditBloc>().add(AddStep()),
|
||||
text: "Добавить шаг",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
if (isLastStep && !isFirstStep) // Добавляем кнопку "Добавить шаг" только для последнего шага
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 5,
|
||||
child: CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeEditBloc>().add(AddStep()),
|
||||
text: "Добавить шаг",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8), // Add some spacing between the buttons
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: CustomOutlinedButton(
|
||||
text: "х",
|
||||
onPressed: () => context.read<RecipeEditBloc>().add(RemoveStep(i)),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
),
|
||||
],
|
||||
SizedBox(height: 8.0),
|
||||
CustomTextFormField(
|
||||
controller: state.stepDescriptions?[i],
|
||||
hintText: "Введите описание шага",
|
||||
maxLines: 4,
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!isLastStep && !isFirstStep)
|
||||
CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeEditBloc>().add(RemoveStep(i)),
|
||||
text: "x",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
],),
|
||||
SizedBox(height: 16.0),
|
||||
if (state.steps?[i]['image'] != null)
|
||||
CachedNetworkImage(
|
||||
imageUrl: baseUrl + '/storage/' + (state.steps?[i]['image']),
|
||||
width: double.infinity,
|
||||
// Установите ширину равной ширине родительского элемента
|
||||
height: 200.0,
|
||||
// Задайте постоянную высоту элемента
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
)
|
||||
else
|
||||
_buildAddPhoto(context, state),
|
||||
SizedBox(height: 16.0),
|
||||
if (isFirstStep && isLastStep)
|
||||
CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeEditBloc>().add(AddStep()),
|
||||
text: "Добавить шаг",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
if (isLastStep && !isFirstStep) // Добавляем кнопку "Добавить шаг" только для последнего шага
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 5,
|
||||
child: CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeEditBloc>().add(AddStep()),
|
||||
text: "Добавить шаг",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8), // Add some spacing between the buttons
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: CustomOutlinedButton(
|
||||
text: "х",
|
||||
onPressed: () => context.read<RecipeEditBloc>().add(RemoveStep(i)),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!isLastStep && !isFirstStep)
|
||||
CustomOutlinedButton(
|
||||
onPressed: () => context.read<RecipeEditBloc>().add(RemoveStep(i)),
|
||||
text: "x",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -372,29 +379,32 @@ class RecipeEditScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Теги")),
|
||||
_buildEditableTags(state.tags),
|
||||
SizedBox(height: 8.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Ссылка на видео (необязательно)")),
|
||||
CustomTextFormField(
|
||||
controller: state.video_url,
|
||||
hintText: "YouTube",
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Теги")),
|
||||
_buildEditableTags(state.tags),
|
||||
SizedBox(height: 8.0),
|
||||
Align(alignment: Alignment.centerLeft, child: Text("Ссылка на видео (необязательно)")),
|
||||
CustomTextFormField(
|
||||
controller: state.video_url,
|
||||
hintText: "YouTube",
|
||||
fillColor: appTheme.gray50,
|
||||
borderDecoration: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5.h),
|
||||
borderSide: BorderSide(
|
||||
color: appTheme.gray50,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
CustomOutlinedButton(
|
||||
text: "Добавить рецепт",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
],),
|
||||
SizedBox(height: 16.0),
|
||||
CustomOutlinedButton(
|
||||
text: "Добавить рецепт",
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/locator_service.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_select_screen/models/recipe_select_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_select_screen/models/recipe_select_model.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import '/core/app_export.dart';
|
||||
|
||||
part 'recipe_select_event.dart';
|
||||
part 'recipe_select_state.dart';
|
||||
@@ -31,7 +31,7 @@ class RecipeSelectBloc extends Bloc<RecipeSelectEvent, RecipeSelectState> {
|
||||
if (token == null) {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final response = await sl<Dio>().get(dotenv.env['SERVER_ROOT']! + '/recipes/index');
|
||||
final response = await sl<Dio>().get(baseUrl + '/api/recipes/index');
|
||||
print('Got response');
|
||||
if (response.statusCode == 200) {
|
||||
print('Got 200');
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/recipe_select_bloc.dart';
|
||||
import 'models/recipe_select_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RecipeSelectScreen extends StatelessWidget {
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<RecipeSelectBloc>(
|
||||
create: (context) => RecipeSelectBloc(RecipeSelectState(myProfileModelObj: RecipeSelectModel()))..add(RecipeSelectInitialEvent()),
|
||||
child: RecipeSelectScreen(),);
|
||||
create: (context) => RecipeSelectBloc(RecipeSelectState(myProfileModelObj: RecipeSelectModel()))..add(RecipeSelectInitialEvent()),
|
||||
child: RecipeSelectScreen(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -118,50 +118,51 @@ class RecipeSelectScreen extends StatelessWidget {
|
||||
itemBuilder: (context, index) {
|
||||
final post = state.posts?[index];
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
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),
|
||||
),
|
||||
],
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
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: ListTile(
|
||||
leading: CachedNetworkImage(
|
||||
imageUrl: baseUrl + '/storage/' + post['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,
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
leading: CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + post['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,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
post?['title'] ?? '',
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
subtitle: Text(post?['description'] ?? ''),
|
||||
title: Text(
|
||||
post?['title'] ?? '',
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
subtitle: Text(post?['description'] ?? ''),
|
||||
onTap: () => GoRouter.of(context).goNamed(
|
||||
'recipeScreen',
|
||||
extra: post?['id'].toString(),
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
onTap: () => GoRouter.of(context).goNamed(
|
||||
'recipeScreen',
|
||||
'recipeEditScreen',
|
||||
extra: post?['id'].toString(),
|
||||
),
|
||||
trailing: GestureDetector(
|
||||
onTap: () => GoRouter.of(context).goNamed(
|
||||
'recipeEditScreen',
|
||||
extra: post?['id'].toString(),
|
||||
),
|
||||
child: Icon(Icons.edit),
|
||||
),
|
||||
),);
|
||||
child: Icon(Icons.edit),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_screen/models/comment_model.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_show_screen/models/recipe_show_model.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:intl/intl.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_show_screen/models/recipe_show_model.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_screen/models/comment_model.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
part 'recipe_show_event.dart';
|
||||
|
||||
part 'recipe_show_state.dart';
|
||||
|
||||
/// A bloc that manages the state of a Recipe according to the event that is dispatched to it.
|
||||
@@ -37,7 +36,7 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
}
|
||||
final String? recipeID = state.recipeModelObj?.recipeID;
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/recipes/show/$recipeID'),
|
||||
Uri.parse(baseUrl + '/api/recipes/show/$recipeID'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
@@ -93,7 +92,7 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
}
|
||||
final int id = event.id;
|
||||
final response = await http.post(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/recipes/delete/$id'),
|
||||
Uri.parse(baseUrl + '/api/recipes/delete/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
@@ -131,7 +130,7 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
}
|
||||
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/recipes/getAuthor/$id'),
|
||||
Uri.parse(baseUrl + '/api/recipes/getAuthor/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
@@ -147,7 +146,7 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/recipes/getComments/$id'),
|
||||
Uri.parse(baseUrl + '/api/recipes/getComments/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
@@ -165,7 +164,7 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
}
|
||||
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/recipes/getTags/$id'),
|
||||
Uri.parse(baseUrl + '/api/recipes/getTags/$id'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
@@ -191,7 +190,7 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
}
|
||||
|
||||
Future<http.Response> _sendCommentData(String? token, String body, int id) async {
|
||||
String url = dotenv.env['SERVER_ROOT']! + '/recipes/createComment/$id';
|
||||
String url = baseUrl + '/api/recipes/createComment/$id';
|
||||
final Map<String, dynamic> credentials = {
|
||||
'id': id,
|
||||
'body': body,
|
||||
|
||||
@@ -22,15 +22,16 @@ class RecipeState extends Equatable {
|
||||
}
|
||||
|
||||
class RecipeLoadedState extends RecipeState {
|
||||
RecipeLoadedState(
|
||||
{this.recipeModelObj,
|
||||
this.recipe,
|
||||
this.author,
|
||||
this.comments,
|
||||
this.token,
|
||||
this.commentController,
|
||||
this.tags,
|
||||
this.steps,});
|
||||
RecipeLoadedState({
|
||||
this.recipeModelObj,
|
||||
this.recipe,
|
||||
this.author,
|
||||
this.comments,
|
||||
this.token,
|
||||
this.commentController,
|
||||
this.tags,
|
||||
this.steps,
|
||||
});
|
||||
|
||||
RecipeModel? recipeModelObj;
|
||||
Map<String, dynamic>? recipe;
|
||||
@@ -50,15 +51,16 @@ class RecipeLoadedState extends RecipeState {
|
||||
commentController,
|
||||
steps,
|
||||
];
|
||||
RecipeLoadedState copyWith(
|
||||
{RecipeModel? recipeModelObj,
|
||||
Map<String, dynamic>? recipe,
|
||||
Map<String, dynamic>? author,
|
||||
TextEditingController? commentController,
|
||||
String? token,
|
||||
List<dynamic>? tags,
|
||||
List<dynamic>? steps,
|
||||
List<dynamic>? comments,}) {
|
||||
RecipeLoadedState copyWith({
|
||||
RecipeModel? recipeModelObj,
|
||||
Map<String, dynamic>? recipe,
|
||||
Map<String, dynamic>? author,
|
||||
TextEditingController? commentController,
|
||||
String? token,
|
||||
List<dynamic>? tags,
|
||||
List<dynamic>? steps,
|
||||
List<dynamic>? comments,
|
||||
}) {
|
||||
return RecipeLoadedState(
|
||||
recipeModelObj: recipeModelObj ?? this.recipeModelObj,
|
||||
recipe: recipe ?? this.recipe,
|
||||
@@ -82,6 +84,5 @@ class RecipeErrorState extends RecipeState {
|
||||
}
|
||||
|
||||
class RecipeInitialState extends RecipeState {
|
||||
RecipeInitialState({required RecipeModel recipeModelObj})
|
||||
: super(recipeModelObj: recipeModelObj);
|
||||
RecipeInitialState({required RecipeModel recipeModelObj}) : super(recipeModelObj: recipeModelObj);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_screen/widgets/comment_widget.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'bloc/recipe_show_bloc.dart';
|
||||
import 'models/recipe_show_model.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_screen/widgets/comment_widget.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
class RecipeScreen extends StatelessWidget {
|
||||
const RecipeScreen({Key? key}) : super(key: key);
|
||||
@@ -17,8 +16,9 @@ class RecipeScreen extends StatelessWidget {
|
||||
static Widget builder(BuildContext context) {
|
||||
final recipeID = ModalRoute.of(context)!.settings.arguments;
|
||||
return BlocProvider<RecipeBloc>(
|
||||
create: (context) => RecipeBloc(RecipeState(recipeModelObj: RecipeModel(recipeID: recipeID.toString())))..add(RecipeInitialEvent()),
|
||||
child: RecipeScreen(),);
|
||||
create: (context) => RecipeBloc(RecipeState(recipeModelObj: RecipeModel(recipeID: recipeID.toString())))..add(RecipeInitialEvent()),
|
||||
child: RecipeScreen(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -52,32 +52,33 @@ class RecipeScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 15.v),
|
||||
_buildHeaderRow(context, state),
|
||||
SizedBox(height: 15.v),
|
||||
_buildRecipeData(context, state),
|
||||
SizedBox(height: 15.v),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: steps,
|
||||
),
|
||||
SizedBox(height: 15.v),
|
||||
_buildTextField(context, state),
|
||||
SizedBox(height: 15.v),
|
||||
_buildCommentSection(context, state),
|
||||
],
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 15.v),
|
||||
_buildHeaderRow(context, state),
|
||||
SizedBox(height: 15.v),
|
||||
_buildRecipeData(context, state),
|
||||
SizedBox(height: 15.v),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: steps,
|
||||
),
|
||||
SizedBox(height: 15.v),
|
||||
_buildTextField(context, state),
|
||||
SizedBox(height: 15.v),
|
||||
_buildCommentSection(context, state),
|
||||
],
|
||||
),
|
||||
),);
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buildHeaderRow(BuildContext context, RecipeLoadedState state) {
|
||||
@@ -119,7 +120,7 @@ class RecipeScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.author?['profile_photo_path'] ?? ''),
|
||||
imageUrl: baseUrl + '/storage/' + (state.author?['profile_photo_path'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
@@ -159,75 +160,86 @@ class RecipeScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
state.recipe?['title'],
|
||||
style: CustomTextStyles.titleMediumBlack,
|
||||
),
|
||||
Spacer(),
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (value) => tapMenu(value, context, state),
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
PopupMenuItem<String>(
|
||||
value: 'edit',
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'delete',
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
_buildImage(state),
|
||||
SizedBox(height: 16.0),
|
||||
Text(
|
||||
state.recipe?['description'],
|
||||
style: CustomTextStyles.bodyMediumBluegray800,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Align(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
state.recipe?['title'],
|
||||
style: CustomTextStyles.titleMediumBlack,
|
||||
),
|
||||
Spacer(),
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (value) => tapMenu(value, context, state),
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
PopupMenuItem<String>(
|
||||
value: 'edit',
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'delete',
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
_buildImage(state),
|
||||
SizedBox(height: 16.0),
|
||||
Text(
|
||||
state.recipe?['description'],
|
||||
style: CustomTextStyles.bodyMediumBluegray800,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
DateFormat('dd.MM.yyyy').format(DateTime.parse(state.recipe?['updated_at'])),
|
||||
style: theme.textTheme.bodyMedium,
|
||||
),),
|
||||
SizedBox(height: 16.0),
|
||||
_buildTags(state.tags),
|
||||
SizedBox(height: 16.0),
|
||||
Row(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 24),
|
||||
child: Row(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 8),
|
||||
child: Icon(Icons.favorite_outline),
|
||||
),
|
||||
Text(
|
||||
"Нравится",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
],),
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 24),
|
||||
child: Row(children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: Icon(Icons.share_outlined),
|
||||
SizedBox(height: 16.0),
|
||||
_buildTags(state.tags),
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 24),
|
||||
child: Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 8),
|
||||
child: Icon(Icons.favorite_outline),
|
||||
),
|
||||
Text(
|
||||
"Нравится",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
"Поделиться",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
Spacer(),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 24),
|
||||
child: Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: Icon(Icons.share_outlined),
|
||||
),
|
||||
Text(
|
||||
"Поделиться",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
],
|
||||
),
|
||||
],),),
|
||||
],),
|
||||
],),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -245,7 +257,7 @@ class RecipeScreen extends StatelessWidget {
|
||||
|
||||
_buildImage(RecipeLoadedState state) {
|
||||
return CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.recipe?['image'] ?? ''),
|
||||
imageUrl: baseUrl + '/storage/' + (state.recipe?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
@@ -431,28 +443,31 @@ class RecipeScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Шаг ${i + 1}",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Шаг ${i + 1}",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.steps?[i]['image']),
|
||||
width: double.infinity,
|
||||
// Установите ширину равной ширине родительского элемента
|
||||
height: 200.0,
|
||||
// Задайте постоянную высоту элемента
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(state.steps?[i]['description']),
|
||||
],),
|
||||
SizedBox(height: 16.0),
|
||||
CachedNetworkImage(
|
||||
imageUrl: baseUrl + '/storage/' + (state.steps?[i]['image']),
|
||||
width: double.infinity,
|
||||
// Установите ширину равной ширине родительского элемента
|
||||
height: 200.0,
|
||||
// Задайте постоянную высоту элемента
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(state.steps?[i]['description']),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/feed/blog_post_screen/models/comment_model.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CommentWidget extends StatelessWidget {
|
||||
CommentWidget(this.commentModelObj, {Key? key})
|
||||
@@ -36,13 +35,11 @@ class CommentWidget extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment
|
||||
.spaceBetween, // Move the main axis alignment to space between
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center, // Center the items vertically
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Move the main axis alignment to space between
|
||||
crossAxisAlignment: CrossAxisAlignment.center, // Center the items vertically
|
||||
children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + commentModelObj.userImage!,
|
||||
imageUrl: baseUrl + '/storage/' + commentModelObj.userImage!,
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
@@ -69,10 +66,7 @@ class CommentWidget extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
commentModelObj.username!.length <= 15
|
||||
? commentModelObj.username!
|
||||
: commentModelObj.username!.substring(0, 15) +
|
||||
'...',
|
||||
commentModelObj.username!.length <= 15 ? commentModelObj.username! : commentModelObj.username!.substring(0, 15) + '...',
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
Spacer(),
|
||||
@@ -96,10 +90,11 @@ class CommentWidget extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
CustomImageView(
|
||||
imagePath: ImageConstant.imgSend,
|
||||
height: 30.v,
|
||||
width: 30.h,
|
||||
margin: EdgeInsets.only(left: 5),),
|
||||
imagePath: ImageConstant.imgSend,
|
||||
height: 30.v,
|
||||
width: 30.h,
|
||||
margin: EdgeInsets.only(left: 5),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user