feat(diary): diet

This commit is contained in:
Alex
2024-12-24 16:52:06 +03:00
parent c6a60eccd9
commit 67d8bb58ee
13 changed files with 451 additions and 86 deletions

View File

@@ -4,6 +4,17 @@ part 'diary_day_model.freezed.dart';
part 'diary_day_model.g.dart';
enum PortionState {
active,
filled_diet,
eaten_from_diet,
eaten,
eaten_deleted,
eaten_edited,
commented,
reviewed_by_user,
}
@freezed
class DiaryDayWrapperModel with _$DiaryDayWrapperModel {
const factory DiaryDayWrapperModel({
@@ -37,7 +48,7 @@ class MealModel with _$MealModel {
@JsonKey(name: "type_no") required int typeNumber,
@JsonKey(name: "satiety") required int satiety,
@JsonKey(name: "mood") required int mood,
@JsonKey(name: "portions") required List<Portion> portions,
@JsonKey(name: "portions") required List<PortionModel> portions,
@JsonKey(name: "photos") required List<DiaryPhotoModel> photos,
}) = _MealModel;
@@ -57,16 +68,18 @@ class DiaryPhotoModel with _$DiaryPhotoModel {
}
@freezed
class Portion with _$Portion {
const factory Portion({
class PortionModel with _$PortionModel {
const factory PortionModel({
@JsonKey(name: "id") required int id,
@JsonKey(name: "product_nutritional_value_id") int? productNutritionalValueId,
@JsonKey(name: "product_name") required String productName,
@JsonKey(name: "quantity") required int quantity,
@JsonKey(name: "portion") required String portion,
@JsonKey(name: "from_diet") required bool fromDiet,
}) = _Portion;
@JsonKey(name: "state") required PortionState portionState,
}) = _PortionModel;
factory Portion.fromJson(Map<String, dynamic> json) => _$PortionFromJson(json);
factory PortionModel.fromJson(Map<String, dynamic> json) => _$PortionModelFromJson(json);
}
@freezed