diff --git a/WekoutThotViewer/WekoutThotViewer.xcodeproj/project.pbxproj b/WekoutThotViewer/WekoutThotViewer.xcodeproj/project.pbxproj index 8e4869a..0d8d9c5 100644 --- a/WekoutThotViewer/WekoutThotViewer.xcodeproj/project.pbxproj +++ b/WekoutThotViewer/WekoutThotViewer.xcodeproj/project.pbxproj @@ -34,6 +34,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 1C08B2372C234522005F07D1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 1CC0930B2C21DE760004E1E6 /* WekoutThotViewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WekoutThotViewer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1CC0930E2C21DE760004E1E6 /* WekoutThotViewerApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WekoutThotViewerApp.swift; sourceTree = ""; }; 1CC093102C21DE760004E1E6 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; @@ -132,6 +133,7 @@ 1CC0930D2C21DE760004E1E6 /* WekoutThotViewer */ = { isa = PBXGroup; children = ( + 1C08B2372C234522005F07D1 /* Info.plist */, 1CC0930E2C21DE760004E1E6 /* WekoutThotViewerApp.swift */, 1CC7CB7B2C21E089001614B8 /* RegisteredUser.swift */, 1CC093102C21DE760004E1E6 /* ContentView.swift */, @@ -387,6 +389,7 @@ DEVELOPMENT_TEAM = V3PF3M6B6U; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = WekoutThotViewer/Info.plist; INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UIUserInterfaceStyle = Automatic; LD_RUNPATH_SEARCH_PATHS = ( @@ -413,6 +416,7 @@ DEVELOPMENT_TEAM = V3PF3M6B6U; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = WekoutThotViewer/Info.plist; INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UIUserInterfaceStyle = Automatic; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/WekoutThotViewer/WekoutThotViewer/Info.plist b/WekoutThotViewer/WekoutThotViewer/Info.plist new file mode 100644 index 0000000..f753731 --- /dev/null +++ b/WekoutThotViewer/WekoutThotViewer/Info.plist @@ -0,0 +1,10 @@ + + + + + UIBackgroundModes + + audio + + + diff --git a/WekoutThotViewer/WekoutThotViewer/WekoutThotViewerApp.swift b/WekoutThotViewer/WekoutThotViewer/WekoutThotViewerApp.swift index 969ae1d..cded510 100644 --- a/WekoutThotViewer/WekoutThotViewer/WekoutThotViewerApp.swift +++ b/WekoutThotViewer/WekoutThotViewer/WekoutThotViewerApp.swift @@ -6,12 +6,16 @@ // import SwiftUI +import AVKit @main struct WekoutThotViewerApp: App { var body: some Scene { WindowGroup { ContentView() + .onAppear(perform: { + _ = try? AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback, mode: .default, options: .mixWithOthers) + }) } } } diff --git a/iphone/Werkout_ios/HealthKitHelper.swift b/iphone/Werkout_ios/HealthKitHelper.swift index 2122fc4..7c07d08 100644 --- a/iphone/Werkout_ios/HealthKitHelper.swift +++ b/iphone/Werkout_ios/HealthKitHelper.swift @@ -42,6 +42,8 @@ class HealthKitHelper { { (sampleQuery, results, error ) -> Void in if let queryError = error { + self.shitReturned() + self.shitReturned() print( "There was an error while reading the samples: \(queryError.localizedDescription)") } else { for samples: HKSample in results! { @@ -86,10 +88,8 @@ class HealthKitHelper { self.healthKitWorkoutData.minHeartRate = _minHeartRate self.healthKitWorkoutData.maxHeartRate = _maxHeartRate print("got heart") - DispatchQueue.main.async { - self.shitReturned() - } } + self.shitReturned() }) healthStore.execute(heartQuery) } @@ -108,10 +108,8 @@ class HealthKitHelper { if let result = result { self.healthKitWorkoutData.caloriesBurned = result.sumQuantity()?.doubleValue(for: HKUnit.kilocalorie()) ?? -1 print("got total burned") - DispatchQueue.main.async { - self.shitReturned() - } } + self.shitReturned() }) healthStore.execute(calQuery) } @@ -121,7 +119,7 @@ class HealthKitHelper { self.returnCount += 1 print("\(self.returnCount)") if self.returnCount == 2 { - self.completion!(self.healthKitWorkoutData) + self.completion?(self.healthKitWorkoutData) } } } diff --git a/iphone/Werkout_ios/Views/WorkoutDetail/WorkoutDetailView.swift b/iphone/Werkout_ios/Views/WorkoutDetail/WorkoutDetailView.swift index f8a631c..ca99769 100644 --- a/iphone/Werkout_ios/Views/WorkoutDetail/WorkoutDetailView.swift +++ b/iphone/Werkout_ios/Views/WorkoutDetail/WorkoutDetailView.swift @@ -19,10 +19,10 @@ struct WorkoutDetailView: View { enum Sheet: Identifiable { case completedWorkout([String: Any]) - var id: String { return UUID().uuidString } + var id: String { return "completedWorkoutSheet" } } - @State var presentedSheet: Sheet? + @State var workoutComplete: Sheet? @State var workoutToPlan: Workout? @State var showExecersizeInfo: Bool = false @@ -134,13 +134,14 @@ struct WorkoutDetailView: View { .frame(height: 44) } - .sheet(item: $presentedSheet) { item in + .sheet(item: $workoutComplete) { item in switch item { case .completedWorkout(let data): CompletedWorkoutView(postData: data, workout: workout, completedWorkoutDismissed: { uploaded in if uploaded { + bridgeModule.resetCurrentWorkout() dismiss() } }) @@ -195,7 +196,8 @@ struct WorkoutDetailView: View { func startWorkout(workout: Workout) { bridgeModule.completedWorkout = { if let workoutData = createWorkoutData() { - presentedSheet = .completedWorkout(workoutData) + workoutComplete = .completedWorkout(workoutData) + } else { bridgeModule.resetCurrentWorkout() } }