import 'package:sendtrain/classes/media.dart'; class ActivityAction { int id; String title; String description; Set activityActionSet; List? media; ActivityAction({ required this.id, required this.title, required this.description, required this.activityActionSet, this.media, }); List>> items() { List>> sets = []; Reps reps = activityActionSet.reps; int totalActions = 1; for (int i = 0; i < activityActionSet.total; i++) { List> 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.amounts[i], }); } 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); // 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 tempo; List amounts; List weights = []; int? rest; Reps({ required this.type, required this.tempo, required this.amounts, required this.weights, this.rest, }); }