diff --git a/lib/providers/gym_state.dart b/lib/providers/gym_state.dart index a6567a90..b42d7b42 100644 --- a/lib/providers/gym_state.dart +++ b/lib/providers/gym_state.dart @@ -1,4 +1,5 @@ import 'package:clock/clock.dart'; +import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; @@ -331,15 +332,24 @@ class GymStateNotifier extends _$GymStateNotifier { // exercise overview page if (state.showExercisePages) { - slotEntries.add( - SlotPageEntry( - type: SlotPageType.exerciseOverview, - setIndex: setIndex, - pageIndex: pageIndex, - setConfigData: slotData.setConfigs.first, - ), - ); - pageIndex++; + // Add one overview page per exercise in the slot (e.g. for supersets) + for (final exerciseId in slotData.exerciseIds) { + final setConfig = slotData.setConfigs.firstWhereOrNull((c) => c.exerciseId == exerciseId); + if (setConfig == null) { + _logger.warning('Exercise with ID $exerciseId not found in slotData!!'); + continue; + } + + slotEntries.add( + SlotPageEntry( + type: SlotPageType.exerciseOverview, + setIndex: setIndex, + pageIndex: pageIndex, + setConfigData: setConfig, + ), + ); + pageIndex++; + } } for (final config in slotData.setConfigs) { @@ -425,6 +435,7 @@ class GymStateNotifier extends _$GymStateNotifier { _logger.fine('Recalculated page indices'); } + /// Reads the current page structure for debugging purposes String readPageStructure() { final List out = []; out.add('GymModeState structure:'); diff --git a/lib/widgets/routines/gym_mode/session_page.dart b/lib/widgets/routines/gym_mode/session_page.dart index a55ffd64..614dcf75 100644 --- a/lib/widgets/routines/gym_mode/session_page.dart +++ b/lib/widgets/routines/gym_mode/session_page.dart @@ -54,7 +54,6 @@ class SessionPage extends ConsumerWidget { NavigationHeader( AppLocalizations.of(context).workoutSession, _controller, - showEndWorkoutButton: false, ), Expanded(child: Container()), Padding( @@ -68,7 +67,7 @@ class SessionPage extends ConsumerWidget { session: session, ), ), - NavigationFooter(_controller, showNext: false), + NavigationFooter(_controller), ], ); } diff --git a/lib/widgets/routines/gym_mode/summary.dart b/lib/widgets/routines/gym_mode/summary.dart index d5d7fa78..3fbbb8a6 100644 --- a/lib/widgets/routines/gym_mode/summary.dart +++ b/lib/widgets/routines/gym_mode/summary.dart @@ -93,14 +93,14 @@ class _WorkoutSummaryState extends ConsumerState { }, ), ), - NavigationFooter(widget._controller), + NavigationFooter(widget._controller, showNext: false), ], ); } } class WorkoutSessionStats extends ConsumerWidget { - final _logger = Logger('WorkoutStats'); + final _logger = Logger('WorkoutSessionStats'); final WorkoutSessionApi? _sessionApi; WorkoutSessionStats(this._sessionApi, {super.key}); diff --git a/test/routine/gym_mode/gym_mode_test.dart b/test/routine/gym_mode/gym_mode_test.dart index d55774c4..38a3e296 100644 --- a/test/routine/gym_mode/gym_mode_test.dart +++ b/test/routine/gym_mode/gym_mode_test.dart @@ -1,6 +1,6 @@ /* * This file is part of wger Workout Manager . - * Copyright (c) 2020, wger Team + * Copyright (c) 2020, 2025 wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -38,6 +38,7 @@ import 'package:wger/widgets/routines/gym_mode/exercise_overview.dart'; import 'package:wger/widgets/routines/gym_mode/log_page.dart'; import 'package:wger/widgets/routines/gym_mode/session_page.dart'; import 'package:wger/widgets/routines/gym_mode/start_page.dart'; +import 'package:wger/widgets/routines/gym_mode/summary.dart'; import 'package:wger/widgets/routines/gym_mode/timer.dart'; import '../../../test_data/exercises.dart'; @@ -292,6 +293,16 @@ void main() { expect(toggleButtons.isSelected[1], isTrue); expect(find.byIcon(Icons.chevron_left), findsOneWidget); expect(find.byIcon(Icons.close), findsOneWidget); + expect(find.byIcon(Icons.chevron_right), findsOneWidget); + await tester.tap(find.byIcon(Icons.chevron_right)); + await tester.pumpAndSettle(); + + // + // Workout summary + // + expect(find.byType(WorkoutSummary), findsOneWidget); + expect(find.byIcon(Icons.chevron_left), findsOneWidget); + expect(find.byIcon(Icons.close), findsOneWidget); expect(find.byIcon(Icons.chevron_right), findsNothing); }); },