WIP
This commit is contained in:
@@ -17,9 +17,11 @@ struct Workout: Codable, Identifiable, Equatable {
|
|||||||
let description: String?
|
let description: String?
|
||||||
let exercises: [ExerciseElement]
|
let exercises: [ExerciseElement]
|
||||||
let registeredUser: RegisteredUser?
|
let registeredUser: RegisteredUser?
|
||||||
|
let muscles: [String]?
|
||||||
|
let equipment: [String]?
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case name, description, exercises, id
|
case name, description, exercises, id, muscles, equipment
|
||||||
case registeredUser = "registered_user"
|
case registeredUser = "registered_user"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +37,8 @@ struct Workout: Codable, Identifiable, Equatable {
|
|||||||
self.description = try container.decodeIfPresent(String.self, forKey: .description)
|
self.description = try container.decodeIfPresent(String.self, forKey: .description)
|
||||||
self.registeredUser = try container.decodeIfPresent(RegisteredUser.self, forKey: .registeredUser)
|
self.registeredUser = try container.decodeIfPresent(RegisteredUser.self, forKey: .registeredUser)
|
||||||
self.id = try container.decode(Int.self, forKey: .id)
|
self.id = try container.decode(Int.self, forKey: .id)
|
||||||
|
self.muscles = try container.decodeIfPresent([String].self, forKey: .muscles)
|
||||||
|
self.equipment = try container.decodeIfPresent([String].self, forKey: .equipment)
|
||||||
}
|
}
|
||||||
|
|
||||||
var exercisesSortedByCreated_at: [ExerciseElement] {
|
var exercisesSortedByCreated_at: [ExerciseElement] {
|
||||||
|
|||||||
@@ -1,182 +1,162 @@
|
|||||||
{
|
{
|
||||||
"id": 20,
|
"id": 1,
|
||||||
"name": "Adsfadfafa",
|
"name": "test workout",
|
||||||
"description": "description",
|
"description": null,
|
||||||
"exercises": [
|
"exercises": [
|
||||||
{
|
{
|
||||||
"workout": 20,
|
"workout": 1,
|
||||||
"exercise": {
|
"exercise": {
|
||||||
"id": 992,
|
"id": 1080,
|
||||||
"muscles": [
|
"muscles": [
|
||||||
{
|
{
|
||||||
"id": 7270,
|
"id": 7267,
|
||||||
"created_at": "2023-06-14T17:05:39.769351Z",
|
"created_at": "2023-06-28T04:04:39.263974Z",
|
||||||
"updated_at": "2023-06-14T17:05:39.769758Z",
|
"updated_at": "2023-06-28T04:04:39.263986Z",
|
||||||
"exercise": 992,
|
"exercise": 1080,
|
||||||
"muscle": 6
|
"muscle": 4
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 7271,
|
"id": 7266,
|
||||||
"created_at": "2023-06-14T17:05:39.770480Z",
|
"created_at": "2023-06-28T04:04:39.268881Z",
|
||||||
"updated_at": "2023-06-14T17:05:39.771111Z",
|
"updated_at": "2023-06-28T04:04:39.268893Z",
|
||||||
"exercise": 992,
|
"exercise": 1080,
|
||||||
"muscle": 4
|
"muscle": 5
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"equipment": [
|
"equipment": [
|
||||||
{
|
{
|
||||||
"id": 944,
|
"id": 942,
|
||||||
"created_at": "2023-06-13T02:28:04.294180Z",
|
"created_at": "2023-06-28T14:18:59.650301Z",
|
||||||
"updated_at": "2023-06-13T02:28:04.294658Z",
|
"updated_at": "2023-06-28T14:18:59.650313Z",
|
||||||
"exercise": 992,
|
"exercise": 1080,
|
||||||
"equipment": 1091
|
"equipment": 1091
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"audio_url": "/media/exercise_audio/2_Dumbbell_Single-Leg_Deadlift.m4a",
|
"audio_url": "/media/exercise_audio/2_Dumbbell_Lateral_Lunges.m4a",
|
||||||
"video_url": "/media/exercise_videos/2_Dumbbell_Single-Leg_Deadlift.mp4",
|
"video_url": "/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4",
|
||||||
"created_at": "2023-06-11T22:50:19.197099Z",
|
"nsfw_video_url": "/media/nsfw_exercise_videos/2_Dumbbell_Lateral_Lunges.mp4",
|
||||||
"updated_at": "2023-06-11T22:50:19.197105Z",
|
"created_at": "2023-06-26T20:52:33.576028Z",
|
||||||
"name": "2 Dumbbell Single-Leg Deadlift",
|
"updated_at": "2023-06-26T20:52:33.576040Z",
|
||||||
"description": "Holding a dumbbell in each hand, with your right leg on the ground, hinge at your hips and let your body see-saw down until you are parallel with the ground. Snap back to a standing position.",
|
"name": "2 Dumbbell Lateral Lunges",
|
||||||
"side": "right_leg",
|
"description": "With dumbbells by your sides, step out to the side.. Reach your hips back like you're sitting in a chair.. Drive back up to the starting position, and repeat on the other side.",
|
||||||
|
"side": "",
|
||||||
"is_two_dumbbells": true,
|
"is_two_dumbbells": true,
|
||||||
"is_trackable_distance": false,
|
"is_trackable_distance": false,
|
||||||
|
"is_alternating": true,
|
||||||
|
"is_weight": true,
|
||||||
|
"is_distance": false,
|
||||||
|
"is_duration": true,
|
||||||
|
"is_reps": true,
|
||||||
|
"joints_used": "ankle,hip,knee,lumbar spine,wrist",
|
||||||
|
"movement_patterns": "lower push,lower push - lunge",
|
||||||
|
"equipment_required": "Dumbbell",
|
||||||
|
"muscle_groups": "quads,glutes",
|
||||||
|
"synonyms": ""
|
||||||
|
},
|
||||||
|
"weight": null,
|
||||||
|
"reps": null,
|
||||||
|
"duration": null,
|
||||||
|
"duration_audio": null,
|
||||||
|
"weight_audio": null,
|
||||||
|
"created_at": "2023-06-27T12:18:54.998026Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"workout": 1,
|
||||||
|
"exercise": {
|
||||||
|
"id": 798,
|
||||||
|
"muscles": [],
|
||||||
|
"equipment": [],
|
||||||
|
"audio_url": "/media/exercise_audio/Recover.m4a",
|
||||||
|
"video_url": "/media/exercise_videos/Recover.mp4",
|
||||||
|
"nsfw_video_url": "/media/nsfw_exercise_videos/Recover_5.mp4",
|
||||||
|
"created_at": "2023-06-26T20:52:36.446337Z",
|
||||||
|
"updated_at": "2023-06-26T20:52:36.446348Z",
|
||||||
|
"name": "Recover",
|
||||||
|
"description": "Use this time to catch your breath. It will help you get more out of what's next",
|
||||||
|
"side": "",
|
||||||
|
"is_two_dumbbells": false,
|
||||||
|
"is_trackable_distance": false,
|
||||||
|
"is_alternating": false,
|
||||||
|
"is_weight": false,
|
||||||
|
"is_distance": false,
|
||||||
|
"is_duration": true,
|
||||||
|
"is_reps": false,
|
||||||
|
"joints_used": "",
|
||||||
|
"movement_patterns": "",
|
||||||
|
"equipment_required": "",
|
||||||
|
"muscle_groups": "",
|
||||||
|
"synonyms": ""
|
||||||
|
},
|
||||||
|
"weight": null,
|
||||||
|
"reps": null,
|
||||||
|
"duration": null,
|
||||||
|
"duration_audio": null,
|
||||||
|
"weight_audio": null,
|
||||||
|
"created_at": "2023-06-27T12:18:54.999424Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"workout": 1,
|
||||||
|
"exercise": {
|
||||||
|
"id": 130,
|
||||||
|
"muscles": [
|
||||||
|
{
|
||||||
|
"id": 7282,
|
||||||
|
"created_at": "2023-06-28T04:04:39.194997Z",
|
||||||
|
"updated_at": "2023-06-28T04:04:39.195009Z",
|
||||||
|
"exercise": 130,
|
||||||
|
"muscle": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 7281,
|
||||||
|
"created_at": "2023-06-28T04:04:39.199685Z",
|
||||||
|
"updated_at": "2023-06-28T04:04:39.199697Z",
|
||||||
|
"exercise": 130,
|
||||||
|
"muscle": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"equipment": [
|
||||||
|
{
|
||||||
|
"id": 948,
|
||||||
|
"created_at": "2023-06-28T14:18:59.622982Z",
|
||||||
|
"updated_at": "2023-06-28T14:18:59.622994Z",
|
||||||
|
"exercise": 130,
|
||||||
|
"equipment": 1088
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"audio_url": "/media/exercise_audio/2_Kettlebell_Push_Press.m4a",
|
||||||
|
"video_url": "/media/exercise_videos/2_Kettlebell_Push_Press.mp4",
|
||||||
|
"nsfw_video_url": "/media/nsfw_exercise_videos/2_Kettlebell_Push_Press.mp4",
|
||||||
|
"created_at": "2023-06-26T20:52:33.599643Z",
|
||||||
|
"updated_at": "2023-06-26T20:52:33.599655Z",
|
||||||
|
"name": "2 Kettlebell Push Press",
|
||||||
|
"description": "Stand with feet in a shoulder width stance and kettlebells in the front rack position. \nDip quickly at the knees into a quarter squat and then explode straight up as you press the kettlebells overhead.\nLower the kettlebells under control back to the starting position",
|
||||||
|
"side": "",
|
||||||
|
"is_two_dumbbells": false,
|
||||||
|
"is_trackable_distance": false,
|
||||||
"is_alternating": false,
|
"is_alternating": false,
|
||||||
"is_weight": true,
|
"is_weight": true,
|
||||||
"is_distance": false,
|
"is_distance": false,
|
||||||
"is_duration": true,
|
"is_duration": true,
|
||||||
"is_reps": true,
|
"is_reps": true,
|
||||||
"joints_used": "ankle,lumbar spine,hip,knee,wrist",
|
"joints_used": "knee,hip,shoulder,wrist,elbow",
|
||||||
"movement_patterns": "lower pull,lower pull - hip hinge",
|
"movement_patterns": "upper push - vertical,upper push",
|
||||||
"equipment_required": "Dumbbell",
|
"equipment_required": "Kettlebell",
|
||||||
"muscle_groups": "hamstrings,glutes",
|
"muscle_groups": "deltoids,quads",
|
||||||
"synonyms": "2 Dumbbell Single Leg Deadlift"
|
"synonyms": ""
|
||||||
},
|
},
|
||||||
"weight": 10,
|
"weight": null,
|
||||||
"reps": 12,
|
"reps": null,
|
||||||
"duration": null,
|
"duration": null,
|
||||||
"duration_audio": null,
|
"duration_audio": null,
|
||||||
"weight_audio": "/media/quantities_audio/for_10_pounds.m4a",
|
"weight_audio": null,
|
||||||
"created_at": "2023-06-20T20:53:51.251968Z"
|
"created_at": "2023-06-27T12:18:54.999935Z"
|
||||||
},
|
|
||||||
{
|
|
||||||
"workout": 20,
|
|
||||||
"exercise": {
|
|
||||||
"id": 992,
|
|
||||||
"muscles": [
|
|
||||||
{
|
|
||||||
"id": 7270,
|
|
||||||
"created_at": "2023-06-14T17:05:39.769351Z",
|
|
||||||
"updated_at": "2023-06-14T17:05:39.769758Z",
|
|
||||||
"exercise": 992,
|
|
||||||
"muscle": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 7271,
|
|
||||||
"created_at": "2023-06-14T17:05:39.770480Z",
|
|
||||||
"updated_at": "2023-06-14T17:05:39.771111Z",
|
|
||||||
"exercise": 992,
|
|
||||||
"muscle": 4
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"equipment": [
|
|
||||||
{
|
|
||||||
"id": 944,
|
|
||||||
"created_at": "2023-06-13T02:28:04.294180Z",
|
|
||||||
"updated_at": "2023-06-13T02:28:04.294658Z",
|
|
||||||
"exercise": 992,
|
|
||||||
"equipment": 1091
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"audio_url": "/media/exercise_audio/2_Dumbbell_Single-Leg_Deadlift.m4a",
|
|
||||||
"video_url": "/media/exercise_videos/2_Dumbbell_Single-Leg_Deadlift.mp4",
|
|
||||||
"created_at": "2023-06-11T22:50:19.197099Z",
|
|
||||||
"updated_at": "2023-06-11T22:50:19.197105Z",
|
|
||||||
"name": "2 Dumbbell Single-Leg Deadlift",
|
|
||||||
"description": "Holding a dumbbell in each hand, with your right leg on the ground, hinge at your hips and let your body see-saw down until you are parallel with the ground. Snap back to a standing position.",
|
|
||||||
"side": "right_leg",
|
|
||||||
"is_two_dumbbells": true,
|
|
||||||
"is_trackable_distance": false,
|
|
||||||
"is_alternating": false,
|
|
||||||
"is_weight": true,
|
|
||||||
"is_distance": false,
|
|
||||||
"is_duration": true,
|
|
||||||
"is_reps": true,
|
|
||||||
"joints_used": "ankle,lumbar spine,hip,knee,wrist",
|
|
||||||
"movement_patterns": "lower pull,lower pull - hip hinge",
|
|
||||||
"equipment_required": "Dumbbell",
|
|
||||||
"muscle_groups": "hamstrings,glutes",
|
|
||||||
"synonyms": "2 Dumbbell Single Leg Deadlift"
|
|
||||||
},
|
|
||||||
"weight": 10,
|
|
||||||
"reps": 12,
|
|
||||||
"duration": null,
|
|
||||||
"duration_audio": null,
|
|
||||||
"weight_audio": "/media/quantities_audio/for_10_pounds.m4a",
|
|
||||||
"created_at": "2023-06-20T20:53:51.254113Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"workout": 20,
|
|
||||||
"exercise": {
|
|
||||||
"id": 992,
|
|
||||||
"muscles": [
|
|
||||||
{
|
|
||||||
"id": 7270,
|
|
||||||
"created_at": "2023-06-14T17:05:39.769351Z",
|
|
||||||
"updated_at": "2023-06-14T17:05:39.769758Z",
|
|
||||||
"exercise": 992,
|
|
||||||
"muscle": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 7271,
|
|
||||||
"created_at": "2023-06-14T17:05:39.770480Z",
|
|
||||||
"updated_at": "2023-06-14T17:05:39.771111Z",
|
|
||||||
"exercise": 992,
|
|
||||||
"muscle": 4
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"equipment": [
|
|
||||||
{
|
|
||||||
"id": 944,
|
|
||||||
"created_at": "2023-06-13T02:28:04.294180Z",
|
|
||||||
"updated_at": "2023-06-13T02:28:04.294658Z",
|
|
||||||
"exercise": 992,
|
|
||||||
"equipment": 1091
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"audio_url": "/media/exercise_audio/2_Dumbbell_Single-Leg_Deadlift.m4a",
|
|
||||||
"video_url": "/media/exercise_videos/2_Dumbbell_Single-Leg_Deadlift.mp4",
|
|
||||||
"created_at": "2023-06-11T22:50:19.197099Z",
|
|
||||||
"updated_at": "2023-06-11T22:50:19.197105Z",
|
|
||||||
"name": "2 Dumbbell Single-Leg Deadlift",
|
|
||||||
"description": "Holding a dumbbell in each hand, with your right leg on the ground, hinge at your hips and let your body see-saw down until you are parallel with the ground. Snap back to a standing position.",
|
|
||||||
"side": "right_leg",
|
|
||||||
"is_two_dumbbells": true,
|
|
||||||
"is_trackable_distance": false,
|
|
||||||
"is_alternating": false,
|
|
||||||
"is_weight": true,
|
|
||||||
"is_distance": false,
|
|
||||||
"is_duration": true,
|
|
||||||
"is_reps": true,
|
|
||||||
"joints_used": "ankle,lumbar spine,hip,knee,wrist",
|
|
||||||
"movement_patterns": "lower pull,lower pull - hip hinge",
|
|
||||||
"equipment_required": "Dumbbell",
|
|
||||||
"muscle_groups": "hamstrings,glutes",
|
|
||||||
"synonyms": "2 Dumbbell Single Leg Deadlift"
|
|
||||||
},
|
|
||||||
"weight": 10,
|
|
||||||
"reps": 12,
|
|
||||||
"duration": null,
|
|
||||||
"duration_audio": null,
|
|
||||||
"weight_audio": "/media/quantities_audio/for_10_pounds.m4a",
|
|
||||||
"created_at": "2023-06-20T20:53:51.255969Z"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"registered_user": {
|
"registered_user": {
|
||||||
"id": 2,
|
"id": 1,
|
||||||
"first_name": "test2_first",
|
"first_name": "User1",
|
||||||
"last_name": "test2_last",
|
"last_name": "user1",
|
||||||
"image": "",
|
"image": "",
|
||||||
"nick_name": null
|
"nick_name": "test user1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,10 @@ struct AllWorkoutsView: View {
|
|||||||
|
|
||||||
switch selectedSegment {
|
switch selectedSegment {
|
||||||
case .AllWorkout:
|
case .AllWorkout:
|
||||||
allWorkoutView(workouts: workouts)
|
AllWorkoutsListView(workouts: workouts, selectedWorkout: { workout in
|
||||||
|
selectedWorkout = workout
|
||||||
|
})
|
||||||
|
Divider()
|
||||||
case .MyWorkouts:
|
case .MyWorkouts:
|
||||||
plannedWorkout(workouts: UserStore.shared.plannedWorkouts)
|
plannedWorkout(workouts: UserStore.shared.plannedWorkouts)
|
||||||
}
|
}
|
||||||
@@ -101,24 +104,6 @@ struct AllWorkoutsView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func allWorkoutView(workouts: [Workout]) -> some View {
|
|
||||||
List {
|
|
||||||
ForEach(workouts, id:\.name) { workout in
|
|
||||||
VStack {
|
|
||||||
Text(workout.name)
|
|
||||||
.font(.title2)
|
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
|
||||||
Text(workout.description ?? "")
|
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
|
||||||
}
|
|
||||||
.contentShape(Rectangle())
|
|
||||||
.onTapGesture {
|
|
||||||
selectedWorkout = workout
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func plannedWorkout(workouts: [PlannedWorkout]) -> some View {
|
func plannedWorkout(workouts: [PlannedWorkout]) -> some View {
|
||||||
List {
|
List {
|
||||||
ForEach(workouts, id:\.workout.name) { plannedWorkout in
|
ForEach(workouts, id:\.workout.name) { plannedWorkout in
|
||||||
@@ -185,6 +170,75 @@ struct AllWorkoutsView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct AllWorkoutsListView: View {
|
||||||
|
@State var searchString: String = ""
|
||||||
|
let workouts: [Workout]
|
||||||
|
|
||||||
|
let selectedWorkout: ((Workout) -> Void)
|
||||||
|
|
||||||
|
var filteredWorkouts: [Workout] {
|
||||||
|
if !searchString.isEmpty, searchString.count > 0 {
|
||||||
|
return workouts.filter({
|
||||||
|
if $0.name.lowercased().contains(searchString.lowercased()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if let equipment = $0.equipment?.joined(separator: "").lowercased(),
|
||||||
|
equipment.contains(searchString.lowercased()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if let muscles = $0.muscles?.joined(separator: "").lowercased(),
|
||||||
|
muscles.contains(searchString.lowercased()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return workouts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
List {
|
||||||
|
ForEach(filteredWorkouts, id:\.name) { workout in
|
||||||
|
Section {
|
||||||
|
VStack {
|
||||||
|
Text(workout.name)
|
||||||
|
.font(.title2)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
Text(workout.description ?? "")
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
|
||||||
|
if let muscles = workout.muscles,
|
||||||
|
muscles.joined(separator: ", ").count > 0{
|
||||||
|
Divider()
|
||||||
|
Text(muscles.joined(separator: ", "))
|
||||||
|
.font(.footnote)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
|
|
||||||
|
if let equipment = workout.equipment,
|
||||||
|
equipment.joined(separator: ", ").count > 0 {
|
||||||
|
Divider()
|
||||||
|
Text(equipment.joined(separator: ", "))
|
||||||
|
.font(.footnote)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.contentShape(Rectangle())
|
||||||
|
.onTapGesture {
|
||||||
|
selectedWorkout(workout)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TextField("Filter", text: $searchString)
|
||||||
|
.padding(.leading)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct AllWorkoutsView_Previews: PreviewProvider {
|
struct AllWorkoutsView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
AllWorkoutsView(workouts: PreviewData.allWorkouts())
|
AllWorkoutsView(workouts: PreviewData.allWorkouts())
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ struct PlanWorkoutView: View {
|
|||||||
.foregroundColor(Color.accentColor)
|
.foregroundColor(Color.accentColor)
|
||||||
.padding()
|
.padding()
|
||||||
.animation(.spring(), value: selectedDate)
|
.animation(.spring(), value: selectedDate)
|
||||||
.frame(width: 500)
|
|
||||||
|
|
||||||
Divider().frame(height: 1)
|
Divider().frame(height: 1)
|
||||||
|
|
||||||
|
|||||||
@@ -243,9 +243,25 @@ struct CurrentWorkoutElapsedTimeView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ExerciseListView: View {
|
struct ExerciseListView: View {
|
||||||
|
@AppStorage("showNSFWVideos") private var showNSFWVideos = false
|
||||||
@ObservedObject var bridgeModule = BridgeModule.shared
|
@ObservedObject var bridgeModule = BridgeModule.shared
|
||||||
var workout: Workout
|
var workout: Workout
|
||||||
|
@State var avPlayer = AVPlayer(url: URL(string: "https://dev.werkout.fitness/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4")!)
|
||||||
|
@State var videoExercise: ExerciseExercise? {
|
||||||
|
didSet {
|
||||||
|
if showNSFWVideos {
|
||||||
|
if let viddd = self.videoExercise?.nsfwVideoURL,
|
||||||
|
let url = URL(string: BaseURLs.currentBaseURL + viddd) {
|
||||||
|
avPlayer = AVPlayer(url: url)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if let viddd = self.videoExercise?.videoURL,
|
||||||
|
let url = URL(string: BaseURLs.currentBaseURL + viddd) {
|
||||||
|
avPlayer = AVPlayer(url: url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List() {
|
List() {
|
||||||
@@ -259,12 +275,17 @@ struct ExerciseListView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Text(obj.exercise.name)
|
Text(obj.exercise.name)
|
||||||
.onTapGesture {
|
|
||||||
bridgeModule.goToExerciseAt(index: i)
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
|
.contentShape(Rectangle())
|
||||||
|
.onTapGesture {
|
||||||
|
if bridgeModule.isInWorkout {
|
||||||
|
bridgeModule.goToExerciseAt(index: i)
|
||||||
|
} else {
|
||||||
|
videoExercise = obj.exercise
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if i == bridgeModule.currentExerciseIdx {
|
if i == bridgeModule.currentExerciseIdx {
|
||||||
HStack {
|
HStack {
|
||||||
if obj.exercise.isReps {
|
if obj.exercise.isReps {
|
||||||
@@ -284,6 +305,9 @@ struct ExerciseListView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.sheet(item: $videoExercise) { exercise in
|
||||||
|
VideoPlayerView(avPlayer: $avPlayer)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user