add ValueKeyboard as input for exercise values
This commit is contained in:
@@ -24,7 +24,6 @@ final class Workout: Nameable, Hashable {
|
||||
|
||||
// TODO: Expected Duration (learn from past workouts with ML and predict workout duration from that
|
||||
|
||||
|
||||
@Relationship(deleteRule: .cascade) private var workoutItems: [WorkoutItem] = []
|
||||
func getWorkoutItems() -> [WorkoutItem] {
|
||||
return workoutItems.sorted { $0.position < $1.position }
|
||||
|
||||
@@ -16,14 +16,20 @@ final class WorkoutItem: Nameable, Positionable {
|
||||
var workout: Workout?
|
||||
var workoutItemType: WorkoutItemType
|
||||
enum WorkoutItemType: Codable {
|
||||
// TODO: Add workout as WorkoutItemType (needs recursive dealing)
|
||||
// case workout
|
||||
case rest
|
||||
case set
|
||||
case workout
|
||||
case exerciseWithReps
|
||||
case exerciseWithDuration
|
||||
case rest
|
||||
}
|
||||
|
||||
var position: Int = 0
|
||||
// TODO: Wondering if a SortDescriptor in the Model is useful?
|
||||
// https://old.reddit.com/r/SwiftUI/comments/1fnvkud/extracting_the_creation_of_swiftdata_query_into/
|
||||
// static var sorted: SortDescriptor<WorkoutItem> {
|
||||
// SortDescriptor(\.position, order: .forward)
|
||||
// }
|
||||
|
||||
var reps: Int = 0
|
||||
var duration: Int = 0
|
||||
@@ -90,11 +96,11 @@ extension WorkoutItem {
|
||||
exercises.append(WorkoutItem(exercise: exercise))
|
||||
}
|
||||
|
||||
// var set = WorkoutItem(workoutItems: [
|
||||
// WorkoutItem(from: Exercise("Set item 1")),
|
||||
// WorkoutItem(from: Exercise("Set item 2"))
|
||||
// ])
|
||||
// exercises.append(set)
|
||||
// var set = WorkoutItem(workoutItems: [
|
||||
// WorkoutItem(from: Exercise("Set item 1")),
|
||||
// WorkoutItem(from: Exercise("Set item 2"))
|
||||
// ])
|
||||
// exercises.append(set)
|
||||
|
||||
return exercises
|
||||
}()
|
||||
|
||||
@@ -12,6 +12,7 @@ import SwiftData
|
||||
final class WorkoutSession: Nameable {
|
||||
var id = UUID()
|
||||
var name = ""
|
||||
// The Workout is what *should* happen
|
||||
var workout: Workout? {
|
||||
didSet {
|
||||
self.name = workout?.name ?? "Unknown Workout"
|
||||
|
||||
Reference in New Issue
Block a user