forked from eatvio/eatvio_app
115 lines
3.8 KiB
Dart
115 lines
3.8 KiB
Dart
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'diary_day_model.freezed.dart';
|
|
|
|
part 'diary_day_model.g.dart';
|
|
|
|
enum PortionState {
|
|
@JsonValue('filled_diet')
|
|
filledDiet,
|
|
@JsonValue('eaten_from_diet')
|
|
eatenFromDiet,
|
|
eaten,
|
|
@JsonValue('eaten_deleted')
|
|
eatenDeleted,
|
|
@JsonValue('eaten_edited')
|
|
eatenEdited,
|
|
commented,
|
|
@JsonValue('reviewed_by_user')
|
|
reviewedByUser,
|
|
}
|
|
|
|
@freezed
|
|
class DiaryDayWrapperModel with _$DiaryDayWrapperModel {
|
|
const factory DiaryDayWrapperModel({
|
|
@JsonKey(
|
|
name: "diary",
|
|
)
|
|
required DiaryDayModel diary,
|
|
}) = _DiaryDayWrapperModel;
|
|
|
|
factory DiaryDayWrapperModel.fromJson(Map<String, dynamic> json) => _$DiaryDayWrapperModelFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class DiaryDayModel with _$DiaryDayModel {
|
|
const factory DiaryDayModel({
|
|
@JsonKey(name: "id") required int id,
|
|
@JsonKey(name: "date") required String date,
|
|
@JsonKey(name: "wakeup") String? wakeup,
|
|
@JsonKey(name: "retire") String? retire,
|
|
@JsonKey(name: "closed") required int closed,
|
|
@JsonKey(name: "comment") required String comment,
|
|
@JsonKey(name: "state") required TypeOfDiaryModel typeOfDiary,
|
|
@JsonKey(name: "meals") required List<MealModel> meals,
|
|
@JsonKey(name: "chosen_plan_id") required int? chosenPlanId,
|
|
}) = _DiaryDayModel;
|
|
|
|
factory DiaryDayModel.fromJson(Map<String, dynamic> json) => _$DiaryDayModelFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class MealModel with _$MealModel {
|
|
const factory MealModel({
|
|
@JsonKey(name: "id") required int id,
|
|
@JsonKey(name: "time") required String time,
|
|
@JsonKey(name: "type_no") required int typeNumber,
|
|
@JsonKey(name: "satiety") required int satiety,
|
|
@JsonKey(name: "mood") required int mood,
|
|
@JsonKey(name: "portions") required List<PortionModel> portions,
|
|
@JsonKey(name: "photos") required List<DiaryPhotoModel> photos,
|
|
}) = _MealModel;
|
|
|
|
factory MealModel.fromJson(Map<String, dynamic> json) => _$MealModelFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class DiaryPhotoModel with _$DiaryPhotoModel {
|
|
const factory DiaryPhotoModel({
|
|
@JsonKey(name: "id") required int id,
|
|
@JsonKey(name: "original_name") required String originalName,
|
|
@JsonKey(name: "path") required String path,
|
|
@JsonKey(name: "size") required int size,
|
|
}) = _DiaryPhotoModel;
|
|
|
|
factory DiaryPhotoModel.fromJson(Map<String, dynamic> json) => _$DiaryPhotoModelFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
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,
|
|
@JsonKey(name: "state") required PortionState portionState,
|
|
}) = _PortionModel;
|
|
|
|
factory PortionModel.fromJson(Map<String, dynamic> json) => _$PortionModelFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class TypeOfDiaryModel with _$TypeOfDiaryModel {
|
|
const factory TypeOfDiaryModel({
|
|
@JsonKey(name: "has_chosen_diet") required bool hasChosenDiet,
|
|
@JsonKey(name: "has_chosen_plan") required bool hasChosenPlan,
|
|
@JsonKey(name: "last_state") required DiaryStateEnum diaryState,
|
|
}) = _TypeOfDiaryModel;
|
|
|
|
factory TypeOfDiaryModel.fromJson(Map<String, dynamic> json) => _$TypeOfDiaryModelFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class ProductInMeal with _$ProductInMeal {
|
|
const factory ProductInMeal({
|
|
@JsonKey(name: 'product_name') required String productName,
|
|
@JsonKey(name: 'portion') required String portion,
|
|
@JsonKey(name: 'quantity') required int quantity,
|
|
}) = _ProductInMeal;
|
|
|
|
factory ProductInMeal.fromJson(Map<String, Object?> json) => _$ProductInMealFromJson(json);
|
|
}
|