mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Correctly show exercise overviews for supersets
This commit is contained in:
@@ -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<String> out = [];
|
||||
out.add('GymModeState structure:');
|
||||
|
||||
@@ -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),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -93,14 +93,14 @@ class _WorkoutSummaryState extends ConsumerState<WorkoutSummary> {
|
||||
},
|
||||
),
|
||||
),
|
||||
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});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* 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);
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user