Show workout log notes in the day logs

This commit is contained in:
Roland Geider
2026-11-07 21:36:24 +01:00
parent 07f5320a4d
commit a87f4d3829
2 changed files with 39 additions and 14 deletions

View File

@@ -19,6 +19,7 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:material_ui/material_ui.dart';
import 'package:wger/core/date.dart';
import 'package:wger/core/widgets/core.dart';
import 'package:wger/features/account/providers/user_profile_notifier.dart';
import 'package:wger/features/routines/models/routine.dart';
import 'package:wger/features/routines/models/session.dart';
@@ -109,16 +110,24 @@ class SessionLogWidget extends ConsumerWidget {
(log) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
if (prTrophies.any((t) => t.contextData?.logId == log.id))
Icon(
Icons.emoji_events,
color: theme.colorScheme.primary,
size: 20,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
if (prTrophies.any((t) => t.contextData?.logId == log.id))
Icon(
Icons.emoji_events,
color: theme.colorScheme.primary,
size: 20,
),
Text(log.repTextNoNl(context)),
],
),
Text(log.repTextNoNl(context)),
],
if (log.notes != null) MutedText(log.notes!),
],
),
),
Row(
mainAxisSize: MainAxisSize.min,

View File

@@ -369,8 +369,10 @@ void main() {
});
});
group('Edit dialog notes', () {
Future<void> openEditDialog(WidgetTester tester) async {
group('Notes', () {
final notesField = find.byKey(const ValueKey('edit-notes-widget'));
Future<void> showDayLogs(WidgetTester tester) async {
tester.view.physicalSize = const Size(500, 1200);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.reset);
@@ -380,7 +382,10 @@ void main() {
await tester.pumpAndSettle();
await tester.drag(find.byType(ListView), const Offset(0, -500));
await tester.pumpAndSettle();
}
Future<void> openEditDialog(WidgetTester tester) async {
await showDayLogs(tester);
await tester.tap(find.byKey(const ValueKey('edit-log-1')));
await tester.pumpAndSettle();
}
@@ -391,11 +396,22 @@ void main() {
return verify(mockWorkoutLogRepository.updateLocalDrift(captureAny)).captured.single as Log;
}
testWidgets('the day logs show the notes under their set', (WidgetTester tester) async {
for (final log in routine.sessions[0].logs.where((l) => l.id == '1')) {
log.notes = 'Paused reps';
}
await withClock(Clock.fixed(DateTime(2025, 3, 29)), () async {
await showDayLogs(tester);
expect(find.text('Paused reps'), findsOneWidget);
});
});
testWidgets('saves the entered notes', (WidgetTester tester) async {
await withClock(Clock.fixed(DateTime(2025, 3, 29)), () async {
await openEditDialog(tester);
await tester.enterText(find.byKey(const ValueKey('edit-notes-widget')), 'Grip slipped');
await tester.enterText(notesField, 'Grip slipped');
await tester.pump();
expect((await saveAndCapture(tester)).notes, 'Grip slipped');
@@ -409,9 +425,9 @@ void main() {
await withClock(Clock.fixed(DateTime(2025, 3, 29)), () async {
await openEditDialog(tester);
expect(find.text('Paused reps'), findsOneWidget);
expect(find.descendant(of: notesField, matching: find.text('Paused reps')), findsOneWidget);
await tester.enterText(find.byKey(const ValueKey('edit-notes-widget')), ' ');
await tester.enterText(notesField, ' ');
await tester.pump();
expect((await saveAndCapture(tester)).notes, isNull);