forked from eatvio/eatvio_app
feat(diary): add diary page, calendar, meals
This commit is contained in:
80
lib/features/diary/models/diary_day_model.dart
Normal file
80
lib/features/diary/models/diary_day_model.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'diary_day_model.freezed.dart';
|
||||
|
||||
part 'diary_day_model.g.dart';
|
||||
|
||||
@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,
|
||||
}) = _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") required int type,
|
||||
@JsonKey(name: "satiety") required int satiety,
|
||||
@JsonKey(name: "mood") required int mood,
|
||||
@JsonKey(name: "portions") required List<Portion> 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 String id,
|
||||
@JsonKey(name: "original_name") required String originalName,
|
||||
@JsonKey(name: "path") required String path,
|
||||
@JsonKey(name: "size") required String size,
|
||||
}) = _DiaryPhotoModel;
|
||||
|
||||
factory DiaryPhotoModel.fromJson(Map<String, dynamic> json) => _$DiaryPhotoModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Portion with _$Portion {
|
||||
const factory Portion({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@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;
|
||||
|
||||
factory Portion.fromJson(Map<String, dynamic> json) => _$PortionFromJson(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,
|
||||
}) = _TypeOfDiaryModel;
|
||||
|
||||
factory TypeOfDiaryModel.fromJson(Map<String, dynamic> json) => _$TypeOfDiaryModelFromJson(json);
|
||||
}
|
||||
Reference in New Issue
Block a user