add draft views for sets of exercises
This commit is contained in:
@@ -12,18 +12,19 @@ import SwiftData
|
||||
final class WorkoutItem: Identifiable {
|
||||
var id = UUID()
|
||||
var name: String
|
||||
var workoutItemType: WorkoutItemType
|
||||
|
||||
|
||||
var workout: Workout?
|
||||
var children: [WorkoutItem] = []
|
||||
var workoutItemType: WorkoutItemType
|
||||
var position: Int = 0
|
||||
|
||||
var reps: Int = 8
|
||||
|
||||
// EXERCISE
|
||||
var exercise: Exercise? {
|
||||
didSet {
|
||||
self.name = exercise?.name ?? "self.name"
|
||||
}
|
||||
}
|
||||
var reps: Int = 0
|
||||
|
||||
init(_ reps: Int, _ exercise: String) {
|
||||
self.workoutItemType = .exercise
|
||||
@@ -40,8 +41,20 @@ final class WorkoutItem: Identifiable {
|
||||
self.exercise = exercise
|
||||
}
|
||||
|
||||
// SET
|
||||
var workoutItems: [WorkoutItem] = []
|
||||
|
||||
init(workoutItems: [WorkoutItem] = []) {
|
||||
self.name = "Set"
|
||||
self.workoutItemType = .set
|
||||
self.reps = 3
|
||||
workoutItems.forEach(addChild)
|
||||
}
|
||||
|
||||
func addChild(_ child: WorkoutItem) {
|
||||
self.children.append(child)
|
||||
if self.workoutItemType == .set {
|
||||
self.workoutItems.append(child)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user