WIP
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -34,10 +34,7 @@ struct WorkoutDetailView: View {
|
||||
ExerciseListView(workout: workout)
|
||||
ActionsView(completedWorkout: {
|
||||
bridgeModule.workoutEndDate = Date()
|
||||
if let workoutData = createWorkoutData() {
|
||||
presentedSheet = .completedWorkout(workoutData)
|
||||
bridgeModule.resetCurrentWorkout()
|
||||
}
|
||||
bridgeModule.sendWorkoutCompleteToWatch()
|
||||
}, workout: workout)
|
||||
.frame(height: 44)
|
||||
|
||||
@@ -55,6 +52,14 @@ struct WorkoutDetailView: View {
|
||||
.interactiveDismissDisabled()
|
||||
}
|
||||
}
|
||||
.onAppear{
|
||||
bridgeModule.completedWorkoutFromWatch = {
|
||||
if let workoutData = createWorkoutData() {
|
||||
presentedSheet = .completedWorkout(workoutData)
|
||||
bridgeModule.resetCurrentWorkout()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func createWorkoutData() -> [String:Any]? {
|
||||
@@ -68,7 +73,9 @@ struct WorkoutDetailView: View {
|
||||
"workout_start_time": startTime,
|
||||
"workout_end_time": endTime,
|
||||
"workout": workoutid,
|
||||
"total_time": bridgeModule.currentWorkoutRunTimeInSeconds
|
||||
"total_time": bridgeModule.currentWorkoutRunTimeInSeconds,
|
||||
"total_calories": bridgeModule.totalCaloire ?? -1,
|
||||
"heart_rates": bridgeModule.heartRates ?? [Int]()
|
||||
] as [String : Any]
|
||||
|
||||
return postBody
|
||||
|
||||
Reference in New Issue
Block a user