Remove more unused code

This commit is contained in:
Roland Geider
2025-01-05 20:08:11 +01:00
parent b66aa7444d
commit ca6c682483
7 changed files with 16 additions and 108 deletions

View File

@@ -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?",

View File

@@ -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', '');

View File

@@ -50,11 +50,6 @@ class Slot {
@JsonKey(required: false, includeFromJson: true, defaultValue: [], includeToJson: false)
List<SlotEntry> 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<SlotEntry> 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<SlotEntry> get settingsFiltered {
final List<SlotEntry> 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<SlotEntry> filterSettingsByExercise(Exercise exerciseBase) {
return entries.where((element) => element.exerciseId == exerciseBase.id).toList();
}
/// Returns a list with all repetitions for the given exercise
List<String> getSmartRepr(Exercise exerciseBase) {
final List<String> 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

View File

@@ -286,9 +286,7 @@ class _SlotFormWidgetStateNg extends State<ReorderableSlotList> {
@override
Widget build(BuildContext context) {
final i18n = AppLocalizations.of(context);
final provider = context.read<RoutinesProvider>();
final languageCode = Localizations.localeOf(context).languageCode;
return Column(
@@ -296,8 +294,7 @@ class _SlotFormWidgetStateNg extends State<ReorderableSlotList> {
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<ReorderableSlotList> {
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(

View File

@@ -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<GymMode> {
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<GymMode> {
// 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<ExercisesProvider>(context, listen: false)
@@ -113,7 +113,7 @@ class _GymModeState extends State<GymMode> {
var currentElement = 1;
final List<Widget> 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<GymMode> {
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<GymMode> {
return PageView(
controller: _controller,
children: [
StartPage(_controller, widget._DayData.day!, _exercisePages),
StartPage(_controller, widget._dayData.day!, _exercisePages),
...getContent(),
SessionPage(
Provider.of<RoutinesProvider>(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),
],
);

View File

@@ -1,33 +0,0 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* 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 <http://www.gnu.org/licenses/>.
*/
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)');
});
});
}

View File

@@ -92,7 +92,6 @@ Routine getWorkout({List<Exercise>? 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<Exercise>? 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<Exercise>? 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