feat(plans): plan creating has been completed

This commit is contained in:
Username1548
2025-04-29 14:44:33 +07:00
parent c8b828bfe1
commit 0fcb2c1a0d
43 changed files with 1602 additions and 635 deletions

View File

@@ -36,6 +36,7 @@ class MealComment with _$MealComment {
factory MealComment({
required String comment,
required int typeNo,
}) = _MealComment;
factory MealComment.fromJson(Map<String, dynamic> json) => _$MealCommentFromJson(json);
@@ -45,7 +46,7 @@ class MealComment with _$MealComment {
class PortionComment with _$PortionComment {
factory PortionComment({
@JsonKey(name: 'commentable_id') required int portionId,
@JsonKey(name: 'id') required int portionId,
required String comment,
}) = _PortionComment;

View File

@@ -479,6 +479,7 @@ MealComment _$MealCommentFromJson(Map<String, dynamic> json) {
/// @nodoc
mixin _$MealComment {
String get comment => throw _privateConstructorUsedError;
int get typeNo => throw _privateConstructorUsedError;
/// Serializes this MealComment to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -496,7 +497,7 @@ abstract class $MealCommentCopyWith<$Res> {
MealComment value, $Res Function(MealComment) then) =
_$MealCommentCopyWithImpl<$Res, MealComment>;
@useResult
$Res call({String comment});
$Res call({String comment, int typeNo});
}
/// @nodoc
@@ -515,12 +516,17 @@ class _$MealCommentCopyWithImpl<$Res, $Val extends MealComment>
@override
$Res call({
Object? comment = null,
Object? typeNo = null,
}) {
return _then(_value.copyWith(
comment: null == comment
? _value.comment
: comment // ignore: cast_nullable_to_non_nullable
as String,
typeNo: null == typeNo
? _value.typeNo
: typeNo // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
@@ -533,7 +539,7 @@ abstract class _$$MealCommentImplCopyWith<$Res>
__$$MealCommentImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String comment});
$Res call({String comment, int typeNo});
}
/// @nodoc
@@ -550,12 +556,17 @@ class __$$MealCommentImplCopyWithImpl<$Res>
@override
$Res call({
Object? comment = null,
Object? typeNo = null,
}) {
return _then(_$MealCommentImpl(
comment: null == comment
? _value.comment
: comment // ignore: cast_nullable_to_non_nullable
as String,
typeNo: null == typeNo
? _value.typeNo
: typeNo // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
@@ -563,17 +574,19 @@ class __$$MealCommentImplCopyWithImpl<$Res>
/// @nodoc
@JsonSerializable()
class _$MealCommentImpl implements _MealComment {
_$MealCommentImpl({required this.comment});
_$MealCommentImpl({required this.comment, required this.typeNo});
factory _$MealCommentImpl.fromJson(Map<String, dynamic> json) =>
_$$MealCommentImplFromJson(json);
@override
final String comment;
@override
final int typeNo;
@override
String toString() {
return 'MealComment(comment: $comment)';
return 'MealComment(comment: $comment, typeNo: $typeNo)';
}
@override
@@ -581,12 +594,13 @@ class _$MealCommentImpl implements _MealComment {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$MealCommentImpl &&
(identical(other.comment, comment) || other.comment == comment));
(identical(other.comment, comment) || other.comment == comment) &&
(identical(other.typeNo, typeNo) || other.typeNo == typeNo));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, comment);
int get hashCode => Object.hash(runtimeType, comment, typeNo);
/// Create a copy of MealComment
/// with the given fields replaced by the non-null parameter values.
@@ -605,13 +619,17 @@ class _$MealCommentImpl implements _MealComment {
}
abstract class _MealComment implements MealComment {
factory _MealComment({required final String comment}) = _$MealCommentImpl;
factory _MealComment(
{required final String comment,
required final int typeNo}) = _$MealCommentImpl;
factory _MealComment.fromJson(Map<String, dynamic> json) =
_$MealCommentImpl.fromJson;
@override
String get comment;
@override
int get typeNo;
/// Create a copy of MealComment
/// with the given fields replaced by the non-null parameter values.
@@ -627,7 +645,7 @@ PortionComment _$PortionCommentFromJson(Map<String, dynamic> json) {
/// @nodoc
mixin _$PortionComment {
@JsonKey(name: 'commentable_id')
@JsonKey(name: 'id')
int get portionId => throw _privateConstructorUsedError;
String get comment => throw _privateConstructorUsedError;
@@ -647,7 +665,7 @@ abstract class $PortionCommentCopyWith<$Res> {
PortionComment value, $Res Function(PortionComment) then) =
_$PortionCommentCopyWithImpl<$Res, PortionComment>;
@useResult
$Res call({@JsonKey(name: 'commentable_id') int portionId, String comment});
$Res call({@JsonKey(name: 'id') int portionId, String comment});
}
/// @nodoc
@@ -689,7 +707,7 @@ abstract class _$$PortionCommentImplCopyWith<$Res>
__$$PortionCommentImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({@JsonKey(name: 'commentable_id') int portionId, String comment});
$Res call({@JsonKey(name: 'id') int portionId, String comment});
}
/// @nodoc
@@ -725,14 +743,13 @@ class __$$PortionCommentImplCopyWithImpl<$Res>
@JsonSerializable()
class _$PortionCommentImpl implements _PortionComment {
_$PortionCommentImpl(
{@JsonKey(name: 'commentable_id') required this.portionId,
required this.comment});
{@JsonKey(name: 'id') required this.portionId, required this.comment});
factory _$PortionCommentImpl.fromJson(Map<String, dynamic> json) =>
_$$PortionCommentImplFromJson(json);
@override
@JsonKey(name: 'commentable_id')
@JsonKey(name: 'id')
final int portionId;
@override
final String comment;
@@ -775,14 +792,14 @@ class _$PortionCommentImpl implements _PortionComment {
abstract class _PortionComment implements PortionComment {
factory _PortionComment(
{@JsonKey(name: 'commentable_id') required final int portionId,
{@JsonKey(name: 'id') required final int portionId,
required final String comment}) = _$PortionCommentImpl;
factory _PortionComment.fromJson(Map<String, dynamic> json) =
_$PortionCommentImpl.fromJson;
@override
@JsonKey(name: 'commentable_id')
@JsonKey(name: 'id')
int get portionId;
@override
String get comment;

View File

@@ -48,22 +48,24 @@ Map<String, dynamic> _$$ConsultantCommentsImplToJson(
_$MealCommentImpl _$$MealCommentImplFromJson(Map<String, dynamic> json) =>
_$MealCommentImpl(
comment: json['comment'] as String,
typeNo: (json['typeNo'] as num).toInt(),
);
Map<String, dynamic> _$$MealCommentImplToJson(_$MealCommentImpl instance) =>
<String, dynamic>{
'comment': instance.comment,
'typeNo': instance.typeNo,
};
_$PortionCommentImpl _$$PortionCommentImplFromJson(Map<String, dynamic> json) =>
_$PortionCommentImpl(
portionId: (json['commentable_id'] as num).toInt(),
portionId: (json['id'] as num).toInt(),
comment: json['comment'] as String,
);
Map<String, dynamic> _$$PortionCommentImplToJson(
_$PortionCommentImpl instance) =>
<String, dynamic>{
'commentable_id': instance.portionId,
'id': instance.portionId,
'comment': instance.comment,
};

View File

@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
@@ -6,7 +7,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
class MealButtonWidget extends StatefulWidget {
final int mealNumber;
const MealButtonWidget({
super.key,
required this.mealNumber,
@@ -22,6 +22,18 @@ class _MealButtonWidgetState extends State<MealButtonWidget> {
return BlocBuilder<DiaryCubit, DiaryState>(
builder: (context, state) {
if (state is DiaryStateLoaded) {
final consultantComment = state.consultantReview?.consultantComments.mealsComments.firstWhereOrNull(
(element) => element.typeNo == widget.mealNumber,
);
final Color bgColor;
if (state.selectedMeal == widget.mealNumber) {
bgColor = appTheme.blueA400;
} else if (consultantComment != null) {
bgColor = appTheme.commentBg;
} else {
bgColor = const Color(0xFFF1F2F6);
}
return InkWell(
onTap: () {
context.read<DiaryCubit>().setSelectedMeal(widget.mealNumber);
@@ -32,7 +44,7 @@ class _MealButtonWidgetState extends State<MealButtonWidget> {
height: 32,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: state.selectedMeal == widget.mealNumber ? appTheme.blueA400 : const Color(0xFFF1F2F6),
color: bgColor,
),
child: Center(
child: Text(

View File

@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
@@ -81,8 +82,10 @@ class _MealWidgetState extends State<MealWidget> {
BlocBuilder<DiaryCubit, DiaryState>(
builder: (context, state) {
if (state is DiaryStateLoaded) {
final mealsComments = state.consultantReview?.consultantComments.mealsComments;
if (mealsComments != null && (state.selectedMeal - 1 < mealsComments.length)) {
final consultantCommentOfMeal = state.consultantReview?.consultantComments.mealsComments.firstWhereOrNull(
(element) => element.typeNo == state.selectedMeal,
);
if (consultantCommentOfMeal != null) {
return Column(
children: [
Text(
@@ -90,7 +93,7 @@ class _MealWidgetState extends State<MealWidget> {
style: TextStyles.textLSemibold.copyWith(color: appTheme.black),
),
const SizedBox(height: 12),
CommentContainer(comment: mealsComments[state.selectedMeal - 1].comment),
CommentContainer(comment: consultantCommentOfMeal.comment),
],
);
}

View File

@@ -11,7 +11,7 @@ import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
class DiaryRepository {
final DiaryService diaryService;
final StreamController<String> _diaryForceFetchController = StreamController<String>();
final StreamController<String> _diaryForceFetchController = StreamController<String>.broadcast();
Stream<String> get forceFetchStream => _diaryForceFetchController.stream;