This commit is contained in:
Trey t
2023-07-03 20:18:08 -05:00
parent 5c66ceff9f
commit 85dfc0a931
8 changed files with 190 additions and 80 deletions

View File

@@ -7,6 +7,7 @@
import Foundation
import WatchConnectivity
import AVFoundation
enum WatchActions: Codable {
case nextExercise
@@ -125,6 +126,14 @@ class BridgeModule: NSObject, ObservableObject {
let watchModel = WatchPackageModel(currentExerciseName: currentExercise?.exercise.name ?? "-", currentTimeLeft: currentExerciseTimeLeft, workoutStartDate: workoutStartDate ?? Date())
let data = try! JSONEncoder().encode(watchModel)
send(data)
if currentExerciseTimeLeft == 0 {
playFinished()
} else {
if currentExerciseTimeLeft < 4 {
playBeep()
}
}
} else {
nextExercise()
}
@@ -166,6 +175,18 @@ class BridgeModule: NSObject, ObservableObject {
completedWorkout?()
}
}
func playBeep() {
#if os(iOS)
AudioServicesPlaySystemSound(SystemSoundID(1052))
#endif
}
func playFinished() {
#if os(iOS)
AudioServicesPlaySystemSound(SystemSoundID(1070))
#endif
}
}
extension BridgeModule: WCSessionDelegate {