workouttest_app/lib/model/workout_menu_tree.dart
2020-12-17 22:32:45 +01:00

67 lines
1.6 KiB
Dart

import 'dart:ui';
import 'exercise_type.dart';
enum WorkoutType { endurance, oneRepMax, cardio, staticExercise }
extension WorkoutTypeExt on WorkoutType {
static const WorkoutTypeMenu = {
WorkoutType.endurance: "Endurance",
WorkoutType.cardio: "Cardio",
WorkoutType.oneRepMax: "One Rep Max",
WorkoutType.staticExercise: "Static"
};
bool equals(WorkoutType type) => this.toString() == type.toString();
bool equalsString(String type) => this.toString() == type;
String get menu => WorkoutTypeMenu[this];
}
class WorkoutMenuTree {
int id;
int parent;
String name;
String imageName;
Color color;
double fontSize;
bool child;
int exerciseTypeId;
ExerciseType exerciseType;
bool base;
bool is1RM;
bool isEndurance;
bool isRunning;
List<WorkoutType> workoutTypes = List();
bool selected = false;
bool executed = false;
String exerciseDetail;
String nameEnglish;
WorkoutMenuTree(this.id, this.parent, this.name, this.imageName, this.color, this.fontSize, this.child, this.exerciseTypeId,
this.exerciseType, this.base, this.is1RM, this.isEndurance, this.isRunning, this.nameEnglish);
Map<String, dynamic> toJson() {
return {
"id": id,
"parent": parent,
"name": name,
"imageName": imageName,
"color": color.toString(),
"fontSize": fontSize.toString(),
"child": child.toString(),
"exerciseTypeId": exerciseTypeId.toString(),
"base": base.toString(),
"is1RM": is1RM.toString(),
"isEndurance": isEndurance.toString(),
"isRunning": isRunning.toString(),
};
}
@override
String toString() {
return this.toJson().toString();
}
}