Stabilize iOS/watchOS/tvOS apps and add cross-platform audit remediation
This commit is contained in:
@@ -10,15 +10,16 @@ import AVFoundation
|
||||
|
||||
struct CreateExerciseActionsView: View {
|
||||
@ObservedObject var workoutExercise: CreateWorkoutExercise
|
||||
var superset: CreateWorkoutSuperSet
|
||||
@ObservedObject var superset: CreateWorkoutSuperSet
|
||||
var viewModel: WorkoutViewModel
|
||||
|
||||
@State var avPlayer = AVPlayer(url: URL(string: "https://dev.werkout.fitness/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4")!)
|
||||
@State var avPlayer = AVPlayer(url: URL(string: "https://dev.werkout.fitness/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4") ?? URL(fileURLWithPath: "/dev/null"))
|
||||
@State private var currentVideoURL: URL?
|
||||
@State var videoExercise: Exercise? {
|
||||
didSet {
|
||||
if let viddd = self.videoExercise?.videoURL,
|
||||
let url = URL(string: BaseURLs.currentBaseURL + viddd) {
|
||||
self.avPlayer = AVPlayer(url: url)
|
||||
updatePlayer(for: url)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,6 +38,7 @@ struct CreateExerciseActionsView: View {
|
||||
}, onDecrement: {
|
||||
workoutExercise.decreaseReps()
|
||||
})
|
||||
.accessibilityLabel("Reps")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +51,7 @@ struct CreateExerciseActionsView: View {
|
||||
}, onDecrement: {
|
||||
workoutExercise.decreaseWeight()
|
||||
})
|
||||
.accessibilityLabel("Weight")
|
||||
}
|
||||
|
||||
HStack {
|
||||
@@ -66,6 +69,7 @@ struct CreateExerciseActionsView: View {
|
||||
}, onDecrement: {
|
||||
workoutExercise.decreaseDuration()
|
||||
})
|
||||
.accessibilityLabel("Duration")
|
||||
}
|
||||
|
||||
HStack {
|
||||
@@ -80,6 +84,8 @@ struct CreateExerciseActionsView: View {
|
||||
.background(.blue)
|
||||
.cornerRadius(Constants.buttonRadius)
|
||||
.buttonStyle(BorderlessButtonStyle())
|
||||
.accessibilityLabel("Preview exercise video")
|
||||
.accessibilityHint("Opens a video preview for this exercise")
|
||||
|
||||
Spacer()
|
||||
|
||||
@@ -89,7 +95,6 @@ struct CreateExerciseActionsView: View {
|
||||
superset
|
||||
.deleteExerciseForChosenSuperset(exercise: workoutExercise)
|
||||
viewModel.increaseRandomNumberForUpdating()
|
||||
viewModel.objectWillChange.send()
|
||||
}) {
|
||||
Image(systemName: "trash.fill")
|
||||
}
|
||||
@@ -98,6 +103,8 @@ struct CreateExerciseActionsView: View {
|
||||
.background(.red)
|
||||
.cornerRadius(Constants.buttonRadius)
|
||||
.buttonStyle(BorderlessButtonStyle())
|
||||
.accessibilityLabel("Delete exercise")
|
||||
.accessibilityHint("Removes this exercise from the superset")
|
||||
|
||||
Spacer()
|
||||
}
|
||||
@@ -109,6 +116,23 @@ struct CreateExerciseActionsView: View {
|
||||
avPlayer.play()
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
avPlayer.pause()
|
||||
}
|
||||
}
|
||||
|
||||
private func updatePlayer(for url: URL) {
|
||||
if currentVideoURL == url {
|
||||
avPlayer.seek(to: .zero)
|
||||
avPlayer.isMuted = true
|
||||
avPlayer.play()
|
||||
return
|
||||
}
|
||||
|
||||
currentVideoURL = url
|
||||
avPlayer = AVPlayer(url: url)
|
||||
avPlayer.isMuted = true
|
||||
avPlayer.play()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user