mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Use updated name of repetition in API response
Also use the same name locally for more consistency
This commit is contained in:
@@ -45,17 +45,17 @@ class Log {
|
||||
@JsonKey(required: false, name: 'rir_target')
|
||||
String? rirTarget;
|
||||
|
||||
@JsonKey(required: true)
|
||||
late int reps;
|
||||
@JsonKey(required: true, name: 'repetitions')
|
||||
late int repetitions;
|
||||
|
||||
@JsonKey(required: true, name: 'reps_target')
|
||||
late int? repsTarget;
|
||||
@JsonKey(required: true, name: 'repetitions_target')
|
||||
late int? repetitionsTarget;
|
||||
|
||||
@JsonKey(required: true, name: 'repetition_unit')
|
||||
late int repetitionUnitId;
|
||||
@JsonKey(required: true, name: 'repetitions_unit')
|
||||
late int repetitionsUnitId;
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
late RepetitionUnit repetitionUnitObj;
|
||||
late RepetitionUnit repetitionsUnitObj;
|
||||
|
||||
@JsonKey(required: true, fromJson: stringToNum, toJson: numToString)
|
||||
late num weight;
|
||||
@@ -79,9 +79,9 @@ class Log {
|
||||
this.id,
|
||||
required this.exerciseId,
|
||||
required this.routineId,
|
||||
required this.reps,
|
||||
this.repsTarget,
|
||||
required this.repetitionUnitId,
|
||||
required this.repetitions,
|
||||
this.repetitionsTarget,
|
||||
required this.repetitionsUnitId,
|
||||
required this.rir,
|
||||
this.rirTarget,
|
||||
required this.weight,
|
||||
@@ -108,8 +108,8 @@ class Log {
|
||||
}
|
||||
|
||||
set repetitionUnit(RepetitionUnit repetitionUnit) {
|
||||
repetitionUnitObj = repetitionUnit;
|
||||
repetitionUnitId = repetitionUnit.id;
|
||||
repetitionsUnitObj = repetitionUnit;
|
||||
repetitionsUnitId = repetitionUnit.id;
|
||||
}
|
||||
|
||||
void setRir(String rir) {
|
||||
@@ -118,7 +118,8 @@ class Log {
|
||||
|
||||
/// 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', '');
|
||||
return repText(repetitions, repetitionsUnitObj, weight, weightUnitObj, rir)
|
||||
.replaceAll('\n', '');
|
||||
}
|
||||
|
||||
/// Override the equals operator
|
||||
@@ -132,20 +133,21 @@ class Log {
|
||||
exerciseId == o.exerciseId &&
|
||||
weight == o.weight &&
|
||||
weightUnitId == o.weightUnitId &&
|
||||
reps == o.reps &&
|
||||
repetitionUnitId == o.repetitionUnitId &&
|
||||
repetitions == o.repetitions &&
|
||||
repetitionsUnitId == o.repetitionsUnitId &&
|
||||
rir == o.rir;
|
||||
}
|
||||
|
||||
@override
|
||||
//ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
int get hashCode => Object.hash(exerciseId, weight, weightUnitId, reps, repetitionUnitId, rir);
|
||||
int get hashCode =>
|
||||
Object.hash(exerciseId, weight, weightUnitId, repetitions, repetitionsUnitId, rir);
|
||||
|
||||
//@override
|
||||
//int get hashCode => super.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Log(id: $id, ex: $exerciseId, weightU: $weightUnitId, w: $weight, repU: $repetitionUnitId, rep: $reps, rir: $rir)';
|
||||
return 'Log(id: $id, ex: $exerciseId, weightU: $weightUnitId, w: $weight, repU: $repetitionsUnitId, rep: $repetitions, rir: $rir)';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ Log _$LogFromJson(Map<String, dynamic> json) {
|
||||
'id',
|
||||
'exercise',
|
||||
'routine',
|
||||
'reps',
|
||||
'reps_target',
|
||||
'repetition_unit',
|
||||
'repetitions',
|
||||
'repetitions_target',
|
||||
'repetitions_unit',
|
||||
'weight',
|
||||
'weight_target',
|
||||
'weight_unit',
|
||||
@@ -26,9 +26,9 @@ Log _$LogFromJson(Map<String, dynamic> json) {
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
exerciseId: (json['exercise'] as num).toInt(),
|
||||
routineId: (json['routine'] as num).toInt(),
|
||||
reps: (json['reps'] as num).toInt(),
|
||||
repsTarget: (json['reps_target'] as num?)?.toInt(),
|
||||
repetitionUnitId: (json['repetition_unit'] as num).toInt(),
|
||||
repetitions: (json['repetitions'] as num).toInt(),
|
||||
repetitionsTarget: (json['repetitions_target'] as num?)?.toInt(),
|
||||
repetitionsUnitId: (json['repetitions_unit'] as num).toInt(),
|
||||
rir: json['rir'] as String?,
|
||||
rirTarget: json['rir_target'] as String?,
|
||||
weight: stringToNum(json['weight'] as String?),
|
||||
@@ -44,9 +44,9 @@ Map<String, dynamic> _$LogToJson(Log instance) => <String, dynamic>{
|
||||
'routine': instance.routineId,
|
||||
'rir': instance.rir,
|
||||
'rir_target': instance.rirTarget,
|
||||
'reps': instance.reps,
|
||||
'reps_target': instance.repsTarget,
|
||||
'repetition_unit': instance.repetitionUnitId,
|
||||
'repetitions': instance.repetitions,
|
||||
'repetitions_target': instance.repetitionsTarget,
|
||||
'repetitions_unit': instance.repetitionsUnitId,
|
||||
'weight': numToString(instance.weight),
|
||||
'weight_target': numToString(instance.weightTarget),
|
||||
'weight_unit': instance.weightUnitId,
|
||||
|
||||
@@ -313,7 +313,7 @@ class _LogPageState extends State<LogPage> {
|
||||
focusNode: focusNode,
|
||||
onFieldSubmitted: (_) {},
|
||||
onSaved: (newValue) {
|
||||
widget._log.reps = int.parse(newValue!);
|
||||
widget._log.repetitions = int.parse(newValue!);
|
||||
focusNode.unfocus();
|
||||
},
|
||||
validator: (value) {
|
||||
@@ -431,7 +431,7 @@ class _LogPageState extends State<LogPage> {
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: RepetitionUnitInputWidget(
|
||||
widget._log.repetitionUnitId,
|
||||
widget._log.repetitionsUnitId,
|
||||
onChanged: (v) => {},
|
||||
)),
|
||||
],
|
||||
@@ -530,12 +530,12 @@ class _LogPageState extends State<LogPage> {
|
||||
onTap: () {
|
||||
setState(() {
|
||||
// Text field
|
||||
_repsController.text = log.reps.toString();
|
||||
_repsController.text = log.repetitions.toString();
|
||||
_weightController.text = log.weight.toString();
|
||||
|
||||
// Drop downs
|
||||
widget._log.rir = log.rir;
|
||||
widget._log.repetitionUnit = log.repetitionUnitObj;
|
||||
widget._log.repetitionUnit = log.repetitionsUnitObj;
|
||||
widget._log.weightUnit = log.weightUnitObj;
|
||||
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
|
||||
@@ -29,9 +29,9 @@ void main() {
|
||||
id: 123,
|
||||
routineId: 100,
|
||||
exerciseId: 1,
|
||||
reps: 10,
|
||||
repetitions: 10,
|
||||
rir: '1.5',
|
||||
repetitionUnitId: 1,
|
||||
repetitionsUnitId: 1,
|
||||
weight: 20,
|
||||
weightUnitId: 1,
|
||||
date: DateTime(2010, 10, 1),
|
||||
@@ -40,9 +40,9 @@ void main() {
|
||||
id: 9,
|
||||
routineId: 42,
|
||||
exerciseId: 1,
|
||||
reps: 10,
|
||||
repetitions: 10,
|
||||
rir: '1.5',
|
||||
repetitionUnitId: 1,
|
||||
repetitionsUnitId: 1,
|
||||
weight: 20,
|
||||
weightUnitId: 1,
|
||||
date: DateTime(2063, 4, 5),
|
||||
@@ -69,12 +69,12 @@ void main() {
|
||||
});
|
||||
|
||||
test('Test different reps', () {
|
||||
log1.reps = 99;
|
||||
log1.repetitions = 99;
|
||||
expect(log1, isNot(log2));
|
||||
});
|
||||
|
||||
test('Test different rep units', () {
|
||||
log1.repetitionUnitId = 44;
|
||||
log1.repetitionsUnitId = 44;
|
||||
expect(log1, isNot(log2));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
|
||||
..weight = 10
|
||||
..rir = '1.5'
|
||||
..date = DateTime(2021, 5, 1)
|
||||
..reps = 10
|
||||
..repetitions = 10
|
||||
..routineId = 1;
|
||||
log1.exerciseBase = testExercises[0];
|
||||
log1.weightUnit = testWeightUnit1;
|
||||
@@ -58,7 +58,7 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
|
||||
..weight = 10
|
||||
..rir = '2'
|
||||
..date = DateTime(2021, 5, 1)
|
||||
..reps = 12
|
||||
..repetitions = 12
|
||||
..routineId = 1;
|
||||
log2.exerciseBase = testExercises[0];
|
||||
log2.weightUnit = testWeightUnit1;
|
||||
@@ -69,7 +69,7 @@ Routine getTestRoutine({List<Exercise>? exercises}) {
|
||||
..weight = 50
|
||||
..rir = ''
|
||||
..date = DateTime(2021, 5, 2)
|
||||
..reps = 8
|
||||
..repetitions = 8
|
||||
..routineId = 1;
|
||||
log3.exerciseBase = testExercises[1];
|
||||
log3.weightUnit = testWeightUnit1;
|
||||
|
||||
Reference in New Issue
Block a user