This commit is contained in:
Trey t
2023-06-24 00:01:32 -05:00
parent 36400d1f79
commit 01915752b6
6 changed files with 120 additions and 46 deletions

View File

@@ -19,37 +19,18 @@ struct CompletedWorkoutView: View {
var body: some View {
VStack {
Text(workout.name)
.frame(maxWidth: .infinity, alignment: .leading)
.font(.title3)
.padding(.top
)
if let desc = workout.description {
Text(desc)
.frame(maxWidth: .infinity, alignment: .leading)
.font(.body)
.padding(.top)
}
topViews()
Divider()
calsBurned()
Text("how hard was this shit")
HStack {
Text("easy")
Spacer()
Text("Death")
}
Slider(value: $difficulty, in: 0...5, step: 1)
heartRates()
rateWorkout()
Divider()
TextField("Notes", text: $notes)
// Divider()
Spacer()
Button("Upload", action: {
@@ -66,6 +47,57 @@ struct CompletedWorkoutView: View {
.padding([.leading, .trailing])
}
func topViews() -> some View {
VStack {
Text(workout.name)
.frame(maxWidth: .infinity, alignment: .leading)
.font(.title3)
.padding(.top
)
if let desc = workout.description {
Text(desc)
.frame(maxWidth: .infinity, alignment: .leading)
.font(.body)
.padding(.top)
}
}
}
func calsBurned() -> some View {
VStack {
Divider()
Text("calroies burned")
Text("\(postData["total_calories"] as! Float)")
}
}
func rateWorkout() -> some View {
VStack {
Divider()
Text("how hard was this shit")
HStack {
Text("easy")
Spacer()
Text("Death")
}
Slider(value: $difficulty, in: 0...5, step: 1)
}
}
func heartRates() -> some View {
VStack {
Divider()
if let heartRates = postData["heart_rates"] as? [Int] {
let avg = heartRates.reduce(0, +)/heartRates.count
Text("Avg heart rate: \(avg)")
}
}
}
func upload(postBody: [String: Any]) {
var _postBody = postBody
_postBody["difficulty"] = difficulty