56 lines
1.9 KiB
Swift
56 lines
1.9 KiB
Swift
//
|
|
// PlannedWorkoutView.swift
|
|
// Werkout_ios
|
|
//
|
|
// Created by Trey Tartt on 6/18/24.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct PlannedWorkoutView: View {
|
|
let workouts: [PlannedWorkout]
|
|
@Binding var selectedPlannedWorkout: Workout?
|
|
|
|
var body: some View {
|
|
List {
|
|
ForEach(workouts.sorted(by: { $0.onDate < $1.onDate }), id: \.id) { plannedWorkout in
|
|
Button(action: {
|
|
selectedPlannedWorkout = plannedWorkout.workout
|
|
}, label: {
|
|
HStack {
|
|
VStack(alignment: .leading) {
|
|
Text(plannedWorkout.onDate.plannedDate?.weekDay ?? "-")
|
|
.font(.title)
|
|
|
|
Text(plannedWorkout.onDate.plannedDate?.monthString ?? "-")
|
|
.font(.title)
|
|
|
|
Text(plannedWorkout.onDate.plannedDate?.dateString ?? "-")
|
|
.font(.title)
|
|
}
|
|
|
|
Divider()
|
|
|
|
VStack {
|
|
Text(plannedWorkout.workout.name)
|
|
.font(.title)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
Text(plannedWorkout.workout.description ?? "")
|
|
.font(.body)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
}
|
|
})
|
|
.buttonStyle(.plain)
|
|
.accessibilityLabel("Open planned workout \(plannedWorkout.workout.name)")
|
|
.accessibilityHint("Shows workout details")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//#Preview {
|
|
// PlannedWorkoutView()
|
|
//}
|