simplify Exercise to only hold on to the unit of the metric, remove ValueKeyboard as input
This commit is contained in:
@@ -5,6 +5,14 @@
|
||||
// Created by Felix Förtsch on 25.08.24.
|
||||
//
|
||||
|
||||
// TODO: The model currently has an issue. I think An exercise always (!) has reps 1x 30s or 8x 1 0 kg Push-up. I stumbled upon the issue through the fact that bodyweight exercises can be loaded and for the user it makes sense that a Push-up is the same a Push-up with 10 kg load.
|
||||
// var equipment: [Equipment]
|
||||
// var isPartOfProgression: Bool = false
|
||||
// var type: ExerciseType = [.cardio, .flexibility, .strength, .balance]
|
||||
// var focus: ExerciseFocus? // Strength, Flexibility, Speed, etc
|
||||
// TODO: add a way to save suggested metrics (distance, reps, etc)
|
||||
|
||||
|
||||
import Foundation
|
||||
import SwiftData
|
||||
|
||||
@@ -15,74 +23,53 @@ final class Exercise: Nameable {
|
||||
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
|
||||
var metric: ExerciseMetric
|
||||
|
||||
init(_ name: String, _ metric: ExerciseMetric) {
|
||||
var equipment: [Equipment] = []
|
||||
|
||||
init(_ name: String, _ metric: ExerciseMetric = .none) {
|
||||
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."
|
||||
}
|
||||
}
|
||||
enum ExerciseMetric: String, Codable, CaseIterable, Identifiable {
|
||||
case none = ""
|
||||
case distance = "Distance"
|
||||
case time = "Time"
|
||||
case weight = "Weight"
|
||||
|
||||
var id: Self { self }
|
||||
}
|
||||
|
||||
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)
|
||||
Exercise("Shoulder Band Warm-up"),
|
||||
Exercise("Squat Sky Reaches"),
|
||||
Exercise("GMB Wrist Prep", .time),
|
||||
Exercise("Dead Bugs"),
|
||||
Exercise("Pull-up Progression", .weight),
|
||||
Exercise("Dip Progression", .weight),
|
||||
Exercise("Squat Progression", .weight),
|
||||
Exercise("Hinge Progression", .weight),
|
||||
Exercise("Row Progression", .weight),
|
||||
Exercise("Push-up Progression", .weight),
|
||||
Exercise("Handstand Practice", .time),
|
||||
Exercise("Support Practice", .time)
|
||||
]
|
||||
|
||||
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),
|
||||
Exercise("Dips", .weight),
|
||||
Exercise("Chin-ups", .weight),
|
||||
Exercise("Push-ups", .weight),
|
||||
Exercise("Inverted Rows", .weight),
|
||||
Exercise("Hanging Knee Raises", .weight),
|
||||
Exercise("Pistol Squats", .weight),
|
||||
Exercise("Hanging Leg Curls", .weight),
|
||||
Exercise("Sissy Squats")
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user