rework timer and how we manage actions

This commit is contained in:
Joshua Burman
2024-12-06 17:33:33 -05:00
parent 56b25a6963
commit 19f835d8f2
4 changed files with 385 additions and 150 deletions

View File

@ -14,6 +14,64 @@ class ActivityAction {
required this.activityActionSet,
this.media,
});
List<List<Map<String, dynamic>>> items() {
List<List<Map<String, dynamic>>> sets = [];
Reps reps = activityActionSet.reps;
for (int i = 0; i < activityActionSet.total; i++) {
List<Map<String, dynamic>> actions = [];
int? weight = _setWeight(i);
actions.add({
'name': title,
'type': reps.type,
'amount': reps.amounts[i],
'weight': weight,
});
if (activityActionSet.type == 'alternating') {
if (reps.rest != null) {
actions.add({
'name': 'Rest',
'type': 'seconds',
'amount': reps.amounts[i],
});
}
actions.add({
'name': title,
'type': reps.type,
'amount': reps.amounts[i],
'weights': weight,
});
}
actions.add({
'name': 'Rest',
'type': 'seconds',
'amount': activityActionSet.rest ~/ 1000,
});
sets.add(actions);
// for (int j = 0; i < activityActionSet.reps.amounts; j++) {}
}
return sets;
}
int? _setWeight(setNum) {
Reps reps = activityActionSet.reps;
if (reps.weights.length == activityActionSet.total) {
return reps.weights[setNum];
} else if (reps.weights.length == 1) {
return reps.weights[0];
}
return null;
}
}
class Set {
@ -34,14 +92,14 @@ class Reps {
String type;
List<int> tempo;
List<int> amounts;
List<int> weights;
int rest;
List<int> weights = [];
int? rest;
Reps({
required this.type,
required this.tempo,
required this.amounts,
required this.weights,
required this.rest,
this.rest,
});
}