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 {
  late int id;
  late int parent;
  late String name;
  late String imageName;
  late Color color;
  late double fontSize;
  late bool child;
  late int exerciseTypeId;
  ExerciseType? exerciseType;
  late bool base;

  late bool is1RM;
  late bool isRunning;
  List<WorkoutType> workoutTypes = [];
  bool selected = false;
  bool executed = false;
  late String exerciseDetail;
  late String nameEnglish;
  late String parentName;
  late String parentNameEnglish;
  late int sort;

  WorkoutMenuTree(this.id, this.parent, this.name, this.imageName, this.color, this.fontSize, this.child, this.exerciseTypeId,
      this.exerciseType, this.base, this.is1RM, this.isRunning, this.nameEnglish, this.parentName, this.parentNameEnglish, this.sort);

  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(),
      "isRunning": isRunning.toString(),
      "sort": sort,
    };
  }

  @override
  String toString() {
    return this.toJson().toString();
  }
}