89 lines
2.8 KiB
Swift
89 lines
2.8 KiB
Swift
//
|
|
// Exercise.swift
|
|
// WorkoutsPlus
|
|
//
|
|
// Created by Felix Förtsch on 25.08.24.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftData
|
|
|
|
@Model
|
|
final class Exercise: Nameable {
|
|
static var systemImage = "figure.run"
|
|
|
|
var id = UUID()
|
|
var creationDate: Date = Date.now
|
|
|
|
// The example for a exercise is the Push-up (but could also be: a sprint interval, a jump, a marathon, etc).
|
|
@Attribute(.unique) var name: String
|
|
// Performing a push-up correctly has the following form cues
|
|
var exerciseDescription: String = ""
|
|
|
|
// A push-up is measured in reps.
|
|
var metric: ExerciseMetric
|
|
// In a typical push-up exercise you perform 8 reps.
|
|
var suggestedReps = "8" // TODO: Make a Rep
|
|
var suggestedDuration = "" // TODO: Make a Duration
|
|
var suggestedDistance = "" // TODO: Make a Distance
|
|
|
|
// A push-up is part of the Push-up Progression.
|
|
var isPartOfProgression: Bool = false
|
|
// The focus of the push-up is strength
|
|
// var focus: ExerciseFocus? // Strength, Flexibility, Speed, etc
|
|
|
|
init(_ name: String, _ metric: ExerciseMetric) {
|
|
self.name = name
|
|
self.metric = metric
|
|
}
|
|
}
|
|
|
|
enum ExerciseMetric: String, Codable {
|
|
case reps = "Reps" // Repeat the exrcise for a given amount of repetitions
|
|
case duration = "Duration" // Do the exercise for given amount of time
|
|
case distance = "Distance" // Do the exercise for a given amount of distance
|
|
// Other possible metrics:
|
|
// - Open exercise: this exercise does not bring a metric (eg running)
|
|
}
|
|
|
|
extension Exercise {
|
|
static func getAdvice(for name: String, with metric: ExerciseMetric) -> String {
|
|
switch metric {
|
|
case .reps:
|
|
return "Repeat \(name == "" ? "New Exercise" : name) 8 times."
|
|
case .duration:
|
|
return "Do \(name == "" ? "New Exercise" : name) for 30 seconds."
|
|
case .distance:
|
|
return "Do \(name == "" ? "New Exercise" : name) for 500 meters."
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Exercise {
|
|
static let sampleDataRecommendedRoutine: [Exercise] = [
|
|
Exercise("Shoulder Band Warm-up", .duration),
|
|
Exercise("Squat Sky Reaches", .reps),
|
|
Exercise("GMB Wrist Prep", .duration),
|
|
Exercise("Dead Bugs", .reps),
|
|
Exercise("Pull-up Progression", .reps),
|
|
Exercise("Dip Progression", .reps),
|
|
Exercise("Squat Progression", .reps),
|
|
Exercise("Hinge Progression", .reps),
|
|
Exercise("Row Progression", .reps),
|
|
Exercise("Push-up Progression", .reps),
|
|
Exercise("Handstand Practice", .duration),
|
|
Exercise("Support Practice", .duration)
|
|
]
|
|
|
|
static let sampleDataRings: [Exercise] = [
|
|
Exercise("Dips", .reps),
|
|
Exercise("Chin-ups", .reps),
|
|
Exercise("Push-ups", .reps),
|
|
Exercise("Inverted Rows", .reps),
|
|
Exercise("Hanging Knee Raises", .reps),
|
|
Exercise("Pistol Squats", .reps),
|
|
Exercise("Hanging Leg Curls", .reps),
|
|
Exercise("Sissy Squats", .reps),
|
|
]
|
|
}
|