Merge remote-tracking branch 'upstream/main'

This commit is contained in:
Username1548
2025-05-19 21:38:20 +07:00
53 changed files with 534 additions and 216 deletions

View File

@@ -25,21 +25,40 @@ class Recipe with _$Recipe {
@JsonKey(name: 'was_liked_by_me') required bool wasLikedByMe,
@JsonKey(name: 'is_favorite') required bool isFavorite,
@JsonKey(name: 'energy_per_serving') required double calories,
int? servings,
@JsonKey(name: 'total_likes') required int likesCount,
@JsonKey(name: 'total_views') required int viewsCount,
required List<Tag> tags,
required Author author,
}) = _Recipes;
factory Recipe.fromJson(Map<String, Object?> json) => _$RecipeFromJson(json);
}
@freezed
class Tag with _$Tag {
const factory Tag({required String name}) = _Tag;
factory Tag.fromJson(Map<String, Object?> json) => _$TagFromJson(json);
}
@freezed
class Ingredient with _$Ingredient {
const factory Ingredient({required String name, String? unit, required String portion}) = _Ingredient;
const factory Ingredient({
required String name,
String? unit,
required String portion,
@JsonKey(name: 'product_nutritional_id', fromJson: _parseProductId) required int productId,
}) = _Ingredient;
factory Ingredient.fromJson(Map<String, Object?> json) => _$IngredientFromJson(json);
}
int _parseProductId(json) {
if (json is String) {
return int.parse(json);
}
return json as int;
}
@freezed
class Step with _$Step {
const factory Step({required String image, @JsonKey(name: 'description_md') required String description}) = _Step;