diff --git a/Werkout_ios/Views/AccountView/AccountView.swift b/Werkout_ios/Views/AccountView/AccountView.swift index c43ab20..413067c 100644 --- a/Werkout_ios/Views/AccountView/AccountView.swift +++ b/Werkout_ios/Views/AccountView/AccountView.swift @@ -12,7 +12,8 @@ struct AccountView: View { @State var completedWorkouts: [CompletedWorkout]? @ObservedObject var userStore = UserStore.shared @State var showCompletedWorkouts: Bool = false - @AppStorage("thotStyle") private var thotStyle: ThotStyle = .never + @AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never + @AppStorage(Constants.extThotStyle) private var extThotStyle: ThotStyle = .never var body: some View { VStack(alignment: .leading) { @@ -62,11 +63,22 @@ struct AccountView: View { } } Divider() - - Picker("THOT Style:", selection: $thotStyle) { + Text("Phone THOT Style:") + Picker("Phone THOT Style:", selection: $phoneThotStyle) { ForEach(ThotStyle.allCases, id: \.self) { style in Text(style.stringValue()) - .tag(thotStyle.rawValue) + .tag(phoneThotStyle.rawValue) + } + } + .pickerStyle(.segmented) + + Divider() + + Text("External THOT Style:") + Picker("External THOT Style:", selection: $extThotStyle) { + ForEach(ThotStyle.allCases, id: \.self) { style in + Text(style.stringValue()) + .tag(extThotStyle.rawValue) } } .pickerStyle(.segmented) diff --git a/Werkout_ios/Views/CreateWorkout/CreateExerciseActionsView.swift b/Werkout_ios/Views/CreateWorkout/CreateExerciseActionsView.swift index 19adf8e..e155259 100644 --- a/Werkout_ios/Views/CreateWorkout/CreateExerciseActionsView.swift +++ b/Werkout_ios/Views/CreateWorkout/CreateExerciseActionsView.swift @@ -19,6 +19,8 @@ struct CreateExerciseActionsView: View { VStack { Text("Reps: ") Text("\(workoutExercise.reps)") + .foregroundColor(workoutExercise.reps == 0 && workoutExercise.duration == 0 ? .red : Color(uiColor: .label)) + .bold() } Stepper("", onIncrement: { workoutExercise.increaseReps() @@ -51,6 +53,8 @@ struct CreateExerciseActionsView: View { VStack { Text("Duration: ") Text("\(workoutExercise.duration)") + .foregroundColor(workoutExercise.reps == 0 && workoutExercise.duration == 0 ? .red : Color(uiColor: .label)) + .bold() } Stepper("", onIncrement: { workoutExercise.increaseDuration() diff --git a/Werkout_ios/Views/CreateWorkout/CreateViewModels.swift b/Werkout_ios/Views/CreateWorkout/CreateViewModels.swift index 1c39e26..0e6e62e 100644 --- a/Werkout_ios/Views/CreateWorkout/CreateViewModels.swift +++ b/Werkout_ios/Views/CreateWorkout/CreateViewModels.swift @@ -107,32 +107,42 @@ class WorkoutViewModel: ObservableObject { } func uploadWorkout() { - var exercises = [[String: Any]]() + var supersets = [[String: Any]]() + var supersetOrder = 1 superSets.forEach({ superset in if superset.numberOfRounds == 0 { showRoundsError() return } + var supersetInfo = [String: Any]() + supersetInfo["name"] = "" + supersetInfo["rounds"] = superset.numberOfRounds + supersetInfo["order"] = supersetOrder - for _ in 0 ..< superset.numberOfRounds { - for exercise in superset.exercises { - - if exercise.reps == 0 && exercise.duration == 0 { - showNoDurationOrReps() - return - } - - let item = ["id": exercise.exercise.id, - "reps": exercise.reps, - "weight": exercise.weight, - "duration": exercise.duration] as [String : Any] - exercises.append(item) + var exercises = [[String: Any]]() + var exerciseOrder = 1 + for exercise in superset.exercises { + if exercise.reps == 0 && exercise.duration == 0 { + showNoDurationOrReps() + return } + + let item = ["id": exercise.exercise.id, + "reps": exercise.reps, + "weight": exercise.weight, + "duration": exercise.duration, + "order": exerciseOrder] as [String : Any] + exercises.append(item) + exerciseOrder += 1 } + supersetInfo["exercises"] = exercises + + supersets.append(supersetInfo) + supersetOrder += 1 }) let uploadBody = ["name": title, "description": description, - "exercise_data": exercises] as [String : Any] + "supersets": supersets] as [String : Any] CreateWorkoutFetchable(postData: uploadBody).fetch(completion: { result in DispatchQueue.main.async { switch result { diff --git a/Werkout_ios/Views/CreateWorkout/CreateWorkoutMainView.swift b/Werkout_ios/Views/CreateWorkout/CreateWorkoutMainView.swift index 96009d1..e3d9204 100644 --- a/Werkout_ios/Views/CreateWorkout/CreateWorkoutMainView.swift +++ b/Werkout_ios/Views/CreateWorkout/CreateWorkoutMainView.swift @@ -47,7 +47,6 @@ struct CreateWorkoutMainView: View { } } - HStack { Stepper("Number of rounds", onIncrement: { superset.wrappedValue.increaseNumberOfRounds() @@ -58,6 +57,7 @@ struct CreateWorkoutMainView: View { }) Text("\(superset.wrappedValue.numberOfRounds)") .foregroundColor(superset.numberOfRounds.wrappedValue > 0 ? .black : .red) + .bold() } CreateWorkoutSupersetActionsView(workoutSuperSet: superset.wrappedValue, @@ -111,6 +111,32 @@ struct CreateWorkoutMainView: View { AddExerciseView(selectedExercise: { exercise in let workoutExercise = CreateWorkoutExercise(exercise: exercise) selectedCreateWorkoutSuperSet?.exercises.append(workoutExercise) + + + // if left or right auto add the other side + // with a recover in between b/c its + // eaiser to delete a recover than add one + if exercise.side.count > 0 { + let exercises = DataStore.shared.allExercise?.filter({ + $0.name == exercise.name + }) + let recover = DataStore.shared.allExercise?.first(where: { + $0.name.lowercased() == "recover" + }) + if let exercises = exercises, let recover = recover { + if exercises.count == 2 { + let recoverWorkoutExercise = CreateWorkoutExercise(exercise: recover) + selectedCreateWorkoutSuperSet?.exercises.append(recoverWorkoutExercise) + for LRExercise in exercises { + if LRExercise.id != exercise.id { + let otherSideExercise = CreateWorkoutExercise(exercise: LRExercise) + selectedCreateWorkoutSuperSet?.exercises.append(otherSideExercise) + } + } + } + } + } + viewModel.objectWillChange.send() selectedCreateWorkoutSuperSet = nil }) diff --git a/Werkout_ios/Views/ExternalWorkoutDetailView.swift b/Werkout_ios/Views/ExternalWorkoutDetailView.swift index 72a8251..9900b5e 100644 --- a/Werkout_ios/Views/ExternalWorkoutDetailView.swift +++ b/Werkout_ios/Views/ExternalWorkoutDetailView.swift @@ -11,7 +11,7 @@ import AVKit struct ExternalWorkoutDetailView: View { @StateObject var bridgeModule = BridgeModule.shared @State var avPlayer = AVPlayer(url: URL(string: "https://dev.werkout.fitness/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4")!) - @AppStorage("thotStyle") private var thotStyle: ThotStyle = .never + @AppStorage(Constants.extThotStyle) private var extThotStyle: ThotStyle = .never var body: some View { ZStack { @@ -57,7 +57,7 @@ struct ExternalWorkoutDetailView: View { .onChange(of: bridgeModule.currentExerciseInfo.exerciseIndex, perform: { newValue in if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise { if let videoURL = VideoURLCreator.videoURL( - thotStyle: thotStyle, + thotStyle: extThotStyle, defaultVideoURLStr: currentExtercise.exercise.videoURL, exerciseName: currentExtercise.exercise.name, workout: bridgeModule.currentExerciseInfo.workout) { diff --git a/Werkout_ios/Views/WorkoutDetail/ExerciseListView.swift b/Werkout_ios/Views/WorkoutDetail/ExerciseListView.swift index 43e2b66..11d007c 100644 --- a/Werkout_ios/Views/WorkoutDetail/ExerciseListView.swift +++ b/Werkout_ios/Views/WorkoutDetail/ExerciseListView.swift @@ -9,7 +9,7 @@ import SwiftUI import AVKit struct ExerciseListView: View { - @AppStorage("thotStyle") private var thotStyle: ThotStyle = .never + @AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never @ObservedObject var bridgeModule = BridgeModule.shared @State var avPlayer = AVPlayer(url: URL(string: "https://dev.werkout.fitness/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4")!) var workout: Workout @@ -17,7 +17,7 @@ struct ExerciseListView: View { @State var videoExercise: Exercise? { didSet { if let videoURL = VideoURLCreator.videoURL( - thotStyle: thotStyle, + thotStyle: phoneThotStyle, defaultVideoURLStr: self.videoExercise?.videoURL, exerciseName: self.videoExercise?.name, workout: bridgeModule.currentExerciseInfo.workout) { diff --git a/Werkout_ios/Views/WorkoutDetail/WorkoutDetailView.swift b/Werkout_ios/Views/WorkoutDetail/WorkoutDetailView.swift index 798bb66..6fa66b6 100644 --- a/Werkout_ios/Views/WorkoutDetail/WorkoutDetailView.swift +++ b/Werkout_ios/Views/WorkoutDetail/WorkoutDetailView.swift @@ -14,7 +14,7 @@ struct WorkoutDetailView: View { @StateObject var bridgeModule = BridgeModule.shared @Environment(\.dismiss) var dismiss - @AppStorage("thotStyle") private var thotStyle: ThotStyle = .never + @AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never enum Sheet: Identifiable { case completedWorkout([String: Any]) @@ -103,7 +103,7 @@ struct WorkoutDetailView: View { .onChange(of: bridgeModule.currentExerciseInfo.exerciseIndex, perform: { newValue in if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise { if let videoURL = VideoURLCreator.videoURL( - thotStyle: thotStyle, + thotStyle: phoneThotStyle, defaultVideoURLStr: currentExtercise.exercise.videoURL, exerciseName: currentExtercise.exercise.name, workout: bridgeModule.currentExerciseInfo.workout) { @@ -115,7 +115,7 @@ struct WorkoutDetailView: View { .onAppear{ if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise { if let videoURL = VideoURLCreator.videoURL( - thotStyle: thotStyle, + thotStyle: phoneThotStyle, defaultVideoURLStr: currentExtercise.exercise.videoURL, exerciseName: currentExtercise.exercise.name, workout: bridgeModule.currentExerciseInfo.workout) { diff --git a/Werkout_ios/Werkout_iosApp.swift b/Werkout_ios/Werkout_iosApp.swift index e48f9df..74e4760 100644 --- a/Werkout_ios/Werkout_iosApp.swift +++ b/Werkout_ios/Werkout_iosApp.swift @@ -9,6 +9,12 @@ import SwiftUI import Combine import AVKit + +struct Constants { + static let phoneThotStyle = "phoneThotStyle" + static let extThotStyle = "extThotStyle" +} + @main struct Werkout_iosApp: App { let persistenceController = PersistenceController.shared