forked from eatvio/eatvio_app
diet creation scrren is done
This commit is contained in:
@@ -39,6 +39,23 @@ class Diet with _$Diet {
|
||||
factory Diet.fromJson(Map<String, dynamic> json) => _$DietFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class CreatedDiet with _$CreatedDiet {
|
||||
const factory CreatedDiet({
|
||||
@JsonKey(name: "id") required int id,
|
||||
}) = _CreatedDiet;
|
||||
|
||||
factory CreatedDiet.fromJson(Map<String, dynamic> json) => _$CreatedDietFromJson(json);
|
||||
}
|
||||
|
||||
int parseDuration(dynamic duration) {
|
||||
if (duration is String) {
|
||||
return int.parse(duration);
|
||||
}else {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Author with _$Author {
|
||||
const factory Author({
|
||||
@@ -46,7 +63,8 @@ class Author with _$Author {
|
||||
@JsonKey(name: "author_name") required String authorName,
|
||||
@JsonKey(name: "author_profile_icon") required String authorProfileIcon,
|
||||
@JsonKey(name: "author_is_me") required bool authorIsMe,
|
||||
@JsonKey(name: "is_entity_subscribed_by_me") required bool isEntitySubscribedByMe,
|
||||
@JsonKey(name: "is_entity_subscribed_by_me") bool? isEntitySubscribedByMe,
|
||||
@JsonKey(name: "author_place_in_rating") int? authorPlaceInRating,
|
||||
}) = _Author;
|
||||
|
||||
factory Author.fromJson(Map<String, dynamic> json) => _$AuthorFromJson(json);
|
||||
@@ -60,7 +78,7 @@ class DailySchedule with _$DailySchedule {
|
||||
@JsonKey(name: "portion") required Portion portion,
|
||||
@JsonKey(name: "quantity") required int quantity,
|
||||
@JsonKey(includeToJson: false, includeFromJson: false) DailyNutrition? dailyNutrition,
|
||||
@JsonKey(name: 'product_nutritional_value_id', includeFromJson: false, includeIfNull: false) String? productNutritionalValueId,
|
||||
@JsonKey(name: 'product_nutritional_value_id', includeToJson: true, includeFromJson: false, includeIfNull: false) String? productNutritionalValueId,
|
||||
}) = _DailySchedule;
|
||||
|
||||
factory DailySchedule.fromJson(Map<String, dynamic> json) => _$DailyScheduleFromJson(json);
|
||||
@@ -79,6 +97,7 @@ final portionValues = EnumValues({"grams": Portion.GRAMS, "milliliters": Portion
|
||||
|
||||
@freezed
|
||||
class DietType with _$DietType {
|
||||
const DietType._();
|
||||
const factory DietType({
|
||||
@JsonKey(name: "light") bool? light,
|
||||
@JsonKey(name: "veg") bool? veg,
|
||||
@@ -87,6 +106,10 @@ class DietType with _$DietType {
|
||||
}) = _DietType;
|
||||
|
||||
factory DietType.fromJson(Map<String, dynamic> json) => _$DietTypeFromJson(json);
|
||||
|
||||
bool hasAtLeastOneType() {
|
||||
return light ?? false || (veg ?? false) || (carb ?? false) || (meat ?? false);
|
||||
}
|
||||
}
|
||||
|
||||
class EnumValues<T> {
|
||||
|
||||
Reference in New Issue
Block a user