mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-06 07:54:02 +01:00
Show the comment of nutrition diary entries
This commit is contained in:
1 parent
a6e68b48af
commit
987fbbb29e
2 files changed
+21
-5
No files matched your search
@@ -2,6 +2,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:wger/core/consts.dart';
|
||||
import 'package:wger/core/widgets/core.dart';
|
||||
import 'package:wger/features/nutrition/models/ingredient.dart';
|
||||
import 'package:wger/features/nutrition/models/log.dart';
|
||||
import 'package:wger/features/nutrition/models/nutritional_plan.dart';
|
||||
@@ -77,9 +78,14 @@ class DiaryEntryTile extends ConsumerWidget {
|
||||
: '${AppLocalizations.of(context).gValue(diaryEntry.amount.toStringAsFixed(0))} ${diaryEntry.ingredient?.name ?? '…'}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle: getNutritionRow(
|
||||
context,
|
||||
muted(getNutritionalValues(diaryEntry.nutritionalValues, context)),
|
||||
subtitle: Column(
|
||||
children: [
|
||||
getNutritionRow(
|
||||
context,
|
||||
muted(getNutritionalValues(diaryEntry.nutritionalValues, context)),
|
||||
),
|
||||
if (diaryEntry.comment?.isNotEmpty ?? false) MutedText(diaryEntry.comment!),
|
||||
],
|
||||
),
|
||||
trailing: (nutritionalPlan == null)
|
||||
? null
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:wger/features/nutrition/models/nutritional_plan.dart';
|
||||
import 'package:wger/features/nutrition/widgets/charts.dart';
|
||||
import 'package:wger/features/nutrition/widgets/nutritional_diary_detail.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
@@ -26,14 +27,14 @@ import 'package:wger/l10n/localizations_delegates.dart';
|
||||
import '../../../../test_data/nutritional_plans.dart';
|
||||
|
||||
void main() {
|
||||
Widget getWidget({locale = 'en'}) {
|
||||
Widget getWidget({locale = 'en', NutritionalPlan? plan}) {
|
||||
return MaterialApp(
|
||||
locale: Locale(locale),
|
||||
localizationsDelegates: appLocalizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: SingleChildScrollView(
|
||||
child: Card(
|
||||
child: NutritionalDiaryDetailWidget(getNutritionalPlan(), DateTime(2021, 6, 1)),
|
||||
child: NutritionalDiaryDetailWidget(plan ?? getNutritionalPlan(), DateTime(2021, 6, 1)),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -57,4 +58,13 @@ void main() {
|
||||
expect(find.text('75 g Burger soup'), findsOneWidget, reason: 'Name of ingredient');
|
||||
expect(find.byIcon(Icons.delete_outline), findsNWidgets(2));
|
||||
});
|
||||
|
||||
testWidgets('Diary entries show their comment', (WidgetTester tester) async {
|
||||
final plan = getNutritionalPlan();
|
||||
plan.diaryEntries.first.comment = 'Fasting day';
|
||||
|
||||
await tester.pumpWidget(getWidget(plan: plan));
|
||||
|
||||
expect(find.text('Fasting day'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user