feat: add meal planning feature with API integration
- Introduced MealPlanApiPaths for handling meal plan related API endpoints. - Added MealPlanScreen for displaying and managing meal plans. - Implemented MealPlanRepository for fetching and updating meal plan data. - Created data models: MealPlanEntry, MealPlanRecipe, InventoryCompareItem, ShoppingItem, and MealPlanDashboard. - Integrated meal plan functionality into the app router and UI. - Updated localization files for meal plan related strings in English and Swedish. - Added state management for meal plan using Riverpod.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
class MealPlanRecipe {
|
||||
final int id;
|
||||
final String title;
|
||||
final String? imageUrl;
|
||||
final int? servings;
|
||||
|
||||
const MealPlanRecipe({
|
||||
required this.id,
|
||||
required this.title,
|
||||
this.imageUrl,
|
||||
this.servings,
|
||||
});
|
||||
|
||||
factory MealPlanRecipe.fromJson(Map<String, dynamic> json) {
|
||||
final rawId = json['id'];
|
||||
final rawTitle = json['title'] ?? json['name'];
|
||||
final rawServings = json['servings'];
|
||||
final rawImageUrl = json['imageUrl']?.toString().trim();
|
||||
|
||||
return MealPlanRecipe(
|
||||
id: rawId is num ? rawId.toInt() : int.parse(rawId.toString()),
|
||||
title: (rawTitle ?? '').toString(),
|
||||
imageUrl: rawImageUrl == null || rawImageUrl.isEmpty ? null : rawImageUrl,
|
||||
servings: rawServings == null
|
||||
? null
|
||||
: rawServings is num
|
||||
? rawServings.toInt()
|
||||
: int.tryParse(rawServings.toString()),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user