mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Refactor the log entry form in the gym mode.
Previously due to rebuilds the form would e.g. not stay open after selecting a new unit (which would also not change)
This commit is contained in:
@@ -101,16 +101,16 @@ class Log {
|
||||
this.repetitions,
|
||||
this.repetitionsTarget,
|
||||
this.repetitionsUnitId = REP_UNIT_REPETITIONS_ID,
|
||||
this.repetitionsUnitObj,
|
||||
this.rir,
|
||||
this.rirTarget,
|
||||
this.weight,
|
||||
this.weightTarget,
|
||||
this.weightUnitId = WEIGHT_UNIT_KG,
|
||||
this.weightUnitObj,
|
||||
DateTime? date,
|
||||
}) : date = date ?? DateTime.now();
|
||||
|
||||
Log.empty();
|
||||
|
||||
Log.fromSetConfigData(SetConfigData setConfig) {
|
||||
date = DateTime.now();
|
||||
sessionId = null;
|
||||
@@ -142,9 +142,11 @@ class Log {
|
||||
num? repetitions,
|
||||
num? repetitionsTarget,
|
||||
int? repetitionsUnitId,
|
||||
RepetitionUnit? repetitionsUnitObj,
|
||||
num? weight,
|
||||
num? weightTarget,
|
||||
int? weightUnitId,
|
||||
WeightUnit? weightUnitObj,
|
||||
DateTime? date,
|
||||
}) {
|
||||
final out = Log(
|
||||
@@ -156,11 +158,13 @@ class Log {
|
||||
repetitions: repetitions ?? this.repetitions,
|
||||
repetitionsTarget: repetitionsTarget ?? this.repetitionsTarget,
|
||||
repetitionsUnitId: repetitionsUnitId ?? this.repetitionsUnitId,
|
||||
repetitionsUnitObj: repetitionsUnitObj ?? this.repetitionsUnitObj,
|
||||
rir: rir ?? this.rir,
|
||||
rirTarget: rirTarget ?? this.rirTarget,
|
||||
weight: weight ?? this.weight,
|
||||
weightTarget: weightTarget ?? this.weightTarget,
|
||||
weightUnitId: weightUnitId ?? this.weightUnitId,
|
||||
weightUnitObj: weightUnitObj ?? this.weightUnitObj,
|
||||
date: date ?? this.date,
|
||||
);
|
||||
|
||||
@@ -168,9 +172,16 @@ class Log {
|
||||
out.sessionId = sessionId;
|
||||
}
|
||||
|
||||
if (repetitionsUnitObj != null) {
|
||||
out.repetitionsUnitObj = repetitionsUnitObj;
|
||||
out.repetitionsUnitId = repetitionsUnitObj.id;
|
||||
}
|
||||
|
||||
if (weightUnitObj != null) {
|
||||
out.weightUnitObj = weightUnitObj;
|
||||
out.weightUnitId = weightUnitObj.id;
|
||||
}
|
||||
out.exerciseBase = exercise;
|
||||
out.repetitionUnit = repetitionsUnitObj;
|
||||
out.weightUnitObj = weightUnitObj;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 wger Team
|
||||
* Copyright (c) 2020 - 2026 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
|
||||
@@ -32,7 +32,7 @@ class RepetitionUnit {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RepetitionUnit{id: $id, name: $name}';
|
||||
return 'RepetitionUnit(id: $id, name: $name)';
|
||||
}
|
||||
|
||||
// Boilerplate
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 wger Team
|
||||
* Copyright (c) 2020 - 2026 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
|
||||
@@ -30,6 +30,11 @@ class WeightUnit {
|
||||
|
||||
const WeightUnit({required this.id, required this.name});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WeightUnit(id: $id, name: $name)';
|
||||
}
|
||||
|
||||
// Boilerplate
|
||||
factory WeightUnit.fromJson(Map<String, dynamic> json) => _$WeightUnitFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$WeightUnitToJson(this);
|
||||
|
||||
Reference in New Issue
Block a user