Files
workoutsplus/WorkoutsPlus/Features/Exercise/Exercise.swift
2024-10-21 15:03:47 +02:00

76 lines
2.2 KiB
Swift

//
// Exercise.swift
// WorkoutsPlus
//
// 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
@Model
final class Exercise: Nameable {
static var systemImage = "figure.run"
var id = UUID()
var creationDate: Date = Date.now
@Attribute(.unique) var name: String
var exerciseDescription: String = ""
var isPartOfProgression: Bool = false
var metric: ExerciseMetric
var equipment: [Equipment] = []
init(_ name: String, _ metric: ExerciseMetric = .none) {
self.name = name
self.metric = metric
}
}
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"),
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", .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")
]
}