86 lines
2.5 KiB
Swift
86 lines
2.5 KiB
Swift
//
|
|
// WorkoutHistoryView.swift
|
|
// Werkout_ios
|
|
//
|
|
// Created by Trey Tartt on 6/26/23.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct WorkoutHistoryView: View {
|
|
enum DifficltyString: Int {
|
|
case easy = 1
|
|
case moderate
|
|
case average
|
|
case hard
|
|
case death
|
|
|
|
var stringValue: String {
|
|
switch self {
|
|
|
|
case .easy:
|
|
return "Easy"
|
|
case .moderate:
|
|
return "Moderate"
|
|
case .average:
|
|
return "Average"
|
|
case .hard:
|
|
return "Hard"
|
|
case .death:
|
|
return "Death"
|
|
}
|
|
}
|
|
}
|
|
|
|
let completedWorkouts: [CompletedWorkout]
|
|
|
|
var body: some View {
|
|
List {
|
|
ForEach(completedWorkouts, id:\.self.id) { completedWorkout in
|
|
HStack {
|
|
VStack {
|
|
if let date = completedWorkout.workoutStartTime.dateFromServerDate {
|
|
Text(DateFormatter().shortMonthSymbols[date.get(.month) - 1])
|
|
|
|
Text("\(date.get(.day))")
|
|
Text("\(date.get(.hour))")
|
|
}
|
|
}
|
|
|
|
VStack(alignment: .leading) {
|
|
HStack {
|
|
|
|
}
|
|
Text(completedWorkout.workout.name)
|
|
.font(.title3)
|
|
|
|
if let desc = completedWorkout.workout.description {
|
|
Text(desc)
|
|
.font(.footnote)
|
|
}
|
|
|
|
Divider()
|
|
|
|
if let difficulty = completedWorkout.difficulty,
|
|
let string = DifficltyString.init(rawValue: difficulty)?.stringValue {
|
|
Text(string)
|
|
}
|
|
|
|
if let notes = completedWorkout.notes {
|
|
Text(notes)
|
|
}
|
|
}
|
|
.padding(.leading)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct WorkoutHistoryView_Previews: PreviewProvider {
|
|
static let fakeHistory = PreviewData.parseCompletedWorkouts()
|
|
static var previews: some View {
|
|
WorkoutHistoryView(completedWorkouts: fakeHistory)
|
|
}
|
|
}
|