Skip to content

Commit 6f3d690

Browse files
committed
mealtile: show macros + replace 'Log' with diary button
1 parent 244d628 commit 6f3d690

File tree

5 files changed

+20
-33
lines changed

5 files changed

+20
-33
lines changed

lib/widgets/nutrition/meal.dart

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import 'package:flutter/material.dart';
2020
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
21+
import 'package:flutter_svg_icons/flutter_svg_icons.dart';
2122
import 'package:provider/provider.dart';
2223
import 'package:wger/helpers/consts.dart';
2324
import 'package:wger/models/nutrition/log.dart';
@@ -308,36 +309,20 @@ class MealHeader extends StatelessWidget {
308309
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
309310
title: Row(children: [
310311
Expanded(
311-
child: (_meal.name != '')
312-
? Column(
313-
crossAxisAlignment: CrossAxisAlignment.start,
314-
children: [
315-
Text(
316-
_meal.name,
317-
style: Theme.of(context).textTheme.titleMedium,
318-
),
319-
if (_meal.time != null)
320-
Text(
321-
_meal.time!.format(context),
322-
style: Theme.of(context).textTheme.headlineSmall,
323-
)
324-
],
325-
)
326-
: Text(
327-
_meal.time != null ? _meal.time!.format(context) : '',
328-
style: Theme.of(context).textTheme.headlineSmall,
329-
),
330-
),
331-
if (_meal.isRealMeal)
332-
Text(
333-
AppLocalizations.of(context).log,
334-
style: Theme.of(context)
335-
.textTheme
336-
.labelLarge
337-
?.copyWith(color: Theme.of(context).colorScheme.primary),
338-
),
339-
const SizedBox(width: 26),
340-
const SizedBox(height: 40, width: 1, child: VerticalDivider()),
312+
child: Column(
313+
crossAxisAlignment: CrossAxisAlignment.start,
314+
children: [
315+
Text(
316+
((_meal.time != null) ? '${_meal.time!.format(context)} ' : '') + _meal.name,
317+
style: Theme.of(context).textTheme.titleMedium,
318+
),
319+
if (_meal.isRealMeal)
320+
Text(
321+
getShortNutritionValues(_meal.plannedNutritionalValues, context),
322+
style: Theme.of(context).textTheme.titleSmall,
323+
),
324+
],
325+
)),
341326
]),
342327
trailing: Row(
343328
mainAxisSize: MainAxisSize.min,
@@ -363,7 +348,9 @@ class MealHeader extends StatelessWidget {
363348
onPressed: () {
364349
_toggleEditing();
365350
},
366-
)
351+
),
352+
if (_meal.isRealMeal) const SizedBox(width: 5),
353+
if (_meal.isRealMeal) const SvgIcon(icon: SvgIconData('assets/icons/meal-diary.svg')),
367354
],
368355
),
369356
onTap: _meal.isRealMeal
6.58 KB
Loading
4.65 KB
Loading
3.09 KB
Loading

test/nutrition/nutritional_plan_screen_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ void main() {
134134
await tester.tap(find.byType(TextButton));
135135
await tester.pumpAndSettle();
136136

137-
expect(find.text('5:00 PM'), findsOneWidget);
137+
expect(find.textContaining('5:00 PM'), findsOneWidget);
138138
});
139139

140140
testWidgets('Tests the localization of times - DE', (WidgetTester tester) async {
141141
await tester.pumpWidget(createNutritionalPlan(locale: 'de'));
142142
await tester.tap(find.byType(TextButton));
143143
await tester.pumpAndSettle();
144144

145-
expect(find.text('17:00'), findsOneWidget);
145+
expect(find.textContaining('17:00'), findsOneWidget);
146146
});
147147
}

0 commit comments

Comments
 (0)