Skip to content

Commit 9bc0b15

Browse files
authored
Merge pull request #1224 from pankaj-basnet/refactor/nutrition-meals-components
Refactor/nutrition meals components
2 parents bfb44c2 + 601be2c commit 9bc0b15

7 files changed

Lines changed: 216 additions & 116 deletions

File tree

lib/l10n/app_en.arb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,25 @@
460460
"@toAddMealsToThePlanGoToNutritionalPlanDetails": {
461461
"description": "Message shown to guide users to the nutritional plan details page to add meals"
462462
},
463+
"planDateRange": "from {startDate} to {endDate}",
464+
"@planDateRange": {
465+
"description": "Label for the start and end date range of a plan",
466+
"placeholders": {
467+
"startDate": { "type": "String" },
468+
"endDate": { "type": "String" }
469+
}
470+
},
471+
"planStartDate": "from {startDate}",
472+
"@planStartDate": {
473+
"description": "Label for the start date of a plan",
474+
"placeholders": {
475+
"startDate": { "type": "String" }
476+
}
477+
},
478+
"otherLogs": "Other logs",
479+
"@otherLogs": {
480+
"description": "Other unassigned logs. Label for the pseudo-meal section that groups all nutritional diary entries not assigned to a specific meal"
481+
},
463482
"goalEnergy": "Energy goal",
464483
"goalProtein": "Protein goal",
465484
"goalCarbohydrates": "Carbohydrates goal",
@@ -675,6 +694,10 @@
675694
"fiber": "Fibers",
676695
"sodium": "Sodium",
677696
"@sodium": {},
697+
"carbohydratesSugar": "Sugar (Carbohydrates)",
698+
"@carbohydratesSugar": {
699+
"description": "Label for the carbohydrates sugar"
700+
},
678701
"amount": "Amount",
679702
"@amount": {
680703
"description": "The amount (e.g. in grams) of an ingredient in a meal"

lib/providers/nutrition_notifier.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class NutritionState {
5959
/// Returns the plan with the given [id], or `null` if it isn't (yet) in the
6060
/// streamed snapshot
6161
NutritionalPlan? findByIdOrNull(String? id) => plans.firstWhereOrNull((plan) => plan.id == id);
62+
63+
List<MealItem>? recentMealItemsInPlan(String? planId) {
64+
final nutriPlan = plans.firstWhereOrNull((plan) => plan.id == planId);
65+
return nutriPlan?.dedupMealItems;
66+
}
6267
}
6368

6469
@Riverpod(keepAlive: true)

lib/screens/log_meal_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class _LogMealScreenState extends ConsumerState<LogMealScreen> {
7878
children: [
7979
const DiaryheaderTile(),
8080
...meal.mealItems.map(
81-
(item) => MealItemEditableFullTile(item, viewMode.withAllDetails, false),
81+
(item) => MealItemEditableFullTile(item, ViewMode.withAllDetails, false),
8282
),
8383
const SizedBox(height: 32),
8484
Text(

lib/screens/log_meals_screen.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class _LogMealsScreenState extends State<LogMealsScreen> {
6161
itemCount: nutritionalPlan.meals.length,
6262
itemBuilder: (context, index) => MealWidget(
6363
nutritionalPlan.meals[index],
64-
nutritionalPlan.dedupMealItems,
6564
true,
6665
true,
6766
),

0 commit comments

Comments
 (0)