diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 5393c66a..cd52c000 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -69,10 +69,6 @@ "@registerInstead": {}, "loginInstead": "Already have an account? Login", "@loginInstead": {}, - "labelWorkoutPlans": "Workout plans", - "@labelWorkoutPlans": { - "description": "Title for screen workout plans" - }, "labelBottomNavWorkout": "Workout", "@labelBottomNavWorkout": { "description": "Label used in bottom navigation, use a short word" @@ -144,6 +140,7 @@ "@category": { "description": "Category for an exercise, ingredient, etc." }, + "routines": "Routines", "newRoutine": "New routine", "noRoutines": "You have no routines", "reps": "Reps", diff --git a/lib/models/workouts/base_config.dart b/lib/models/workouts/base_config.dart index 73791bfe..90b6ce00 100644 --- a/lib/models/workouts/base_config.dart +++ b/lib/models/workouts/base_config.dart @@ -47,6 +47,9 @@ class BaseConfig { @JsonKey(required: true, name: 'need_log_to_apply') late bool needLogToApply; + @JsonKey(required: true, name: 'repeat') + late bool repeat; + @JsonKey(required: true, name: 'requirements') late dynamic requirements; @@ -54,12 +57,13 @@ class BaseConfig { required this.id, required this.slotEntryId, required this.iteration, + this.repeat = false, // required this.trigger, required this.value, - required this.operation, - required this.step, - required this.needLogToApply, - required this.requirements, + this.operation = 'r', + this.step = 'abs', + this.needLogToApply = false, + this.requirements = null, }); BaseConfig.firstIteration(this.value, this.slotEntryId) { @@ -68,6 +72,7 @@ class BaseConfig { step = 'abs'; needLogToApply = false; requirements = null; + repeat = false; } // Boilerplate diff --git a/lib/models/workouts/routine.dart b/lib/models/workouts/routine.dart index d18ebb5f..dbb05bbd 100644 --- a/lib/models/workouts/routine.dart +++ b/lib/models/workouts/routine.dart @@ -85,11 +85,13 @@ class Routine { required this.end, this.fitInWeek = false, String? description, - List? days, - List? logs, + this.days = const [], + this.dayData = const [], + this.dayDataGym = const [], + this.dayDataCurrentIteration = const [], + this.dayDataCurrentIterationGym = const [], + this.logs = const [], }) { - this.days = days ?? []; - this.logs = logs ?? []; this.description = description ?? ''; } diff --git a/lib/models/workouts/routine.g.dart b/lib/models/workouts/routine.g.dart index 9fd9ba80..793eb9f6 100644 --- a/lib/models/workouts/routine.g.dart +++ b/lib/models/workouts/routine.g.dart @@ -20,8 +20,9 @@ Routine _$RoutineFromJson(Map json) { fitInWeek: json['fit_in_week'] as bool? ?? false, description: json['description'] as String?, days: (json['days'] as List?) - ?.map((e) => Day.fromJson(e as Map)) - .toList(), + ?.map((e) => Day.fromJson(e as Map)) + .toList() ?? + const [], ); } diff --git a/lib/models/workouts/slot_entry.dart b/lib/models/workouts/slot_entry.dart index 4581d84b..92835734 100644 --- a/lib/models/workouts/slot_entry.dart +++ b/lib/models/workouts/slot_entry.dart @@ -129,7 +129,30 @@ class SlotEntry { required this.weightUnitId, required this.weightRounding, required this.comment, - }); + this.weightConfigs = const [], + this.maxWeightConfigs = const [], + this.nrOfSetsConfigs = const [], + this.maxNrOfSetsConfigs = const [], + this.rirConfigs = const [], + this.maxRirConfigs = const [], + this.restTimeConfigs = const [], + this.maxRestTimeConfigs = const [], + this.repsConfigs = const [], + this.maxRepsConfigs = const [], + RepetitionUnit? repetitionUnit, + WeightUnit? weightUnit, + Exercise? exercise, + }) { + if (repetitionUnit != null) { + repetitionUnitObj = repetitionUnit; + } + if (weightUnit != null) { + weightUnitObj = weightUnit; + } + if (exercise != null) { + exerciseObj = exercise; + } + } SlotEntry.empty(); diff --git a/lib/models/workouts/slot_entry.g.dart b/lib/models/workouts/slot_entry.g.dart index 22f62004..2d2a99b3 100644 --- a/lib/models/workouts/slot_entry.g.dart +++ b/lib/models/workouts/slot_entry.g.dart @@ -34,48 +34,47 @@ SlotEntry _$SlotEntryFromJson(Map json) { weightUnitId: (json['weight_unit'] as num).toInt(), weightRounding: stringToNum(json['weight_rounding'] as String?), comment: json['comment'] as String, - ) - ..repsConfigs = (json['reps_configs'] as List?) + weightConfigs: (json['weight_configs'] as List?) ?.map((e) => BaseConfig.fromJson(e as Map)) .toList() ?? - [] - ..maxRepsConfigs = (json['max_reps_configs'] as List?) + [], + maxWeightConfigs: (json['max_weight_configs'] as List?) ?.map((e) => BaseConfig.fromJson(e as Map)) .toList() ?? - [] - ..weightConfigs = (json['weight_configs'] as List?) + [], + nrOfSetsConfigs: (json['set_nr_configs'] as List?) ?.map((e) => BaseConfig.fromJson(e as Map)) .toList() ?? - [] - ..maxWeightConfigs = (json['max_weight_configs'] as List?) + [], + maxNrOfSetsConfigs: (json['max_set_nr_configs'] as List?) ?.map((e) => BaseConfig.fromJson(e as Map)) .toList() ?? - [] - ..nrOfSetsConfigs = (json['set_nr_configs'] as List?) + [], + rirConfigs: (json['rir_configs'] as List?) ?.map((e) => BaseConfig.fromJson(e as Map)) .toList() ?? - [] - ..maxNrOfSetsConfigs = (json['max_set_nr_configs'] as List?) + [], + maxRirConfigs: (json['max_rir_configs'] as List?) ?.map((e) => BaseConfig.fromJson(e as Map)) .toList() ?? - [] - ..rirConfigs = (json['rir_configs'] as List?) + [], + restTimeConfigs: (json['rest_configs'] as List?) ?.map((e) => BaseConfig.fromJson(e as Map)) .toList() ?? - [] - ..maxRirConfigs = (json['max_rir_configs'] as List?) + [], + maxRestTimeConfigs: (json['max_rest_configs'] as List?) ?.map((e) => BaseConfig.fromJson(e as Map)) .toList() ?? - [] - ..restTimeConfigs = (json['rest_configs'] as List?) + [], + repsConfigs: (json['reps_configs'] as List?) ?.map((e) => BaseConfig.fromJson(e as Map)) .toList() ?? - [] - ..maxRestTimeConfigs = (json['max_rest_configs'] as List?) + [], + maxRepsConfigs: (json['max_reps_configs'] as List?) ?.map((e) => BaseConfig.fromJson(e as Map)) .toList() ?? - [] - ..config = json['config']; + [], + )..config = json['config']; } Map _$SlotEntryToJson(SlotEntry instance) => { diff --git a/lib/widgets/routines/app_bar.dart b/lib/widgets/routines/app_bar.dart index aaead093..7709c2f8 100644 --- a/lib/widgets/routines/app_bar.dart +++ b/lib/widgets/routines/app_bar.dart @@ -46,7 +46,7 @@ class RoutineListAppBar extends StatelessWidget implements PreferredSizeWidget { final i18n = AppLocalizations.of(context); return AppBar( - title: Text(i18n.labelWorkoutPlans), + title: Text(i18n.routines), actions: [ PopupMenuButton( itemBuilder: (context) { diff --git a/test_data/routines.dart b/test_data/routines.dart index abd4f84f..3e90f1f9 100644 --- a/test_data/routines.dart +++ b/test_data/routines.dart @@ -17,6 +17,7 @@ */ import 'package:wger/models/exercises/exercise.dart'; +import 'package:wger/models/workouts/base_config.dart'; import 'package:wger/models/workouts/day.dart'; import 'package:wger/models/workouts/log.dart'; import 'package:wger/models/workouts/repetition_unit.dart'; @@ -75,14 +76,34 @@ Routine getRoutine({List? exercises}) { order: 1, exerciseId: 1, repetitionUnitId: 1, - repetitionRounding: 0.25, + repetitionRounding: 1, weightUnitId: 1, - weightRounding: 0.25, + weightRounding: 1.25, comment: 'ddd', + repetitionUnit: testRepetitionUnit1, + weightUnit: testWeightUnit1, + exercise: testExercise[0], + weightConfigs: [ + BaseConfig.firstIteration(100, 1), + BaseConfig( + id: 1, + slotEntryId: 1, + iteration: 2, + value: 5, + operation: '+', + step: 'abs', + needLogToApply: false, + requirements: null, + repeat: true, + ), + ], + repsConfigs: [ + BaseConfig.firstIteration(3, 1), + ], + nrOfSetsConfigs: [ + BaseConfig.firstIteration(4, 1), + ], ); - slotEntryBenchPress.repetitionUnit = testRepetitionUnit1; - slotEntryBenchPress.weightUnit = testWeightUnit1; - slotEntryBenchPress.exercise = testExercise[0]; final slotBenchPress = Slot.withData( id: 1, @@ -103,10 +124,19 @@ Routine getRoutine({List? exercises}) { weightUnitId: 1, weightRounding: 0.25, comment: 'ddd', + repetitionUnit: testRepetitionUnit1, + weightUnit: testWeightUnit1, + exercise: testExercise[4], + weightConfigs: [ + BaseConfig.firstIteration(80, 1), + ], + repsConfigs: [ + BaseConfig.firstIteration(5, 1), + ], + nrOfSetsConfigs: [ + BaseConfig.firstIteration(3, 1), + ], ); - slotEntrySquat.repetitionUnit = testRepetitionUnit1; - slotEntrySquat.weightUnit = testWeightUnit1; - slotEntrySquat.exercise = testExercise[4]; final slotSquat = Slot.withData(id: 2, day: 1, order: 1); slotSquat.addExerciseBase(testExercise[4]); @@ -122,10 +152,19 @@ Routine getRoutine({List? exercises}) { weightUnitId: 1, weightRounding: 0.25, comment: 'ddd', + repetitionUnit: testRepetitionUnit1, + weightUnit: testWeightUnit1, + exercise: testExercise[5], + weightConfigs: [ + BaseConfig.firstIteration(10, 1), + ], + repsConfigs: [ + BaseConfig.firstIteration(12, 1), + ], + nrOfSetsConfigs: [ + BaseConfig.firstIteration(4, 1), + ], ); - slotEntrySideRaises.repetitionUnit = testRepetitionUnit1; - slotEntrySideRaises.weightUnit = testWeightUnit1; - slotEntrySideRaises.exercise = testExercise[5]; // settingSideRaises.weight = 6; final slotSideRaises = Slot.withData(id: 3, day: 1, order: 1);