This commit is contained in:
Trey t
2023-07-03 21:47:51 -05:00
parent 85dfc0a931
commit 38be95ea76
7 changed files with 69 additions and 11 deletions

View File

@@ -7,6 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
1C31C8842A53AE3E00350540 /* short_beep.m4a in Resources */ = {isa = PBXBuildFile; fileRef = 1C31C8822A53AE3E00350540 /* short_beep.m4a */; };
1C31C8852A53AE3E00350540 /* long_beep.m4a in Resources */ = {isa = PBXBuildFile; fileRef = 1C31C8832A53AE3E00350540 /* long_beep.m4a */; };
1C485C832A489B9C00A6F896 /* CompletedWorkouts.json in Resources */ = {isa = PBXBuildFile; fileRef = 1C485C822A489B9C00A6F896 /* CompletedWorkouts.json */; }; 1C485C832A489B9C00A6F896 /* CompletedWorkouts.json in Resources */ = {isa = PBXBuildFile; fileRef = 1C485C822A489B9C00A6F896 /* CompletedWorkouts.json */; };
1C485C872A4915C400A6F896 /* CreateWorkoutItemPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C485C862A4915C400A6F896 /* CreateWorkoutItemPickerView.swift */; }; 1C485C872A4915C400A6F896 /* CreateWorkoutItemPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C485C862A4915C400A6F896 /* CreateWorkoutItemPickerView.swift */; };
1C485C8A2A492BB400A6F896 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C485C892A492BB400A6F896 /* LoginView.swift */; }; 1C485C8A2A492BB400A6F896 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C485C892A492BB400A6F896 /* LoginView.swift */; };
@@ -102,6 +104,8 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
1C31C8822A53AE3E00350540 /* short_beep.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = short_beep.m4a; sourceTree = "<group>"; };
1C31C8832A53AE3E00350540 /* long_beep.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = long_beep.m4a; sourceTree = "<group>"; };
1C485C822A489B9C00A6F896 /* CompletedWorkouts.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = CompletedWorkouts.json; sourceTree = "<group>"; }; 1C485C822A489B9C00A6F896 /* CompletedWorkouts.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = CompletedWorkouts.json; sourceTree = "<group>"; };
1C485C862A4915C400A6F896 /* CreateWorkoutItemPickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreateWorkoutItemPickerView.swift; sourceTree = "<group>"; }; 1C485C862A4915C400A6F896 /* CreateWorkoutItemPickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreateWorkoutItemPickerView.swift; sourceTree = "<group>"; };
1C485C892A492BB400A6F896 /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = "<group>"; }; 1C485C892A492BB400A6F896 /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = "<group>"; };
@@ -223,6 +227,8 @@
1CF65A242A3972840042FFBD /* Werkout_ios */ = { 1CF65A242A3972840042FFBD /* Werkout_ios */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
1C31C8832A53AE3E00350540 /* long_beep.m4a */,
1C31C8822A53AE3E00350540 /* short_beep.m4a */,
1CF65A552A3AA6800042FFBD /* Werkout-ios-Info.plist */, 1CF65A552A3AA6800042FFBD /* Werkout-ios-Info.plist */,
1CF65A482A39FB910042FFBD /* JSON */, 1CF65A482A39FB910042FFBD /* JSON */,
1CF65A252A3972840042FFBD /* Werkout_iosApp.swift */, 1CF65A252A3972840042FFBD /* Werkout_iosApp.swift */,
@@ -473,6 +479,7 @@
files = ( files = (
1CF65A5F2A3BF5A60042FFBD /* Equipment.json in Resources */, 1CF65A5F2A3BF5A60042FFBD /* Equipment.json in Resources */,
1C485C832A489B9C00A6F896 /* CompletedWorkouts.json in Resources */, 1C485C832A489B9C00A6F896 /* CompletedWorkouts.json in Resources */,
1C31C8852A53AE3E00350540 /* long_beep.m4a in Resources */,
1CF65A4A2A39FBB10042FFBD /* WorkoutOne.json in Resources */, 1CF65A4A2A39FBB10042FFBD /* WorkoutOne.json in Resources */,
1CF65A652A3BF6BE0042FFBD /* AllWorkouts.json in Resources */, 1CF65A652A3BF6BE0042FFBD /* AllWorkouts.json in Resources */,
1CF65A332A3972850042FFBD /* Preview Assets.xcassets in Resources */, 1CF65A332A3972850042FFBD /* Preview Assets.xcassets in Resources */,
@@ -483,6 +490,7 @@
1CF65A542A3A9AF30042FFBD /* Straight_Leg_Sit_Up.mp4 in Resources */, 1CF65A542A3A9AF30042FFBD /* Straight_Leg_Sit_Up.mp4 in Resources */,
1CF65A2F2A3972850042FFBD /* Assets.xcassets in Resources */, 1CF65A2F2A3972850042FFBD /* Assets.xcassets in Resources */,
1CF65A872A4400E10042FFBD /* ToDo in Resources */, 1CF65A872A4400E10042FFBD /* ToDo in Resources */,
1C31C8842A53AE3E00350540 /* short_beep.m4a in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@@ -770,6 +778,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = "Werkout_watch Watch App/Werkout_watch Watch App.entitlements"; CODE_SIGN_ENTITLEMENTS = "Werkout_watch Watch App/Werkout_watch Watch App.entitlements";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
@@ -804,6 +813,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = "Werkout_watch Watch App/Werkout_watch Watch App.entitlements"; CODE_SIGN_ENTITLEMENTS = "Werkout_watch Watch App/Werkout_watch Watch App.entitlements";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;

View File

@@ -8,6 +8,7 @@
import Foundation import Foundation
import WatchConnectivity import WatchConnectivity
import AVFoundation import AVFoundation
import HealthKit
enum WatchActions: Codable { enum WatchActions: Codable {
case nextExercise case nextExercise
@@ -40,6 +41,8 @@ class BridgeModule: NSObject, ObservableObject {
public private(set) var totalCaloire: Float? public private(set) var totalCaloire: Float?
public private(set) var heartRates: [Int]? public private(set) var heartRates: [Int]?
var audioPlayer: AVAudioPlayer?
func start(workout: Workout) { func start(workout: Workout) {
self.currentWorkout = workout self.currentWorkout = workout
currentWorkoutRunTimeInSeconds = 0 currentWorkoutRunTimeInSeconds = 0
@@ -52,11 +55,12 @@ class BridgeModule: NSObject, ObservableObject {
startWorkoutTimer() startWorkoutTimer()
workoutStartDate = Date() workoutStartDate = Date()
isInWorkout = true isInWorkout = true
if WCSession.isSupported() { if WCSession.isSupported() {
WCSession.default.delegate = self WCSession.default.delegate = self
WCSession.default.activate() WCSession.default.activate()
} }
} }
func goToExerciseAt(index: Int) { func goToExerciseAt(index: Int) {
@@ -178,13 +182,37 @@ class BridgeModule: NSObject, ObservableObject {
func playBeep() { func playBeep() {
#if os(iOS) #if os(iOS)
AudioServicesPlaySystemSound(SystemSoundID(1052)) if let path = Bundle.main.path(forResource: "short_beep", ofType: "m4a") {
do {
try AVAudioSession.sharedInstance().setCategory(.playback,
mode: .default,
options: [.mixWithOthers, .allowAirPlay])
try AVAudioSession.sharedInstance().setActive(true)
audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: path))
audioPlayer?.play()
} catch {
print("ERROR")
}
}
#endif #endif
} }
func playFinished() { func playFinished() {
#if os(iOS) #if os(iOS)
AudioServicesPlaySystemSound(SystemSoundID(1070)) if let path = Bundle.main.path(forResource: "long_beep", ofType: "m4a") {
do {
try AVAudioSession.sharedInstance().setCategory(.playback,
mode: .default,
options: [.mixWithOthers, .allowAirPlay])
try AVAudioSession.sharedInstance().setActive(true)
audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: path))
audioPlayer?.play()
} catch {
print("ERROR")
}
}
#endif #endif
} }
} }
@@ -221,6 +249,16 @@ extension BridgeModule: WCSessionDelegate {
print("inactive") print("inactive")
case .activated: case .activated:
print("activated") print("activated")
#if os(iOS)
let workoutConfiguration = HKWorkoutConfiguration()
workoutConfiguration.activityType = .traditionalStrengthTraining
workoutConfiguration.locationType = .indoor
if WCSession.isSupported(), WCSession.default.activationState == .activated, WCSession.default.isWatchAppInstalled {
HKHealthStore().startWatchApp(with: workoutConfiguration, completion: { (success, error) in
print(error.debugDescription)
})
}
#endif
} }
} }
#if os(iOS) #if os(iOS)

View File

@@ -89,7 +89,7 @@ struct ExtExerciseList: View {
HStack { HStack {
if i == currentExerciseIdx { if i == currentExerciseIdx {
Image(systemName: "checkmark") Image(systemName: "checkmark")
.font(Font.system(size: 75)) .font(Font.system(size: 55))
.scaledToFit() .scaledToFit()
.minimumScaleFactor(0.01) .minimumScaleFactor(0.01)
.lineLimit(1) .lineLimit(1)
@@ -97,7 +97,7 @@ struct ExtExerciseList: View {
} }
Text(obj.exercise.name) Text(obj.exercise.name)
.font(Font.system(size: 75)) .font(Font.system(size: 55))
.scaledToFit() .scaledToFit()
.minimumScaleFactor(0.01) .minimumScaleFactor(0.01)
.lineLimit(1) .lineLimit(1)
@@ -151,14 +151,16 @@ struct ExtCountdownView: View {
.scaledToFit() .scaledToFit()
.minimumScaleFactor(0.01) .minimumScaleFactor(0.01)
.lineLimit(1) .lineLimit(1)
.padding([.leading, .trailing]) .padding(.leading)
.padding(.trailing, 100)
} else if let reps = currenExercise.reps { } else if let reps = currenExercise.reps {
Text("\(reps)") Text("\(reps)")
.font(Font.system(size: 75)) .font(Font.system(size: 75))
.scaledToFit() .scaledToFit()
.minimumScaleFactor(0.01) .minimumScaleFactor(0.01)
.lineLimit(1) .lineLimit(1)
.padding([.leading, .trailing]) .padding(.leading)
.padding(.trailing, 100)
} }
} }
.frame(height: metrics.size.height * 0.5) .frame(height: metrics.size.height * 0.5)

View File

@@ -2,9 +2,15 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>com.apple.security.app-sandbox</key> <key>com.apple.developer.healthkit</key>
<true/> <true/>
<key>com.apple.security.files.user-selected.read-only</key> <key>com.apple.developer.healthkit.access</key>
<true/> <array/>
<key>com.apple.developer.healthkit.background-delivery</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict> </dict>
</plist> </plist>

BIN
Werkout_ios/long_beep.m4a Normal file

Binary file not shown.

BIN
Werkout_ios/short_beep.m4a Normal file

Binary file not shown.

View File

@@ -6,5 +6,7 @@
<true/> <true/>
<key>com.apple.developer.healthkit.access</key> <key>com.apple.developer.healthkit.access</key>
<array/> <array/>
<key>com.apple.developer.healthkit.background-delivery</key>
<true/>
</dict> </dict>
</plist> </plist>