import 'package:workouttest_util/util/string_extension.dart';

enum LoginType { email, fb, google, apple }

extension LoginTypeExt on LoginType {
  bool equalsTo(LoginType type) => toString() == type.toString();
  bool equalsStringTo(String type) => toString() == type;
}

enum TrackingEvent {
  enter,
  login,
  logout,
  registration,
  login_skip,
  home,
  sizes,
  sizes_save,
  my_development,
  my_exerciseplan,
  account,
  settings,
  sales_page,
  purchase_request,
  purchase_successful,
  exercise_new,
  exercise_new_no_registration,
  exercise_new_paralell,
  result,
  exercise_log,
  exercise_log_open,
  exercise_log_delete,
  exercise_log_result,
  my_body_development,
  my_muscle_development,
  my_size_development,
  my_custom_exercise_plan,
  my_custom_exercise_plan_save,
  my_exercise_plan_execute_open,
  my_exercise_plan_execute_save,
  my_special_plan,
  my_suggested_plan,
  prediction,
  search,
  exercise_device,
  customer_change,
  settings_lang,
  settings_server,
  test_set_edit,
  test_set_new,
  tutorial_step,
  tutorial_finished,
  tutorial_activate,
  terms_of_use,
  data_privacy,
  delete_account,
  faq,
  training_plan_open,
  training_plan_start,
  training_plan_execute,
  training_plan_finished,
  training_plan_custom,
  trial,
  feedback_email,
}

T enumFromString<T>(Iterable<T> values, String value) {
  return values.firstWhere((type) => type.toString().split(".").last == value);
}

extension TrackingEventExt on TrackingEvent {
  String enumToString() => toString().split(".").last;

  bool equalsTo(TrackingEvent event) => toString() == event.toString();
  bool equalsStringTo(String event) => toString() == event;
}

enum PropertyEnum { Ectomorph, Mesomorph, Endomorph }

extension PropertyExt on PropertyEnum {
  String toStr() => toString().split(".").last;

  bool equalsTo(PropertyEnum event) => toString() == event.toString();
  bool equalsStringTo(String event) => toString() == event;
}

enum SizesEnum { Weight, Height, Shoulder, Neck, Biceps, Chest, Belly, Hip, ThighTop, ThighMiddle, Knee, Calf, Ankle, Underarm, Lowerarm }

extension SizesExt on SizesEnum {
  String toStr() => toString().split(".").last;
  bool equalsTo(SizesEnum event) => toString() == event.toString();
  bool equalsStringTo(String event) => toString() == event;
}

enum EvaluationText { very_poor, poor, fair, below_average, average, above_average, good, excellent, elite }

extension EvaluationTextExt on EvaluationText {
  String toStr() => toString().split(".").last;
  bool equalsTo(EvaluationText eval) => toString() == eval.toString();
  bool equalsStringTo(String eval) => toStr() == eval;
}

enum ExerciseTypeTrainingPlanState { none, added, executed }

extension ExerciseTypeTrainingPlanStateExt on ExerciseTypeTrainingPlanState {
  String toStr() => toString().split(".").last;
  bool equalsTo(ExerciseTypeTrainingPlanState state) => toString() == state.toString();
  bool equalsStringTo(String state) => toStr() == state;
}

enum ExerciseSaveType { test, training, test_set }

extension ExerciseSaveTypeExt on ExerciseSaveType {
  String toStr() => toString().split(".").last;
  bool equalsTo(ExerciseSaveType type) => toString() == type.toString();
  bool equalsStringTo(String type) => toStr() == type;
}

enum MuscleGroup { chest, biceps, triceps, back, shoulders, core, thigh, calf }

extension MuscleGroupExt on MuscleGroup {
  String toStr() => toString().split(".").last;
  String toText() => toString().split(".").last.capitalize();
  bool equalsTo(MuscleGroup type) => toString() == type.toString();
  bool equalsStringTo(String type) => toStr() == type;
  String getStrByIndex(int index) => MuscleGroup.values.elementAt(index).toStr();
  MuscleGroup getByIndex(int index) => MuscleGroup.values.elementAt(index);
  String getTextByIndex(int index) => MuscleGroup.values.elementAt(index).toText();
}