forked from eatvio/eatvio_app
feat(diary): added state for future days with diet
This commit is contained in:
@@ -44,11 +44,31 @@ class DiaryDayModel with _$DiaryDayModel {
|
||||
@JsonKey(name: "state") required TypeOfDiaryModel typeOfDiary,
|
||||
@JsonKey(name: "meals") required List<MealModel> meals,
|
||||
@JsonKey(name: "chosen_plan_id") required int? chosenPlanId,
|
||||
@JsonKey(name: "day_of_chosen_diet") required int? dayOfChosenDiet,
|
||||
}) = _DiaryDayModel;
|
||||
|
||||
factory DiaryDayModel.fromJson(Map<String, dynamic> json) => _$DiaryDayModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DiaryFutureDietDayModel with _$DiaryFutureDietDayModel {
|
||||
const factory DiaryFutureDietDayModel({
|
||||
@JsonKey(name: "date") required String date,
|
||||
@JsonKey(name: "state", fromJson: _parseDayTypeForFutureDay) required TypeOfDiaryModel typeOfDiary,
|
||||
@JsonKey(name: "meals") required List<MealModel> meals,
|
||||
}) = _DiaryFutureDietDayModel;
|
||||
|
||||
factory DiaryFutureDietDayModel.fromJson(Map<String, dynamic> json) => _$DiaryFutureDietDayModelFromJson(json);
|
||||
}
|
||||
|
||||
TypeOfDiaryModel _parseDayTypeForFutureDay(json) {
|
||||
return TypeOfDiaryModel(
|
||||
hasChosenDiet: json['has_chosen_diet'] as bool,
|
||||
hasChosenPlan: json['has_chosen_plan'] as bool,
|
||||
diaryState: DiaryStateEnum.init,
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class MealModel with _$MealModel {
|
||||
const factory MealModel({
|
||||
|
||||
Reference in New Issue
Block a user