complete then get health data on completion screen
This commit is contained in:
@@ -10,20 +10,19 @@ import HealthKit
|
||||
|
||||
struct CompletedWorkoutView: View {
|
||||
@ObservedObject var bridgeModule = BridgeModule.shared
|
||||
var postData: [String: Any]
|
||||
let healthKitHelper = HealthKitHelper()
|
||||
let workout: Workout
|
||||
let healthKitUUID: UUID?
|
||||
@State var healthKitWorkoutData: HealthKitWorkoutData?
|
||||
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
@State var difficulty: Float = 0
|
||||
@State var notes: String = ""
|
||||
let completedWorkoutDismissed: ((Bool) -> Void)?
|
||||
@State var isUploading: Bool = false
|
||||
@State var gettingHealthKitData: Bool = false
|
||||
|
||||
var postData: [String: Any]
|
||||
let healthKitHelper = HealthKitHelper()
|
||||
let workout: Workout
|
||||
let completedWorkoutDismissed: ((Bool) -> Void)?
|
||||
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
if isUploading {
|
||||
@@ -105,6 +104,9 @@ struct CompletedWorkoutView: View {
|
||||
.padding([.leading, .trailing])
|
||||
}
|
||||
.onAppear{
|
||||
bridgeModule.sendWorkoutCompleteToWatch()
|
||||
}
|
||||
.onChange(of: bridgeModule.healthKitUUID, perform: { healthKitUUID in
|
||||
if let healthKitUUID = healthKitUUID {
|
||||
gettingHealthKitData = true
|
||||
healthKitHelper.getDetails(forHealthKitUUID: healthKitUUID,
|
||||
@@ -113,7 +115,7 @@ struct CompletedWorkoutView: View {
|
||||
gettingHealthKitData = false
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func topViews() -> some View {
|
||||
@@ -167,7 +169,7 @@ struct CompletedWorkoutView: View {
|
||||
var _postBody = postBody
|
||||
_postBody["difficulty"] = difficulty
|
||||
_postBody["notes"] = notes
|
||||
if let healthKitUUID = healthKitUUID {
|
||||
if let healthKitUUID = bridgeModule.healthKitUUID {
|
||||
_postBody["health_kit_workout_uuid"] = healthKitUUID.uuidString
|
||||
}
|
||||
|
||||
@@ -204,7 +206,6 @@ struct CompletedWorkoutView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
CompletedWorkoutView(postData: CompletedWorkoutView_Previews.postBody,
|
||||
workout: workout,
|
||||
healthKitUUID: nil,
|
||||
completedWorkoutDismissed: { _ in })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user