69 lines
2.4 KiB
Swift
69 lines
2.4 KiB
Swift
import SwiftUI
|
|
|
|
struct WorkoutDetailView: View {
|
|
@ObservedObject var workoutManager: WorkoutManager
|
|
|
|
var body: some View {
|
|
List {
|
|
if let workout = workoutManager.selectedWorkout {
|
|
Section {
|
|
VStack(spacing: 8) {
|
|
Text(workout.name ?? "Workout")
|
|
.font(.headline)
|
|
|
|
Text("\(Int(workout.poolLength))m pool")
|
|
.font(.caption)
|
|
.foregroundColor(.secondary)
|
|
|
|
let totalM = workout.sets.reduce(0) { $0 + $1.distancePerRep * $1.repCount }
|
|
Text("\(totalM)m total")
|
|
.font(.caption)
|
|
.foregroundColor(.secondary)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
.padding(.vertical, 4)
|
|
}
|
|
|
|
Section("Sets") {
|
|
ForEach(Array(workout.sets.enumerated()), id: \.offset) { i, set in
|
|
HStack {
|
|
Text("\(i + 1). \(set.stroke)")
|
|
.font(.body)
|
|
Spacer()
|
|
Text("\(set.repCount)x\(set.distancePerRep)m")
|
|
.font(.caption)
|
|
.foregroundColor(.secondary)
|
|
}
|
|
.listRowBackground(.clear)
|
|
}
|
|
}
|
|
|
|
Section {
|
|
Button {
|
|
workoutManager.startWorkout()
|
|
} label: {
|
|
HStack {
|
|
Spacer()
|
|
Image(systemName: "play.fill")
|
|
Text("Start")
|
|
.font(.headline)
|
|
Spacer()
|
|
}
|
|
}
|
|
.buttonStyle(.borderedProminent)
|
|
.tint(.cyan)
|
|
|
|
Button("Back") {
|
|
workoutManager.selectedWorkout = nil
|
|
}
|
|
.font(.caption)
|
|
.foregroundColor(.secondary)
|
|
.frame(maxWidth: .infinity)
|
|
.listRowBackground(.clear)
|
|
}
|
|
}
|
|
}
|
|
.listStyle(.automatic)
|
|
}
|
|
}
|