Skip to content

Commit 90ebeec

Browse files
committed
also show kcal consumed for "other" logs
1 parent b7a2830 commit 90ebeec

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

lib/widgets/nutrition/helpers.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ String getShortNutritionValues(NutritionalValues values, BuildContext context) {
5151
return '$e / $p / $c / $f';
5252
}
5353

54+
String getKcalConsumed(Meal meal, BuildContext context) {
55+
final consumed =
56+
meal.diaryEntriesToday.map((e) => e.nutritionalValues.energy).fold(0.0, (a, b) => a + b);
57+
final loc = AppLocalizations.of(context);
58+
59+
return '${consumed.toStringAsFixed(0)} ${loc.kcal}';
60+
}
61+
5462
String getKcalConsumedVsPlanned(Meal meal, BuildContext context) {
5563
final planned = meal.plannedNutritionalValues.energy;
5664
final consumed =

lib/widgets/nutrition/meal.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,12 @@ class MealHeader extends StatelessWidget {
321321
((_meal.time != null) ? '${_meal.time!.format(context)} ' : '') + _meal.name,
322322
style: Theme.of(context).textTheme.titleMedium,
323323
),
324-
if (_meal.isRealMeal)
325-
Text(
326-
getKcalConsumedVsPlanned(_meal, context),
327-
style: Theme.of(context).textTheme.titleSmall,
328-
),
324+
Text(
325+
_meal.isRealMeal
326+
? getKcalConsumedVsPlanned(_meal, context)
327+
: getKcalConsumed(_meal, context),
328+
style: Theme.of(context).textTheme.titleSmall,
329+
),
329330
],
330331
)),
331332
]),
1016 Bytes
Loading
899 Bytes
Loading
890 Bytes
Loading

0 commit comments

Comments
 (0)