Merge remote-tracking branch 'upstream/main'

This commit is contained in:
Username1548
2025-03-26 19:51:16 +07:00
42 changed files with 1112 additions and 452 deletions

View File

@@ -85,24 +85,47 @@ class _BlogPostScreenState extends State<BlogPostScreen> {
if (replyId != null) SizedBox(width: 8),
SizedBox(
width: MediaQuery.of(context).size.width - (replyId == null ? 64 : 104),
child: TextFormField(
onChanged: (_) {
setState(() {});
},
controller: textEditingController,
maxLines: 5,
minLines: 1,
keyboardType: TextInputType.multiline,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w400, color: Colors.black, height: 1),
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
hintText: 'Комментарий',
hintStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w400, height: 1, color: Color(0xFFAEAEB2)),
filled: true,
border: OutlineInputBorder(borderRadius: BorderRadius.circular(16), borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1)),
enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(16), borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1)),
focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(16), borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1)),
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: 52),
child: TextFormField(
textCapitalization: TextCapitalization.sentences,
onChanged: (_) {
setState(() {});
},
controller: textEditingController,
maxLines: 5,
minLines: 1,
keyboardType: TextInputType.multiline,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black,
height: 1.2,
),
decoration: InputDecoration(
isDense: false, // убираем true, чтобы padding учитывался корректно
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), // вертикальный паддинг увеличен
hintText: 'Комментарий',
hintStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
height: 1.2,
color: Color(0xFFAEAEB2),
),
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
),
),
),
),

View File

@@ -15,6 +15,7 @@ import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/chat/presentation/widgets/notification_banner.dart';
import 'package:eatvio_app/features/chat/presentation/widgets/order_card.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/plans/enums/chosen_plan_state_enum.dart';
import 'package:eatvio_app/features/user_details/presentation/user_details_screen.dart';
import 'package:eatvio_app/generated/l10n.dart';
@@ -97,37 +98,68 @@ class _ChatScreenState extends State<ChatScreen> {
titleSpacing: 0,
backgroundColor: appTheme.gray100,
centerTitle: false,
title: Row(
children: [
if (state.chatRoom.users.receiver.profilePhotoUrl != null)
CircleAvatar(radius: 20, foregroundImage: NetworkImage(state.chatRoom.users.receiver.profilePhotoUrl!)),
if (state.chatRoom.users.receiver.profilePhotoUrl == null)
Container(
width: 40,
height: 40,
alignment: Alignment.center,
decoration: BoxDecoration(color: Color(0xFFEBF4FF), shape: BoxShape.circle),
child: Text(
state.chatRoom.users.receiver.name.split(' ').first[0] + state.chatRoom.users.receiver.name.split(' ')[1][0],
style: TextStyle(color: Color(0xFF7F9CF5), fontWeight: FontWeight.w400, fontSize: 20),
),
title: GestureDetector(
onTap: () {
GoRouter.of(context).pushNamed(
'profileScreen',
extra: Author(
authorSlug: state.chatRoom.users.receiver.slug,
authorName: state.chatRoom.users.receiver.name,
authorProfileIcon: state.chatRoom.users.receiver.profilePhotoUrl ?? '',
authorIsMe: false,
),
SizedBox(width: 16),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(state.chatRoom.users.receiver.name, style: CustomTextStyles.titleSmallBold.copyWith(color: PrimaryColors().black)),
AnimatedCrossFade(
firstChild: Text('Печатает...', style: CustomTextStyles.bodySmallMulishPrimary),
firstCurve: Curves.easeIn,
secondCurve: Curves.easeOut,
secondChild: const SizedBox.shrink(),
crossFadeState: state.isTyping ? CrossFadeState.showFirst : CrossFadeState.showSecond,
duration: Duration(milliseconds: 150),
);
},
child: Row(
children: [
if (state.chatRoom.users.receiver.profilePhotoUrl != null)
CircleAvatar(
radius: 20,
foregroundImage: NetworkImage(state.chatRoom.users.receiver.profilePhotoUrl!),
),
],
),
],
if (state.chatRoom.users.receiver.profilePhotoUrl == null)
Container(
width: 40,
height: 40,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Color(0xFFEBF4FF),
shape: BoxShape.circle,
),
child: Text(
state.chatRoom.users.receiver.name.split(' ').first[0] + state.chatRoom.users.receiver.name.split(' ')[1][0],
style: TextStyle(
color: Color(0xFF7F9CF5),
fontWeight: FontWeight.w400,
fontSize: 20,
),
),
),
SizedBox(width: 16),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
state.chatRoom.users.receiver.name,
style: CustomTextStyles.titleSmallBold.copyWith(
color: PrimaryColors().black,
),
),
AnimatedCrossFade(
firstChild: Text(
'Печатает...',
style: CustomTextStyles.bodySmallMulishPrimary,
),
firstCurve: Curves.easeIn,
secondCurve: Curves.easeOut,
secondChild: const SizedBox.shrink(),
crossFadeState: state.isTyping ? CrossFadeState.showFirst : CrossFadeState.showSecond,
duration: Duration(milliseconds: 150),
),
],
),
],
),
),
),
body: SafeArea(
@@ -301,6 +333,7 @@ class _ChatScreenState extends State<ChatScreen> {
height: 40,
child: TextFormField(
expands: true,
textCapitalization: TextCapitalization.sentences,
controller: textEditingController,
maxLines: null,
minLines: null,

View File

@@ -81,6 +81,7 @@ class ChatSearchBarWidget extends StatelessWidget {
searchViewWidget(BuildContext context) => SizedBox(
width: width ?? MediaQuery.of(context).size.width,
child: TextFormField(
textCapitalization: TextCapitalization.sentences,
controller: controller,
focusNode: focusNode,
onTapOutside: (event) => onTapOutside(),

View File

@@ -116,6 +116,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
Expanded(
child: SizedBox(
child: TextFormField(
textCapitalization: TextCapitalization.sentences,
onChanged: (_) {
setState(() {});
},

View File

@@ -4,12 +4,9 @@ part 'finish_diary_day_model.freezed.dart';
part 'finish_diary_day_model.g.dart';
@freezed
@Freezed()
class FinishDiaryDayModel with _$FinishDiaryDayModel {
const factory FinishDiaryDayModel({
required String wakeUp,
required String retire,
}) = _FinishDiaryDayModel;
const factory FinishDiaryDayModel({required String wakeUp, required String retire, @JsonKey(includeIfNull: false) String? comment}) = _FinishDiaryDayModel;
factory FinishDiaryDayModel.fromJson(Map<String, Object?> json) => _$FinishDiaryDayModelFromJson(json);
factory FinishDiaryDayModel.fromJson(Map<String, dynamic> json) => _$FinishDiaryDayModelFromJson(json);
}

View File

@@ -23,6 +23,8 @@ FinishDiaryDayModel _$FinishDiaryDayModelFromJson(Map<String, dynamic> json) {
mixin _$FinishDiaryDayModel {
String get wakeUp => throw _privateConstructorUsedError;
String get retire => throw _privateConstructorUsedError;
@JsonKey(includeIfNull: false)
String? get comment => throw _privateConstructorUsedError;
/// Serializes this FinishDiaryDayModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -41,7 +43,11 @@ abstract class $FinishDiaryDayModelCopyWith<$Res> {
$Res Function(FinishDiaryDayModel) then,
) = _$FinishDiaryDayModelCopyWithImpl<$Res, FinishDiaryDayModel>;
@useResult
$Res call({String wakeUp, String retire});
$Res call({
String wakeUp,
String retire,
@JsonKey(includeIfNull: false) String? comment,
});
}
/// @nodoc
@@ -58,7 +64,11 @@ class _$FinishDiaryDayModelCopyWithImpl<$Res, $Val extends FinishDiaryDayModel>
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? wakeUp = null, Object? retire = null}) {
$Res call({
Object? wakeUp = null,
Object? retire = null,
Object? comment = freezed,
}) {
return _then(
_value.copyWith(
wakeUp:
@@ -71,6 +81,11 @@ class _$FinishDiaryDayModelCopyWithImpl<$Res, $Val extends FinishDiaryDayModel>
? _value.retire
: retire // ignore: cast_nullable_to_non_nullable
as String,
comment:
freezed == comment
? _value.comment
: comment // ignore: cast_nullable_to_non_nullable
as String?,
)
as $Val,
);
@@ -86,7 +101,11 @@ abstract class _$$FinishDiaryDayModelImplCopyWith<$Res>
) = __$$FinishDiaryDayModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String wakeUp, String retire});
$Res call({
String wakeUp,
String retire,
@JsonKey(includeIfNull: false) String? comment,
});
}
/// @nodoc
@@ -102,7 +121,11 @@ class __$$FinishDiaryDayModelImplCopyWithImpl<$Res>
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? wakeUp = null, Object? retire = null}) {
$Res call({
Object? wakeUp = null,
Object? retire = null,
Object? comment = freezed,
}) {
return _then(
_$FinishDiaryDayModelImpl(
wakeUp:
@@ -115,6 +138,11 @@ class __$$FinishDiaryDayModelImplCopyWithImpl<$Res>
? _value.retire
: retire // ignore: cast_nullable_to_non_nullable
as String,
comment:
freezed == comment
? _value.comment
: comment // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
@@ -123,7 +151,11 @@ class __$$FinishDiaryDayModelImplCopyWithImpl<$Res>
/// @nodoc
@JsonSerializable()
class _$FinishDiaryDayModelImpl implements _FinishDiaryDayModel {
const _$FinishDiaryDayModelImpl({required this.wakeUp, required this.retire});
const _$FinishDiaryDayModelImpl({
required this.wakeUp,
required this.retire,
@JsonKey(includeIfNull: false) this.comment,
});
factory _$FinishDiaryDayModelImpl.fromJson(Map<String, dynamic> json) =>
_$$FinishDiaryDayModelImplFromJson(json);
@@ -132,10 +164,13 @@ class _$FinishDiaryDayModelImpl implements _FinishDiaryDayModel {
final String wakeUp;
@override
final String retire;
@override
@JsonKey(includeIfNull: false)
final String? comment;
@override
String toString() {
return 'FinishDiaryDayModel(wakeUp: $wakeUp, retire: $retire)';
return 'FinishDiaryDayModel(wakeUp: $wakeUp, retire: $retire, comment: $comment)';
}
@override
@@ -144,12 +179,13 @@ class _$FinishDiaryDayModelImpl implements _FinishDiaryDayModel {
(other.runtimeType == runtimeType &&
other is _$FinishDiaryDayModelImpl &&
(identical(other.wakeUp, wakeUp) || other.wakeUp == wakeUp) &&
(identical(other.retire, retire) || other.retire == retire));
(identical(other.retire, retire) || other.retire == retire) &&
(identical(other.comment, comment) || other.comment == comment));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, wakeUp, retire);
int get hashCode => Object.hash(runtimeType, wakeUp, retire, comment);
/// Create a copy of FinishDiaryDayModel
/// with the given fields replaced by the non-null parameter values.
@@ -172,6 +208,7 @@ abstract class _FinishDiaryDayModel implements FinishDiaryDayModel {
const factory _FinishDiaryDayModel({
required final String wakeUp,
required final String retire,
@JsonKey(includeIfNull: false) final String? comment,
}) = _$FinishDiaryDayModelImpl;
factory _FinishDiaryDayModel.fromJson(Map<String, dynamic> json) =
@@ -181,6 +218,9 @@ abstract class _FinishDiaryDayModel implements FinishDiaryDayModel {
String get wakeUp;
@override
String get retire;
@override
@JsonKey(includeIfNull: false)
String? get comment;
/// Create a copy of FinishDiaryDayModel
/// with the given fields replaced by the non-null parameter values.

View File

@@ -11,8 +11,13 @@ _$FinishDiaryDayModelImpl _$$FinishDiaryDayModelImplFromJson(
) => _$FinishDiaryDayModelImpl(
wakeUp: json['wakeUp'] as String,
retire: json['retire'] as String,
comment: json['comment'] as String?,
);
Map<String, dynamic> _$$FinishDiaryDayModelImplToJson(
_$FinishDiaryDayModelImpl instance,
) => <String, dynamic>{'wakeUp': instance.wakeUp, 'retire': instance.retire};
) => <String, dynamic>{
'wakeUp': instance.wakeUp,
'retire': instance.retire,
if (instance.comment case final value?) 'comment': value,
};

View File

@@ -17,10 +17,7 @@ class DiaryCubit extends Cubit<DiaryState> {
final DiaryRepository diaryRepository;
final GlossaryRepository glossaryRepository;
DiaryCubit({
required this.diaryRepository,
required this.glossaryRepository,
}) : super(const DiaryState.loading()) {
DiaryCubit({required this.diaryRepository, required this.glossaryRepository}) : super(const DiaryState.loading()) {
today = DateTime.now();
selectedDay = today;
}
@@ -56,16 +53,8 @@ class DiaryCubit extends Cubit<DiaryState> {
}
}
finishDiaryDay({
required int diaryId,
required String wakeUp,
required String retire,
}) async {
await diaryRepository.finishDiaryDay(
diaryId: diaryId,
wakeUp: wakeUp,
retire: retire,
);
finishDiaryDay({required int diaryId, required String wakeUp, required String retire, String? comment}) async {
await diaryRepository.finishDiaryDay(diaryId: diaryId, wakeUp: wakeUp, retire: retire, comment: comment);
await fetchDiary();
}
@@ -126,55 +115,23 @@ class DiaryCubit extends Cubit<DiaryState> {
await fetchDiary();
}
markEaten({
required int diaryId,
required int mealId,
required int portionId,
}) async {
await diaryRepository.markEaten(
diaryId: diaryId,
mealId: mealId,
portionId: portionId,
);
markEaten({required int diaryId, required int mealId, required int portionId}) async {
await diaryRepository.markEaten(diaryId: diaryId, mealId: mealId, portionId: portionId);
await fetchDiary();
}
unmarkEaten({
required int diaryId,
required int mealId,
required int portionId,
}) async {
await diaryRepository.unmarkEaten(
diaryId: diaryId,
mealId: mealId,
portionId: portionId,
);
unmarkEaten({required int diaryId, required int mealId, required int portionId}) async {
await diaryRepository.unmarkEaten(diaryId: diaryId, mealId: mealId, portionId: portionId);
await fetchDiary();
}
restore({
required int diaryId,
required int mealId,
required int portionId,
}) async {
await diaryRepository.restore(
diaryId: diaryId,
mealId: mealId,
portionId: portionId,
);
restore({required int diaryId, required int mealId, required int portionId}) async {
await diaryRepository.restore(diaryId: diaryId, mealId: mealId, portionId: portionId);
await fetchDiary();
}
deleteProductFromMeal({
required int diaryId,
required int mealId,
required int portionId,
}) async {
await diaryRepository.deleteProductFromMeal(
diaryId: diaryId,
mealId: mealId,
portionId: portionId,
);
deleteProductFromMeal({required int diaryId, required int mealId, required int portionId}) async {
await diaryRepository.deleteProductFromMeal(diaryId: diaryId, mealId: mealId, portionId: portionId);
await fetchDiary();
}
@@ -182,27 +139,13 @@ class DiaryCubit extends Cubit<DiaryState> {
return await glossaryRepository.getGlossaryListByQuery(query);
}
uploadPhotos({
required List<File> files,
required int diaryId,
}) async {
await diaryRepository.uploadPhotos(
files: await ImageCompressUtility.compressFilesList(files),
diaryId: diaryId,
mealId: selectedMeal,
);
uploadPhotos({required List<File> files, required int diaryId}) async {
await diaryRepository.uploadPhotos(files: await ImageCompressUtility.compressFilesList(files), diaryId: diaryId, mealId: selectedMeal);
await fetchDiary();
}
deletePhoto({
required DiaryPhotoModel photo,
required int diaryId,
}) async {
await diaryRepository.deletePhoto(
photo: photo,
diaryId: diaryId,
mealId: selectedMeal,
);
deletePhoto({required DiaryPhotoModel photo, required int diaryId}) async {
await diaryRepository.deletePhoto(photo: photo, diaryId: diaryId, mealId: selectedMeal);
await fetchDiary();
}
@@ -214,39 +157,37 @@ class DiaryCubit extends Cubit<DiaryState> {
required double carbohydrates,
}) async {
try {
return await diaryRepository.sendProductToModeration(
name: name,
energy: energy,
proteins: proteins,
fats: fats,
carbohydrates: carbohydrates,
);
return await diaryRepository.sendProductToModeration(name: name, energy: energy, proteins: proteins, fats: fats, carbohydrates: carbohydrates);
} catch (e, stackTrace) {
log(e.toString(), stackTrace: stackTrace);
}
return null;
}
fillTime({
required int diaryId,
required String time,
}) async {
await diaryRepository.fillTime(
diaryId: diaryId,
mealId: selectedMeal,
time: time,
);
fillTime({required int diaryId, required String time}) async {
await diaryRepository.fillTime(diaryId: diaryId, mealId: selectedMeal, time: time);
await fetchDiary();
}
fillSatiety({
required int diaryId,
required int satiety,
}) async {
await diaryRepository.fillSatiety(
diaryId: diaryId,
mealId: selectedMeal,
satiety: satiety,
);
fillWakeup({required int diaryId, required String time}) async {
await diaryRepository.fillWakeup(diaryId: diaryId, time: time);
await fetchDiary();
}
fillRetire({required int diaryId, required String time}) async {
await diaryRepository.fillRetire(diaryId: diaryId, time: time);
await fetchDiary();
}
fillSatiety({required int diaryId, required int satiety}) async {
await diaryRepository.fillSatiety(diaryId: diaryId, mealId: selectedMeal, satiety: satiety);
}
fillMood({required int diaryId, required int mood}) async {
await diaryRepository.fillMood(diaryId: diaryId, mealId: selectedMeal, mood: mood);
}
fillComment(String comment) {
emit((state as DiaryStateLoaded).copyWith(diary: (state as DiaryStateLoaded).diary.copyWith(comment: comment)));
}
}

View File

@@ -7,8 +7,10 @@ import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/calendar_widget.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/calories_chart_widget.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/comment_for_consultant_widget.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/finish_day_button_widget.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/meal_widget.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/wakeup_and_retire_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -46,8 +48,12 @@ class _DiaryScreenState extends State<DiaryScreen> {
children: [
CalendarWidget(),
if (state is DiaryStateLoading) const Loader(),
if (state is DiaryStateLoaded) WakeupAndRetireWidget(),
const SizedBox(height: 12),
if (state is DiaryStateLoaded) MealWidget(),
CaloriesChartWidget(),
if (state is DiaryStateLoaded) CaloriesChartWidget(),
const SizedBox(height: 12),
if (state is DiaryStateLoaded) CommentForConsultantWidget(),
if (state is DiaryStateLoaded && state.diary.closed == 0)
Padding(
padding: const EdgeInsets.only(top: 12),

View File

@@ -0,0 +1,44 @@
import 'package:easy_debounce/easy_debounce.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class CommentForConsultantWidget extends StatefulWidget {
const CommentForConsultantWidget({super.key});
@override
State<CommentForConsultantWidget> createState() => _CommentForConsultantWidgetState();
}
class _CommentForConsultantWidgetState extends State<CommentForConsultantWidget> {
@override
Widget build(BuildContext context) {
return Material(
borderRadius: BorderRadius.circular(20),
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Дополнительная информация для консультанта',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: Color(0xFF323F4B), height: 1),
),
const SizedBox(height: 12),
CustomTextFormField(
onChanged: (value) {
EasyDebounce.debounce('client-typing', Duration(seconds: 3), () => context.read<DiaryCubit>().fillComment(value));
},
hintText: 'Укажите дополнительную информацию',
minLines: 4,
maxLines: 4,
),
],
),
),
);
}
}

View File

@@ -7,10 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
class FinishDayButtonWidget extends StatefulWidget {
final DiaryDayModel diaryDay;
const FinishDayButtonWidget({
super.key,
required this.diaryDay,
});
const FinishDayButtonWidget({super.key, required this.diaryDay});
@override
State<FinishDayButtonWidget> createState() => _FinishDayButtonWidgetState();
@@ -20,30 +17,22 @@ class _FinishDayButtonWidgetState extends State<FinishDayButtonWidget> {
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () => context.read<DiaryCubit>().finishDiaryDay(
onTap:
() => context.read<DiaryCubit>().finishDiaryDay(
diaryId: widget.diaryDay.id,
wakeUp: widget.diaryDay.wakeup.toString(),
retire: widget.diaryDay.retire.toString(),
comment: widget.diaryDay.comment.isEmpty ? null : widget.diaryDay.comment,
),
borderRadius: BorderRadius.circular(20),
child: Ink(
padding: EdgeInsets.symmetric(horizontal: 8),
width: MediaQuery.of(context).size.width - 16,
decoration: BoxDecoration(
color: appTheme.blueA400,
borderRadius: BorderRadius.circular(20),
),
decoration: BoxDecoration(color: appTheme.blueA400, borderRadius: BorderRadius.circular(20)),
child: Container(
padding: EdgeInsets.all(16),
alignment: Alignment.center,
child: Text(
'Закончить день',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
child: Text('Закончить день', style: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w600)),
),
),
);

View File

@@ -227,7 +227,7 @@ class _GlossaryModerationRequestModalWidgetState extends State<GlossaryModeratio
child: CustomTextFormField(
hintText: 'Калории',
controller: energyController,
keyboardType: TextInputType.numberWithOptions(),
keyboardType: TextInputType.numberWithOptions(decimal: true),
),
),
const SizedBox(width: 8),
@@ -235,7 +235,7 @@ class _GlossaryModerationRequestModalWidgetState extends State<GlossaryModeratio
child: CustomTextFormField(
hintText: 'Белки',
controller: proteinsController,
keyboardType: TextInputType.numberWithOptions(),
keyboardType: TextInputType.numberWithOptions(decimal: true),
),
),
],
@@ -248,7 +248,7 @@ class _GlossaryModerationRequestModalWidgetState extends State<GlossaryModeratio
child: CustomTextFormField(
hintText: 'Жиры',
controller: fatsController,
keyboardType: TextInputType.numberWithOptions(),
keyboardType: TextInputType.numberWithOptions(decimal: true),
),
),
const SizedBox(width: 8),
@@ -256,7 +256,7 @@ class _GlossaryModerationRequestModalWidgetState extends State<GlossaryModeratio
child: CustomTextFormField(
hintText: 'Углеводы',
controller: carbohydratesController,
keyboardType: TextInputType.numberWithOptions(),
keyboardType: TextInputType.numberWithOptions(decimal: true),
),
),
],
@@ -266,10 +266,10 @@ class _GlossaryModerationRequestModalWidgetState extends State<GlossaryModeratio
onTap: () async {
glossary = (await widget.diaryCubit.sendProductToModeration(
name: productNameController.text,
energy: double.parse(energyController.text),
proteins: double.parse(proteinsController.text),
fats: double.parse(fatsController.text),
carbohydrates: double.parse(carbohydratesController.text),
energy: double.parse(energyController.text.replaceAll(',', '.')),
proteins: double.parse(proteinsController.text.replaceAll(',', '.')),
fats: double.parse(fatsController.text.replaceAll(',', '.')),
carbohydrates: double.parse(carbohydratesController.text.replaceAll(',', '.')),
))
?.glossary;
setState(() {

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/diary/presentation/widgets/add_product_button_widget.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/meal_button_widget.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/mood_rating_widget.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/photo_gallery_widget.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/products_list_widget.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/satiety_rating_widget.dart';
@@ -53,6 +54,8 @@ class _MealWidgetState extends State<MealWidget> {
PhotoGalleryWidget(),
const SizedBox(height: 12),
SatietyRatingWidget(),
const SizedBox(height: 12),
MoodRatingWidget(),
],
),
),

View File

@@ -0,0 +1,199 @@
import 'package:easy_debounce/easy_debounce.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:flutter_svg/flutter_svg.dart';
class MoodRatingWidget extends StatefulWidget {
@override
State<MoodRatingWidget> createState() => _MoodRatingWidgetState();
}
class _MoodRatingWidgetState extends State<MoodRatingWidget> {
late double currentSelectedRating;
bool isFirstFetch = true;
@override
Widget build(BuildContext context) {
return BlocBuilder<DiaryCubit, DiaryState>(
builder: (BuildContext context, DiaryState state) {
if (state is DiaryStateLoaded) {
if (isFirstFetch) {
currentSelectedRating = state.diary.meals[state.selectedMeal - 1].mood.toDouble() + 1;
isFirstFetch = false;
}
return Padding(
padding: const EdgeInsets.only(top: 24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Ваше настроение после приёма пищи',
style: TextStyle(
fontSize: 16,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SvgPicture.asset(
'assets/icons/mood_1.svg',
height: 32,
width: 32,
),
RatingBar.builder(
initialRating: state.diary.meals[state.selectedMeal - 1].mood.toDouble() + 1,
itemCount: 6,
itemSize: MediaQuery.of(context).size.width / 6 - (124 / 6),
updateOnDrag: true,
itemBuilder: (context, index) {
switch (index) {
case 0:
return Container(
width: MediaQuery.of(context).size.width / 6,
height: 24,
margin: currentSelectedRating == 1 ? EdgeInsets.symmetric(horizontal: 2) : null,
decoration: BoxDecoration(
color: Color(0xFFC82222),
border: currentSelectedRating == 1
? Border.all(
width: 2,
color: Color(0xFFAA3333),
strokeAlign: BorderSide.strokeAlignOutside,
)
: null,
borderRadius: currentSelectedRating == 1
? BorderRadius.horizontal(
left: Radius.circular(8),
right: Radius.circular(2),
)
: BorderRadius.horizontal(
left: Radius.circular(8),
),
),
);
case 1:
return Container(
width: MediaQuery.of(context).size.width / 6,
height: 24,
margin: currentSelectedRating == 2 ? EdgeInsets.symmetric(horizontal: 2) : null,
decoration: BoxDecoration(
color: Color(0xFFFF3E3E),
border: currentSelectedRating == 2
? Border.all(
width: 2,
color: Color(0xFF550000),
strokeAlign: BorderSide.strokeAlignOutside,
)
: null,
borderRadius: currentSelectedRating == 2 ? BorderRadius.circular(2) : null,
),
);
case 2:
return Container(
width: MediaQuery.of(context).size.width / 6,
height: 24,
margin: currentSelectedRating == 3 ? EdgeInsets.symmetric(horizontal: 2) : null,
decoration: BoxDecoration(
color: Color(0xFFF8C926),
border: currentSelectedRating == 3
? Border.all(
width: 2,
color: Color(0xFF8C5D00),
strokeAlign: BorderSide.strokeAlignOutside,
)
: null,
borderRadius: currentSelectedRating == 3 ? BorderRadius.circular(2) : null,
),
);
case 3:
return Container(
width: MediaQuery.of(context).size.width / 6,
height: 24,
margin: currentSelectedRating == 4 ? EdgeInsets.symmetric(horizontal: 2) : null,
decoration: BoxDecoration(
color: Color(0xFFFFF3BF),
border: currentSelectedRating == 4
? Border.all(
width: 2,
color: Color(0xFFB5911B),
strokeAlign: BorderSide.strokeAlignOutside,
)
: null,
borderRadius: currentSelectedRating == 4 ? BorderRadius.circular(2) : null,
),
);
case 4:
return Container(
width: MediaQuery.of(context).size.width / 6,
height: 24,
margin: currentSelectedRating == 5 ? EdgeInsets.symmetric(horizontal: 2) : null,
decoration: BoxDecoration(
color: Color(0xFF62E833),
border: currentSelectedRating == 5
? Border.all(
width: 2,
color: Color(0xFF276918),
strokeAlign: BorderSide.strokeAlignOutside,
)
: null,
borderRadius: currentSelectedRating == 5 ? BorderRadius.circular(2) : null,
),
);
default:
return Container(
width: MediaQuery.of(context).size.width / 6,
height: 24,
margin: currentSelectedRating == 6 ? EdgeInsets.symmetric(horizontal: 2) : null,
decoration: BoxDecoration(
color: Color(0xFF4DCE20),
border: currentSelectedRating == 6
? Border.all(
width: 2,
color: Color(0xFF184D12),
strokeAlign: BorderSide.strokeAlignOutside,
)
: null,
borderRadius: currentSelectedRating == 6
? BorderRadius.horizontal(
left: Radius.circular(2),
right: Radius.circular(8),
)
: BorderRadius.horizontal(
right: Radius.circular(8),
),
),
);
}
},
onRatingUpdate: (value) {
setState(() {
currentSelectedRating = value;
});
EasyDebounce.debounce(
'change-satiety',
Duration(milliseconds: 250),
() {
context.read<DiaryCubit>().fillMood(diaryId: state.diary.id, mood: currentSelectedRating.toInt() - 1);
},
);
},
),
SvgPicture.asset(
'assets/icons/mood_2.svg',
height: 32,
width: 32,
),
],
),
],
),
);
}
return const SizedBox.shrink();
},
);
}
}

View File

@@ -21,7 +21,7 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
builder: (BuildContext context, DiaryState state) {
if (state is DiaryStateLoaded) {
if (isFirstFetch) {
currentSelectedRating = state.diary.meals[state.selectedMeal - 1].satiety.toDouble();
currentSelectedRating = state.diary.meals[state.selectedMeal - 1].satiety.toDouble() + 1;
isFirstFetch = false;
}
return Padding(
@@ -44,7 +44,7 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
width: 32,
),
RatingBar.builder(
initialRating: state.diary.meals[state.selectedMeal - 1].satiety.toDouble(),
initialRating: state.diary.meals[state.selectedMeal - 1].satiety.toDouble() + 1,
itemCount: 6,
itemSize: MediaQuery.of(context).size.width / 6 - (124 / 6),
updateOnDrag: true,
@@ -176,7 +176,7 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
'change-satiety',
Duration(milliseconds: 250),
() {
context.read<DiaryCubit>().fillSatiety(diaryId: state.diary.id, satiety: currentSelectedRating.toInt());
context.read<DiaryCubit>().fillSatiety(diaryId: state.diary.id, satiety: currentSelectedRating.toInt() - 1);
},
);
},

View File

@@ -0,0 +1,229 @@
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import '../../../../core/theme/theme_helper.dart';
class WakeupAndRetireWidget extends StatefulWidget {
const WakeupAndRetireWidget({super.key});
@override
State<WakeupAndRetireWidget> createState() => _WakeupAndRetireWidgetState();
}
class _WakeupAndRetireWidgetState extends State<WakeupAndRetireWidget> {
late final DiaryCubit diaryCubit;
DateTime wakeup = DateTime.now().copyWith(hour: 6, minute: 30);
DateTime retire = DateTime.now().copyWith(hour: 22, minute: 30);
@override
void initState() {
super.initState();
diaryCubit = context.read<DiaryCubit>();
}
showTimePicker(int diaryId, bool isWakeup) {
showModalBottomSheet<void>(
context: context,
useRootNavigator: true,
builder:
(context) => SizedBox(
height: MediaQuery.of(context).copyWith().size.height / 3,
child: Column(
children: [
Expanded(
child: CupertinoDatePicker(
mode: CupertinoDatePickerMode.time,
use24hFormat: true,
initialDateTime: DateTime.now(),
onDateTimeChanged: (newTime) {
if (isWakeup) {
wakeup = newTime;
} else {
retire = newTime;
}
},
),
),
InkWell(
onTap: () {
Navigator.of(context).pop();
if (isWakeup) {
diaryCubit.fillWakeup(
diaryId: diaryId,
time:
'${wakeup.hour.toString().padLeft(2, '0')}:${wakeup.minute.toString().padLeft(2, '0')}:00',
);
} else {
diaryCubit.fillRetire(
diaryId: diaryId,
time:
'${retire.hour.toString().padLeft(2, '0')}:${retire.minute.toString().padLeft(2, '0')}:00',
);
}
},
borderRadius: BorderRadius.circular(20),
child: Ink(
width: MediaQuery.of(context).size.width - 16,
height: 52,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: appTheme.blueA400,
),
child: Center(
child: Text(
'Сохранить',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
),
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return BlocBuilder<DiaryCubit, DiaryState>(
builder: (context, state) {
if (state is DiaryStateLoaded) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Row(
children: [
Expanded(
child: Material(
borderRadius: BorderRadius.circular(12),
color: Colors.white,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 12,
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset('assets/icons/wakeup.svg'),
const SizedBox(width: 8),
Text(
'Подъём',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
height: 1,
),
),
],
),
const SizedBox(height: 8),
InkWell(
onTap: () => showTimePicker(state.diary.id, true),
borderRadius: BorderRadius.circular(100),
child: Ink(
height: 32,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: Color(0xFFF1F2F6),
),
child: Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
state.diary.wakeup.toString().substring(
0,
state.diary.wakeup.toString().length - 3,
),
style: TextStyle(
color: Color(0xFF6D6F71),
fontSize: 17,
fontWeight: FontWeight.w500,
),
),
),
),
),
],
),
),
),
),
const SizedBox(width: 8),
Expanded(
child: Material(
borderRadius: BorderRadius.circular(12),
color: Colors.white,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 12,
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset('assets/icons/retire.svg'),
const SizedBox(width: 8),
Text(
'Уход ко сну',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
height: 1,
),
),
],
),
const SizedBox(height: 8),
InkWell(
onTap: () => showTimePicker(state.diary.id, false),
borderRadius: BorderRadius.circular(100),
child: Ink(
height: 32,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: Color(0xFFF1F2F6),
),
child: Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
state.diary.retire.toString().substring(
0,
state.diary.retire.toString().length - 3,
),
style: TextStyle(
color: Color(0xFF6D6F71),
fontSize: 17,
fontWeight: FontWeight.w500,
),
),
),
),
),
],
),
),
),
),
],
),
);
} else {
return SizedBox.shrink();
}
},
);
}
}

View File

@@ -158,12 +158,14 @@ class DiaryRepository {
required int diaryId,
required String wakeUp,
required String retire,
String? comment,
}) async {
return await diaryService.finishDiaryDay(
diary: diaryId,
finishDiaryDayModel: FinishDiaryDayModel(
wakeUp: wakeUp,
retire: retire,
comment: comment
),
);
}
@@ -202,6 +204,22 @@ class DiaryRepository {
}
}
Future<void> fillMood({
required int diaryId,
required int mealId,
required int mood,
}) async {
try {
return await diaryService.fillMood(
diary: diaryId,
typeNo: mealId,
mood: mood,
);
} catch (e) {
rethrow;
}
}
Future<void> fillTime({
required int diaryId,
required int mealId,
@@ -217,4 +235,32 @@ class DiaryRepository {
rethrow;
}
}
Future<void> fillWakeup({
required int diaryId,
required String time,
}) async {
try {
return await diaryService.fillWakeup(
diary: diaryId,
wakeUp: time,
);
} catch (e) {
rethrow;
}
}
Future<void> fillRetire({
required int diaryId,
required String time,
}) async {
try {
return await diaryService.fillRetire(
diary: diaryId,
retire: time,
);
} catch (e) {
rethrow;
}
}
}

View File

@@ -91,7 +91,7 @@ abstract class DiaryService {
@POST('/api/diary/{diary}/finishDay')
Future<void> finishDiaryDay({
@Path('diary') required int diary,
@Body() required FinishDiaryDayModel finishDiaryDayModel,
@Body(nullToAbsent: true) required FinishDiaryDayModel finishDiaryDayModel,
});
@POST('/api/diary/{diary}/meals/{type_no}/satiety/fill')
@@ -101,6 +101,13 @@ abstract class DiaryService {
@Field() required int satiety,
});
@POST('/api/diary/{diary}/meals/{type_no}/mood/fill')
Future<void> fillMood({
@Path('diary') required int diary,
@Path('type_no') required int typeNo,
@Field() required int mood,
});
@POST('/api/diary/{diary}/meals/{type_no}/time/fill')
Future<void> fillTime({
@Path('diary') required int diary,
@@ -108,6 +115,18 @@ abstract class DiaryService {
@Field() required String time,
});
@POST('/api/diary/{diary}/wakeUp/fill')
Future<void> fillWakeup({
@Path('diary') required int diary,
@Field() required String wakeUp,
});
@POST('/api/diary/{diary}/retire/fill')
Future<void> fillRetire({
@Path('diary') required int diary,
@Field() required String retire,
});
@POST('/api/diary/product_nutritional_values/sendToModeration')
Future<GlossaryModerationModel> sendProductToModeration({
@Body() required Map<String, dynamic> data,

View File

@@ -366,6 +366,29 @@ class _DiaryService implements DiaryService {
await _dio.fetch<void>(_options);
}
@override
Future<void> fillMood({
required int diary,
required int typeNo,
required int mood,
}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
final _data = {'mood': mood};
final _options = _setStreamType<void>(
Options(method: 'POST', headers: _headers, extra: _extra)
.compose(
_dio.options,
'/api/diary/${diary}/meals/${typeNo}/mood/fill',
queryParameters: queryParameters,
data: _data,
)
.copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
);
await _dio.fetch<void>(_options);
}
@override
Future<void> fillTime({
required int diary,
@@ -389,6 +412,44 @@ class _DiaryService implements DiaryService {
await _dio.fetch<void>(_options);
}
@override
Future<void> fillWakeup({required int diary, required String wakeUp}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
final _data = {'wakeUp': wakeUp};
final _options = _setStreamType<void>(
Options(method: 'POST', headers: _headers, extra: _extra)
.compose(
_dio.options,
'/api/diary/${diary}/wakeUp/fill',
queryParameters: queryParameters,
data: _data,
)
.copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
);
await _dio.fetch<void>(_options);
}
@override
Future<void> fillRetire({required int diary, required String retire}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
final _data = {'retire': retire};
final _options = _setStreamType<void>(
Options(method: 'POST', headers: _headers, extra: _extra)
.compose(
_dio.options,
'/api/diary/${diary}/retire/fill',
queryParameters: queryParameters,
data: _data,
)
.copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
);
await _dio.fetch<void>(_options);
}
@override
Future<GlossaryModerationModel> sendProductToModeration({
required Map<String, dynamic> data,

View File

@@ -5,7 +5,6 @@ import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/enums/complained_content.dart';
import 'package:eatvio_app/core/enums/product_type.dart';
import 'package:eatvio_app/core/utils/localization_utils.dart';
import 'package:eatvio_app/core/utils/string_extentions.dart';
import 'package:eatvio_app/core/widgets/bookmark_button.dart';
import 'package:eatvio_app/core/widgets/custom_divider.dart';
import 'package:eatvio_app/core/widgets/data_error_widget.dart';
@@ -219,8 +218,10 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
),
if (replyId != null) SizedBox(width: 8),
Expanded(
child: SizedBox(
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: 52),
child: TextFormField(
textCapitalization: TextCapitalization.sentences,
onChanged: (_) {
setState(() {});
},
@@ -228,33 +229,34 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
maxLines: 5,
minLines: 1,
keyboardType: TextInputType.multiline,
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black,
height: 1.2,
),
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
hintText: s.comment.capitalize(),
hintStyle: TextStyles.textMMedium.copyWith(color: appTheme.lightGray600),
isDense: false, // убираем true, чтобы padding учитывался корректно
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), // вертикальный паддинг увеличен
hintText: 'Комментарий',
hintStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
height: 1.2,
color: Color(0xFFAEAEB2),
),
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
),
),

View File

@@ -27,7 +27,7 @@ class PlanModel with _$PlanModel {
@JsonKey(name: "duration") required int duration,
@JsonKey(name: "state") required String state,
@JsonKey(name: "type", fromJson: planTypeFromJson) required PlanType type,
@JsonKey(name: "details") required String details,
@JsonKey(name: "description_md") required String details,
@JsonKey(name: "packets_count") required int packetsCount,
@JsonKey(name: "packet1_options") PacketOptions? packet1Options,
@JsonKey(name: "packet2_options") PacketOptions? packet2Options,

View File

@@ -287,7 +287,7 @@ mixin _$PlanModel {
String get state => throw _privateConstructorUsedError;
@JsonKey(name: "type", fromJson: planTypeFromJson)
PlanType get type => throw _privateConstructorUsedError;
@JsonKey(name: "details")
@JsonKey(name: "description_md")
String get details => throw _privateConstructorUsedError;
@JsonKey(name: "packets_count")
int get packetsCount => throw _privateConstructorUsedError;
@@ -337,7 +337,7 @@ abstract class $PlanModelCopyWith<$Res> {
@JsonKey(name: "duration") int duration,
@JsonKey(name: "state") String state,
@JsonKey(name: "type", fromJson: planTypeFromJson) PlanType type,
@JsonKey(name: "details") String details,
@JsonKey(name: "description_md") String details,
@JsonKey(name: "packets_count") int packetsCount,
@JsonKey(name: "packet1_options") PacketOptions? packet1Options,
@JsonKey(name: "packet2_options") PacketOptions? packet2Options,
@@ -582,7 +582,7 @@ abstract class _$$PlanModelImplCopyWith<$Res>
@JsonKey(name: "duration") int duration,
@JsonKey(name: "state") String state,
@JsonKey(name: "type", fromJson: planTypeFromJson) PlanType type,
@JsonKey(name: "details") String details,
@JsonKey(name: "description_md") String details,
@JsonKey(name: "packets_count") int packetsCount,
@JsonKey(name: "packet1_options") PacketOptions? packet1Options,
@JsonKey(name: "packet2_options") PacketOptions? packet2Options,
@@ -762,7 +762,7 @@ class _$PlanModelImpl implements _PlanModel {
@JsonKey(name: "duration") required this.duration,
@JsonKey(name: "state") required this.state,
@JsonKey(name: "type", fromJson: planTypeFromJson) required this.type,
@JsonKey(name: "details") required this.details,
@JsonKey(name: "description_md") required this.details,
@JsonKey(name: "packets_count") required this.packetsCount,
@JsonKey(name: "packet1_options") this.packet1Options,
@JsonKey(name: "packet2_options") this.packet2Options,
@@ -802,7 +802,7 @@ class _$PlanModelImpl implements _PlanModel {
@JsonKey(name: "type", fromJson: planTypeFromJson)
final PlanType type;
@override
@JsonKey(name: "details")
@JsonKey(name: "description_md")
final String details;
@override
@JsonKey(name: "packets_count")
@@ -935,7 +935,7 @@ abstract class _PlanModel implements PlanModel {
@JsonKey(name: "state") required final String state,
@JsonKey(name: "type", fromJson: planTypeFromJson)
required final PlanType type,
@JsonKey(name: "details") required final String details,
@JsonKey(name: "description_md") required final String details,
@JsonKey(name: "packets_count") required final int packetsCount,
@JsonKey(name: "packet1_options") final PacketOptions? packet1Options,
@JsonKey(name: "packet2_options") final PacketOptions? packet2Options,
@@ -977,7 +977,7 @@ abstract class _PlanModel implements PlanModel {
@JsonKey(name: "type", fromJson: planTypeFromJson)
PlanType get type;
@override
@JsonKey(name: "details")
@JsonKey(name: "description_md")
String get details;
@override
@JsonKey(name: "packets_count")

View File

@@ -34,7 +34,7 @@ _$PlanModelImpl _$$PlanModelImplFromJson(Map<String, dynamic> json) =>
duration: (json['duration'] as num).toInt(),
state: json['state'] as String,
type: planTypeFromJson(json['type']),
details: json['details'] as String,
details: json['description_md'] as String,
packetsCount: (json['packets_count'] as num).toInt(),
packet1Options:
json['packet1_options'] == null
@@ -73,7 +73,7 @@ Map<String, dynamic> _$$PlanModelImplToJson(_$PlanModelImpl instance) =>
'duration': instance.duration,
'state': instance.state,
'type': instance.type,
'details': instance.details,
'description_md': instance.details,
'packets_count': instance.packetsCount,
'packet1_options': instance.packet1Options,
'packet2_options': instance.packet2Options,

View File

@@ -13,7 +13,7 @@ class Recipe with _$Recipe {
@JsonKey(name: 'cooking_time') required int cookingTime,
@JsonKey(name: 'active_time') required int activeCookingTime,
required List<Ingredient>? ingredients,
required String description,
@JsonKey(name: 'description_md') required String description,
required List<Step>? steps,
@JsonKey(name: 'video_url') required String? videoUrl,
@JsonKey(name: 'created_at') required DateTime createdAt,

View File

@@ -29,6 +29,7 @@ mixin _$Recipe {
@JsonKey(name: 'active_time')
int get activeCookingTime => throw _privateConstructorUsedError;
List<Ingredient>? get ingredients => throw _privateConstructorUsedError;
@JsonKey(name: 'description_md')
String get description => throw _privateConstructorUsedError;
List<Step>? get steps => throw _privateConstructorUsedError;
@JsonKey(name: 'video_url')
@@ -75,7 +76,7 @@ abstract class $RecipeCopyWith<$Res> {
@JsonKey(name: 'cooking_time') int cookingTime,
@JsonKey(name: 'active_time') int activeCookingTime,
List<Ingredient>? ingredients,
String description,
@JsonKey(name: 'description_md') String description,
List<Step>? steps,
@JsonKey(name: 'video_url') String? videoUrl,
@JsonKey(name: 'created_at') DateTime createdAt,
@@ -270,7 +271,7 @@ abstract class _$$RecipesImplCopyWith<$Res> implements $RecipeCopyWith<$Res> {
@JsonKey(name: 'cooking_time') int cookingTime,
@JsonKey(name: 'active_time') int activeCookingTime,
List<Ingredient>? ingredients,
String description,
@JsonKey(name: 'description_md') String description,
List<Step>? steps,
@JsonKey(name: 'video_url') String? videoUrl,
@JsonKey(name: 'created_at') DateTime createdAt,
@@ -449,7 +450,7 @@ class _$RecipesImpl implements _Recipes {
@JsonKey(name: 'cooking_time') required this.cookingTime,
@JsonKey(name: 'active_time') required this.activeCookingTime,
required final List<Ingredient>? ingredients,
required this.description,
@JsonKey(name: 'description_md') required this.description,
required final List<Step>? steps,
@JsonKey(name: 'video_url') required this.videoUrl,
@JsonKey(name: 'created_at') required this.createdAt,
@@ -493,6 +494,7 @@ class _$RecipesImpl implements _Recipes {
}
@override
@JsonKey(name: 'description_md')
final String description;
final List<Step>? _steps;
@override
@@ -637,7 +639,7 @@ abstract class _Recipes implements Recipe {
@JsonKey(name: 'cooking_time') required final int cookingTime,
@JsonKey(name: 'active_time') required final int activeCookingTime,
required final List<Ingredient>? ingredients,
required final String description,
@JsonKey(name: 'description_md') required final String description,
required final List<Step>? steps,
@JsonKey(name: 'video_url') required final String? videoUrl,
@JsonKey(name: 'created_at') required final DateTime createdAt,
@@ -671,6 +673,7 @@ abstract class _Recipes implements Recipe {
@override
List<Ingredient>? get ingredients;
@override
@JsonKey(name: 'description_md')
String get description;
@override
List<Step>? get steps;

View File

@@ -17,7 +17,7 @@ _$RecipesImpl _$$RecipesImplFromJson(Map<String, dynamic> json) =>
(json['ingredients'] as List<dynamic>?)
?.map((e) => Ingredient.fromJson(e as Map<String, dynamic>))
.toList(),
description: json['description'] as String,
description: json['description_md'] as String,
steps:
(json['steps'] as List<dynamic>?)
?.map((e) => Step.fromJson(e as Map<String, dynamic>))
@@ -45,7 +45,7 @@ Map<String, dynamic> _$$RecipesImplToJson(_$RecipesImpl instance) =>
'cooking_time': instance.cookingTime,
'active_time': instance.activeCookingTime,
'ingredients': instance.ingredients,
'description': instance.description,
'description_md': instance.description,
'steps': instance.steps,
'video_url': instance.videoUrl,
'created_at': instance.createdAt.toIso8601String(),

View File

@@ -4,6 +4,7 @@ import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/utils/date_time_utils.dart';
import 'package:eatvio_app/core/widgets/feed_icon_button.dart';
import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_state.dart';
@@ -58,37 +59,54 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
CircleAvatar(
radius: 20,
backgroundColor: Colors.black12,
foregroundImage: NetworkImage(
state.feedBlogPostList[widget.index].author.authorProfileIcon,
GestureDetector(
onTap: () {
GoRouter.of(context).pushNamed(
'profileScreen',
extra: Author(
authorSlug: state.feedBlogPostList[widget.index].author.authorSlug,
authorName: state.feedBlogPostList[widget.index].author.authorName,
authorProfileIcon: state.feedBlogPostList[widget.index].author.authorProfileIcon,
authorIsMe: state.feedBlogPostList[widget.index].author.authorIsMe,
),
);
},
child: Row(
children: [
CircleAvatar(
radius: 20,
backgroundColor: Colors.black12,
foregroundImage: NetworkImage(
state.feedBlogPostList[widget.index].author.authorProfileIcon,
),
),
SizedBox(width: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
state.feedBlogPostList[widget.index].author.authorName,
style: TextStyle(
height: 1,
color: Colors.black87,
fontWeight: FontWeight.w500,
fontSize: 16,
),
),
const SizedBox(height: 4),
Text(
'${calculateDifference(state.feedBlogPostList[widget.index].createdAt)} в ${state.feedBlogPostList[widget.index].createdAt.hour.toString().padLeft(2, '0')}:${state.feedBlogPostList[widget.index].createdAt.minute.toString().padLeft(2, '0')}',
style: TextStyle(
height: 1,
color: Colors.black45,
fontSize: 14,
),
),
],
),
],
),
),
SizedBox(width: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
state.feedBlogPostList[widget.index].author.authorName,
style: TextStyle(
height: 1,
color: Colors.black87,
fontWeight: FontWeight.w500,
fontSize: 16,
),
),
const SizedBox(height: 4),
Text(
'${calculateDifference(state.feedBlogPostList[widget.index].createdAt)} в ${state.feedBlogPostList[widget.index].createdAt.hour.toString().padLeft(2, '0')}:${state.feedBlogPostList[widget.index].createdAt.minute.toString().padLeft(2, '0')}',
style: TextStyle(
height: 1,
color: Colors.black45,
fontSize: 14,
),
),
],
),
const Spacer(),
if (!(state.feedBlogPostList[widget.index].author.isEntitySubscribedByMe ?? false) &&
!state.feedBlogPostList[widget.index].author.authorIsMe)

View File

@@ -5,6 +5,7 @@ import 'package:eatvio_app/core/widgets/bookmark_button.dart';
import 'package:eatvio_app/core/widgets/info_row.dart';
import 'package:eatvio_app/core/widgets/feed_icon_button.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
@@ -127,50 +128,63 @@ class _PlanWidgetState extends State<PlanWidget> {
],
),
SizedBox(height: 16),
Padding(
padding: const EdgeInsets.only(left: 16.0),
child: ListTile(
contentPadding: EdgeInsets.zero,
leading: Container(
width: 46,
height: 46,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: NetworkImage(widget.plan.author.authorProfileIcon),
fit: BoxFit.cover,
GestureDetector(
onTap: () {
GoRouter.of(context).pushNamed(
'profileScreen',
extra: Author(
authorSlug: widget.plan.author.authorSlug,
authorName: widget.plan.author.authorName,
authorProfileIcon: widget.plan.author.authorProfileIcon,
authorIsMe: widget.plan.author.authorIsMe,
),
);
},
child: Padding(
padding: const EdgeInsets.only(left: 16.0),
child: ListTile(
contentPadding: EdgeInsets.zero,
leading: Container(
width: 46,
height: 46,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: NetworkImage(widget.plan.author.authorProfileIcon),
fit: BoxFit.cover,
),
),
),
),
subtitle: Row(
children: [
InfoBouble(
radius: 12,
backgroundColor: appTheme.gray50,
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
children: [
Text(
'${widget.plan.author.authorPlaceInRating}-й в рейтинге',
style: TextStyles.textXSSemibold.copyWith(
color: appTheme.blueA400,
subtitle: Row(
children: [
InfoBouble(
radius: 12,
backgroundColor: appTheme.gray50,
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
children: [
Text(
'${widget.plan.author.authorPlaceInRating}-й в рейтинге',
style: TextStyles.textXSSemibold.copyWith(
color: appTheme.blueA400,
),
),
),
],
),
Spacer(),
Text(
'${widget.plan.packetsCount == 1 ? widget.plan.packet1Options?.price : '${s.from} ${widget.plan.minPriceOfOptions.toStringAsFixed(0)}'}₽',
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.greenA700),
),
SizedBox(width: 16),
],
),
title: Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
widget.plan.author.authorName,
style: TextStyles.textSSemibold.copyWith(
color: appTheme.black,
],
),
Spacer(),
Text(
'${widget.plan.packetsCount == 1 ? widget.plan.packet1Options?.price : '${s.from} ${widget.plan.minPriceOfOptions.toStringAsFixed(0)}'}₽',
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.greenA700),
),
SizedBox(width: 16),
],
),
title: Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
widget.plan.author.authorName,
style: TextStyles.textSSemibold.copyWith(
color: appTheme.black,
),
),
),
),

View File

@@ -5,7 +5,6 @@ import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/enums/complained_content.dart';
import 'package:eatvio_app/core/enums/product_type.dart';
import 'package:eatvio_app/core/utils/localization_utils.dart';
import 'package:eatvio_app/core/utils/string_extentions.dart';
import 'package:eatvio_app/core/widgets/bookmark_button.dart';
import 'package:eatvio_app/core/widgets/data_error_widget.dart';
import 'package:eatvio_app/core/widgets/info_row.dart';
@@ -289,8 +288,10 @@ class _AboutPlanScreenState extends State<AboutPlanScreen> {
),
if (replyId != null) SizedBox(width: 8),
Expanded(
child: SizedBox(
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: 52),
child: TextFormField(
textCapitalization: TextCapitalization.sentences,
onChanged: (_) {
setState(() {});
},
@@ -298,33 +299,34 @@ class _AboutPlanScreenState extends State<AboutPlanScreen> {
maxLines: 5,
minLines: 1,
keyboardType: TextInputType.multiline,
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black,
height: 1.2,
),
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
hintText: s.comment.capitalize(),
hintStyle: TextStyles.textMMedium.copyWith(color: appTheme.lightGray600),
isDense: false, // убираем true, чтобы padding учитывался корректно
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), // вертикальный паддинг увеличен
hintText: 'Комментарий',
hintStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
height: 1.2,
color: Color(0xFFAEAEB2),
),
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
),
),

View File

@@ -6,7 +6,6 @@ import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/enums/complained_content.dart';
import 'package:eatvio_app/core/enums/product_type.dart';
import 'package:eatvio_app/core/utils/localization_utils.dart';
import 'package:eatvio_app/core/utils/string_extentions.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/bookmark_button.dart';
import 'package:eatvio_app/core/widgets/data_error_widget.dart';
@@ -149,8 +148,10 @@ class _AboutRecipeScreenState extends State<AboutRecipeScreen> {
),
if (replyId != null) SizedBox(width: 8),
Expanded(
child: SizedBox(
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: 52),
child: TextFormField(
textCapitalization: TextCapitalization.sentences,
onChanged: (_) {
setState(() {});
},
@@ -158,39 +159,40 @@ class _AboutRecipeScreenState extends State<AboutRecipeScreen> {
maxLines: 5,
minLines: 1,
keyboardType: TextInputType.multiline,
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black,
height: 1.2,
),
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
hintText: s.comment.capitalize(),
hintStyle: TextStyles.textMMedium.copyWith(color: appTheme.lightGray600),
isDense: false, // убираем true, чтобы padding учитывался корректно
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), // вертикальный паддинг увеличен
hintText: 'Комментарий',
hintStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
height: 1.2,
color: Color(0xFFAEAEB2),
),
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
borderSide: BorderSide(color: Color(0xFFD1D1D6), width: 1),
),
),
),
),
),
SizedBox(width: 8),
const SizedBox(width: 8),
GestureDetector(
onTap: () {
if (textEditingController.text.length > 2) {
@@ -212,17 +214,10 @@ class _AboutRecipeScreenState extends State<AboutRecipeScreen> {
}
},
child: Container(
decoration: BoxDecoration(
color: textEditingController.text.length > 2 ? appTheme.blueA400 : appTheme.gray50,
shape: BoxShape.circle,
),
decoration: BoxDecoration(color: textEditingController.text.length > 2 ? appTheme.blueA400 : Colors.grey, shape: BoxShape.circle),
height: 32,
width: 32,
child: Icon(
Icons.send_rounded,
size: 18,
color: textEditingController.text.length > 2 ? appTheme.whiteA700 : appTheme.black,
),
child: Icon(Icons.send_rounded, size: 18, color: Colors.white),
),
),
],