118 lines
2.4 KiB
Dart
118 lines
2.4 KiB
Dart
import 'package:sendtrain/classes/media.dart';
|
|
|
|
class ActivityAction {
|
|
int id;
|
|
String title;
|
|
String description;
|
|
Set activityActionSet;
|
|
List<Media>? media;
|
|
|
|
ActivityAction({
|
|
required this.id,
|
|
required this.title,
|
|
required this.description,
|
|
required this.activityActionSet,
|
|
this.media,
|
|
});
|
|
|
|
List<List<Map<String, dynamic>>> items() {
|
|
List<List<Map<String, dynamic>>> sets = [];
|
|
Reps reps = activityActionSet.reps;
|
|
int totalActions = 0;
|
|
|
|
for (int i = 0; i < activityActionSet.total; i++) {
|
|
List<Map<String, dynamic>> actions = [];
|
|
int? weight = _setWeight(i);
|
|
|
|
actions.add({
|
|
'actionID': totalActions++,
|
|
'name': title,
|
|
'type': reps.type,
|
|
'amount': reps.amounts[i],
|
|
'weight': weight,
|
|
});
|
|
|
|
if (activityActionSet.type == 'alternating') {
|
|
if (reps.rest != null) {
|
|
actions.add({
|
|
'actionID': totalActions++,
|
|
'name': 'Rest',
|
|
'type': 'seconds',
|
|
'amount': reps.rest! ~/ 1000,
|
|
});
|
|
}
|
|
|
|
actions.add({
|
|
'actionID': totalActions++,
|
|
'name': title,
|
|
'type': reps.type,
|
|
'amount': reps.amounts[i],
|
|
'weights': weight,
|
|
});
|
|
}
|
|
|
|
actions.add({
|
|
'actionID': totalActions++,
|
|
'name': 'Rest',
|
|
'type': 'seconds',
|
|
'amount': activityActionSet.rest ~/ 1000,
|
|
});
|
|
|
|
sets.add(actions);
|
|
|
|
// sets.add([{
|
|
// 'actionID': totalActions++,
|
|
// 'name': 'Rest',
|
|
// 'type': 'seconds',
|
|
// 'amount': activityActionSet.rest ~/ 1000,
|
|
// }]);
|
|
|
|
// 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 {
|
|
String type;
|
|
int total;
|
|
int rest;
|
|
Reps reps;
|
|
|
|
Set({
|
|
required this.type,
|
|
required this.total,
|
|
required this.rest,
|
|
required this.reps,
|
|
});
|
|
}
|
|
|
|
class Reps {
|
|
String type;
|
|
List<int> tempo;
|
|
List<int> amounts;
|
|
List<int> weights = [];
|
|
int? rest;
|
|
|
|
Reps({
|
|
required this.type,
|
|
required this.tempo,
|
|
required this.amounts,
|
|
required this.weights,
|
|
this.rest,
|
|
});
|
|
}
|