diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index e17c51fa..8b7b9398 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -745,6 +745,7 @@ } } }, + "simpleMode": "Simple mode", "progressionRules": "This exercise has progression rules and can't be edited on the mobile app. Please use the web application to edit this exercise.", "cacheWarning": "Due to caching it might take some time till the changes are visible throughout the application.", "textPromptTitle": "Ready to start?", diff --git a/lib/models/workouts/log.dart b/lib/models/workouts/log.dart index cad0480d..a1f5d962 100644 --- a/lib/models/workouts/log.dart +++ b/lib/models/workouts/log.dart @@ -104,11 +104,6 @@ class Log { this.rir = rir; } - /// Returns the text representation for a single setting, used in the gym mode - String get singleLogRepText { - return repText(reps, repetitionUnitObj, weight, weightUnitObj, rir); - } - /// Returns the text representation for a single setting, used in the gym mode String get singleLogRepTextNoNl { return repText(reps, repetitionUnitObj, weight, weightUnitObj, rir).replaceAll('\n', ''); diff --git a/lib/models/workouts/slot.dart b/lib/models/workouts/slot.dart index 0ecec99a..656f58ae 100644 --- a/lib/models/workouts/slot.dart +++ b/lib/models/workouts/slot.dart @@ -50,11 +50,6 @@ class Slot { @JsonKey(required: false, includeFromJson: true, defaultValue: [], includeToJson: false) List entries = []; - /// Computed settings (instead of 4x10 this has [10, 10, 10, 10]), used for - /// the gym mode where the individual values are used - @JsonKey(includeFromJson: false, includeToJson: false) - List settingsComputed = []; - Slot({ required this.id, required this.day, @@ -84,23 +79,6 @@ class Slot { } } - /// Return only one setting object per exercise, this makes rendering workout - /// plans easier and the gym mode uses the synthetic settings anyway. - List get settingsFiltered { - final List out = []; - - for (final setting in entries) { - final foundSettings = out.where( - (element) => element.exerciseId == setting.exerciseId, - ); - - if (foundSettings.isEmpty) { - out.add(setting); - } - } - return out; - } - void addExerciseBase(Exercise base) { exercisesObj.add(base); exercisesIds.add(base.id!); @@ -111,37 +89,8 @@ class Slot { exercisesIds.removeWhere((e) => e == base.id); } - /// Returns all settings for the given exercise - List filterSettingsByExercise(Exercise exerciseBase) { - return entries.where((element) => element.exerciseId == exerciseBase.id).toList(); - } - - /// Returns a list with all repetitions for the given exercise - List getSmartRepr(Exercise exerciseBase) { - final List out = []; - - final settingList = filterSettingsByExercise(exerciseBase); - - if (settingList.isEmpty) { - out.add(''); - } - - if (settingList.length == 1) { - out.add(settingList.first.singleSettingRepText.replaceAll('\n', '')); - } - - if (settingList.length > 1) { - for (final setting in settingList) { - out.add(setting.singleSettingRepText.replaceAll('\n', '')); - } - } - - return out; - } - - /// Returns a string with all repetitions for the given exercise - String getSmartTextRepr(Exercise exerciseBase) { - return getSmartRepr(exerciseBase).join(' – '); + bool get isSuperset { + return exercisesObj.length > 1; } // Boilerplate diff --git a/lib/widgets/routines/forms/slot.dart b/lib/widgets/routines/forms/slot.dart index 9bfefa66..3eadd588 100644 --- a/lib/widgets/routines/forms/slot.dart +++ b/lib/widgets/routines/forms/slot.dart @@ -286,9 +286,7 @@ class _SlotFormWidgetStateNg extends State { @override Widget build(BuildContext context) { final i18n = AppLocalizations.of(context); - final provider = context.read(); - final languageCode = Localizations.localeOf(context).languageCode; return Column( @@ -296,8 +294,7 @@ class _SlotFormWidgetStateNg extends State { if (!widget.day.isRest) SwitchListTile( value: simpleMode, - title: const Text('Simple edit mode'), - subtitle: const Text('Hides some more advanced fields when editing'), + title: Text(i18n.simpleMode), contentPadding: const EdgeInsets.all(4), onChanged: (value) { setState(() { @@ -320,7 +317,9 @@ class _SlotFormWidgetStateNg extends State { child: Column( children: [ ListTile( - title: Text(i18n.exerciseNr(index + 1)), + title: slot.isSuperset + ? Text(i18n.supersetNr(index + 1)) + : Text(i18n.exerciseNr(index + 1)), tileColor: isCurrentSlotSelected ? Theme.of(context).highlightColor : null, leading: selectedSlotId == null ? ReorderableDragStartListener( diff --git a/lib/widgets/routines/gym_mode.dart b/lib/widgets/routines/gym_mode.dart index 7ff889d0..1782547f 100644 --- a/lib/widgets/routines/gym_mode.dart +++ b/lib/widgets/routines/gym_mode.dart @@ -48,10 +48,10 @@ import 'package:wger/widgets/routines/forms/rir.dart'; import 'package:wger/widgets/routines/forms/weight_unit.dart'; class GymMode extends StatefulWidget { - final DayData _DayData; + final DayData _dayData; late final TimeOfDay _start; - GymMode(this._DayData) { + GymMode(this._dayData) { _start = TimeOfDay.now(); } @@ -77,7 +77,7 @@ class _GymModeState extends State { super.initState(); // Calculate amount of elements for progress indicator - for (final slot in widget._DayData.slots) { + for (final slot in widget._dayData.slots) { _totalElements += slot.setConfigs.length; } // Calculate the pages for the navigation @@ -85,7 +85,7 @@ class _GymModeState extends State { // This duplicates the code below in the getContent method, but it seems to // be the easiest way var currentPage = 1; - for (final slot in widget._DayData.slots) { + for (final slot in widget._dayData.slots) { var firstPage = true; for (final config in slot.setConfigs) { final exercise = Provider.of(context, listen: false) @@ -113,7 +113,7 @@ class _GymModeState extends State { var currentElement = 1; final List out = []; - for (final slotData in widget._DayData.slots) { + for (final slotData in widget._dayData.slots) { var firstPage = true; for (final config in slotData.setConfigs) { final ratioCompleted = currentElement / _totalElements; @@ -134,7 +134,7 @@ class _GymModeState extends State { config, slotData, exercise, - workoutProvider.findById(widget._DayData.day!.routineId), + workoutProvider.findById(widget._dayData.day!.routineId), ratioCompleted, _exercisePages, )); @@ -151,11 +151,11 @@ class _GymModeState extends State { return PageView( controller: _controller, children: [ - StartPage(_controller, widget._DayData.day!, _exercisePages), + StartPage(_controller, widget._dayData.day!, _exercisePages), ...getContent(), SessionPage( Provider.of(context, listen: false) - .findById(widget._DayData.day!.routineId), + .findById(widget._dayData.day!.routineId), _controller, widget._start, _exercisePages, @@ -197,7 +197,7 @@ class StartPage extends StatelessWidget { .name, style: Theme.of(context).textTheme.titleLarge, ), - ...slot.getSmartRepr(entry.exerciseObj).map((e) => Text(e)), + const Text('TODO'), const SizedBox(height: 15), ], ); diff --git a/test/workout/set_model_test.dart b/test/workout/set_model_test.dart deleted file mode 100644 index 15a5f395..00000000 --- a/test/workout/set_model_test.dart +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of wger Workout Manager . - * Copyright (C) 2020, 2021 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * wger Workout Manager is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import 'package:flutter_test/flutter_test.dart'; - -import '../../test_data/routines.dart'; - -void main() { - group('Test the getSmartTextRepr method for a set', () { - test('Repetitions and weigh units', () { - final workout = getWorkout(); - final set = workout.days.first.slots.first; - final exercise1 = set.exercisesObj[0]; - - expect(set.getSmartTextRepr(exercise1), '6 × 80 kg (3 RiR)'); - }); - }); -} diff --git a/test_data/routines.dart b/test_data/routines.dart index 9bce6b6e..0960a285 100644 --- a/test_data/routines.dart +++ b/test_data/routines.dart @@ -92,7 +92,6 @@ Routine getWorkout({List? exercises}) { ); setBenchPress.addExerciseBase(testBases[0]); setBenchPress.entries.add(settingBenchPress); - setBenchPress.settingsComputed = [settingBenchPress, settingBenchPress]; final settingSquat = SlotEntry( slotId: 2, @@ -112,7 +111,6 @@ Routine getWorkout({List? exercises}) { final setSquat = Slot.withData(id: 2, day: 1, order: 1); setSquat.addExerciseBase(testBases[4]); setSquat.entries.add(settingSquat); - setSquat.settingsComputed = [settingSquat, settingSquat]; final settingSideRaises = SlotEntry( slotId: 2, @@ -133,7 +131,6 @@ Routine getWorkout({List? exercises}) { final setSideRaises = Slot.withData(id: 3, day: 1, order: 1); setSideRaises.addExerciseBase(testBases[5]); setSideRaises.entries.add(settingSideRaises); - setSideRaises.settingsComputed = [settingSideRaises, settingSideRaises]; final dayChestShoulders = Day() ..id = 1