WIP
This commit is contained in:
@@ -32,7 +32,10 @@
|
|||||||
1CF65A652A3BF6BE0042FFBD /* AllWorkouts.json in Resources */ = {isa = PBXBuildFile; fileRef = 1CF65A642A3BF6BE0042FFBD /* AllWorkouts.json */; };
|
1CF65A652A3BF6BE0042FFBD /* AllWorkouts.json in Resources */ = {isa = PBXBuildFile; fileRef = 1CF65A642A3BF6BE0042FFBD /* AllWorkouts.json */; };
|
||||||
1CF65A672A3BFF840042FFBD /* Exercises.json in Resources */ = {isa = PBXBuildFile; fileRef = 1CF65A662A3BFF840042FFBD /* Exercises.json */; };
|
1CF65A672A3BFF840042FFBD /* Exercises.json in Resources */ = {isa = PBXBuildFile; fileRef = 1CF65A662A3BFF840042FFBD /* Exercises.json */; };
|
||||||
1CF65A692A3C018F0042FFBD /* AccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CF65A682A3C018F0042FFBD /* AccountView.swift */; };
|
1CF65A692A3C018F0042FFBD /* AccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CF65A682A3C018F0042FFBD /* AccountView.swift */; };
|
||||||
1CF65A6B2A3C1EAC0042FFBD /* CreateWorkoutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CF65A6A2A3C1EAC0042FFBD /* CreateWorkoutView.swift */; };
|
1CF65A6B2A3C1EAC0042FFBD /* CreateWorkoutMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CF65A6A2A3C1EAC0042FFBD /* CreateWorkoutMainView.swift */; };
|
||||||
|
1CF65A6E2A3F60480042FFBD /* CreateViewModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CF65A6D2A3F60480042FFBD /* CreateViewModels.swift */; };
|
||||||
|
1CF65A732A3F60D20042FFBD /* CreateExerciseActionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CF65A722A3F60D20042FFBD /* CreateExerciseActionsView.swift */; };
|
||||||
|
1CF65A7B2A3F83440042FFBD /* CreateWorkoutSupersetActionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CF65A7A2A3F83440042FFBD /* CreateWorkoutSupersetActionsView.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -64,7 +67,10 @@
|
|||||||
1CF65A642A3BF6BE0042FFBD /* AllWorkouts.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = AllWorkouts.json; sourceTree = "<group>"; };
|
1CF65A642A3BF6BE0042FFBD /* AllWorkouts.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = AllWorkouts.json; sourceTree = "<group>"; };
|
||||||
1CF65A662A3BFF840042FFBD /* Exercises.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = Exercises.json; sourceTree = "<group>"; };
|
1CF65A662A3BFF840042FFBD /* Exercises.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = Exercises.json; sourceTree = "<group>"; };
|
||||||
1CF65A682A3C018F0042FFBD /* AccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountView.swift; sourceTree = "<group>"; };
|
1CF65A682A3C018F0042FFBD /* AccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountView.swift; sourceTree = "<group>"; };
|
||||||
1CF65A6A2A3C1EAC0042FFBD /* CreateWorkoutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateWorkoutView.swift; sourceTree = "<group>"; };
|
1CF65A6A2A3C1EAC0042FFBD /* CreateWorkoutMainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateWorkoutMainView.swift; sourceTree = "<group>"; };
|
||||||
|
1CF65A6D2A3F60480042FFBD /* CreateViewModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateViewModels.swift; sourceTree = "<group>"; };
|
||||||
|
1CF65A722A3F60D20042FFBD /* CreateExerciseActionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateExerciseActionsView.swift; sourceTree = "<group>"; };
|
||||||
|
1CF65A7A2A3F83440042FFBD /* CreateWorkoutSupersetActionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateWorkoutSupersetActionsView.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -103,7 +109,7 @@
|
|||||||
1CF65A272A3972840042FFBD /* Persistence.swift */,
|
1CF65A272A3972840042FFBD /* Persistence.swift */,
|
||||||
1CF65A4F2A3A1EA90042FFBD /* BridgeModule.swift */,
|
1CF65A4F2A3A1EA90042FFBD /* BridgeModule.swift */,
|
||||||
1CF65A3F2A3973840042FFBD /* Views */,
|
1CF65A3F2A3973840042FFBD /* Views */,
|
||||||
1CF65A3E2A39737D0042FFBD /* Models */,
|
1CF65A3E2A39737D0042FFBD /* APIModels */,
|
||||||
1CF65A3D2A3973760042FFBD /* Network */,
|
1CF65A3D2A3973760042FFBD /* Network */,
|
||||||
1CF65A2E2A3972850042FFBD /* Assets.xcassets */,
|
1CF65A2E2A3972850042FFBD /* Assets.xcassets */,
|
||||||
1CF65A302A3972850042FFBD /* Werkout_ios.entitlements */,
|
1CF65A302A3972850042FFBD /* Werkout_ios.entitlements */,
|
||||||
@@ -130,7 +136,7 @@
|
|||||||
path = Network;
|
path = Network;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
1CF65A3E2A39737D0042FFBD /* Models */ = {
|
1CF65A3E2A39737D0042FFBD /* APIModels */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
1CF65A422A39FB410042FFBD /* Workout.swift */,
|
1CF65A422A39FB410042FFBD /* Workout.swift */,
|
||||||
@@ -139,7 +145,7 @@
|
|||||||
1CF65A582A3BF4B60042FFBD /* Muscle.swift */,
|
1CF65A582A3BF4B60042FFBD /* Muscle.swift */,
|
||||||
1CF65A5A2A3BF4BE0042FFBD /* Equipment.swift */,
|
1CF65A5A2A3BF4BE0042FFBD /* Equipment.swift */,
|
||||||
);
|
);
|
||||||
path = Models;
|
path = APIModels;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
1CF65A3F2A3973840042FFBD /* Views */ = {
|
1CF65A3F2A3973840042FFBD /* Views */ = {
|
||||||
@@ -149,7 +155,7 @@
|
|||||||
1CF65A3B2A3972CE0042FFBD /* ExternalWorkoutDetailView.swift */,
|
1CF65A3B2A3972CE0042FFBD /* ExternalWorkoutDetailView.swift */,
|
||||||
1CF65A622A3BF6A30042FFBD /* AllWorkoutsView.swift */,
|
1CF65A622A3BF6A30042FFBD /* AllWorkoutsView.swift */,
|
||||||
1CF65A4B2A39FDA20042FFBD /* WorkoutDetailView.swift */,
|
1CF65A4B2A39FDA20042FFBD /* WorkoutDetailView.swift */,
|
||||||
1CF65A6A2A3C1EAC0042FFBD /* CreateWorkoutView.swift */,
|
1CF65A6C2A3F60100042FFBD /* CreateWorkoutViews */,
|
||||||
1CF65A602A3BF6020042FFBD /* AddExerciseView.swift */,
|
1CF65A602A3BF6020042FFBD /* AddExerciseView.swift */,
|
||||||
1CF65A4D2A39FF200042FFBD /* WorkoutDetailViewModel.swift */,
|
1CF65A4D2A39FF200042FFBD /* WorkoutDetailViewModel.swift */,
|
||||||
1CF65A682A3C018F0042FFBD /* AccountView.swift */,
|
1CF65A682A3C018F0042FFBD /* AccountView.swift */,
|
||||||
@@ -169,6 +175,17 @@
|
|||||||
path = JSON;
|
path = JSON;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
1CF65A6C2A3F60100042FFBD /* CreateWorkoutViews */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
1CF65A6D2A3F60480042FFBD /* CreateViewModels.swift */,
|
||||||
|
1CF65A6A2A3C1EAC0042FFBD /* CreateWorkoutMainView.swift */,
|
||||||
|
1CF65A722A3F60D20042FFBD /* CreateExerciseActionsView.swift */,
|
||||||
|
1CF65A7A2A3F83440042FFBD /* CreateWorkoutSupersetActionsView.swift */,
|
||||||
|
);
|
||||||
|
path = CreateWorkoutViews;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
@@ -245,7 +262,8 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
1CF65A6B2A3C1EAC0042FFBD /* CreateWorkoutView.swift in Sources */,
|
1CF65A6B2A3C1EAC0042FFBD /* CreateWorkoutMainView.swift in Sources */,
|
||||||
|
1CF65A7B2A3F83440042FFBD /* CreateWorkoutSupersetActionsView.swift in Sources */,
|
||||||
1CF65A262A3972840042FFBD /* Werkout_iosApp.swift in Sources */,
|
1CF65A262A3972840042FFBD /* Werkout_iosApp.swift in Sources */,
|
||||||
1CF65A3C2A3972CE0042FFBD /* ExternalWorkoutDetailView.swift in Sources */,
|
1CF65A3C2A3972CE0042FFBD /* ExternalWorkoutDetailView.swift in Sources */,
|
||||||
1CF65A632A3BF6A30042FFBD /* AllWorkoutsView.swift in Sources */,
|
1CF65A632A3BF6A30042FFBD /* AllWorkoutsView.swift in Sources */,
|
||||||
@@ -253,12 +271,14 @@
|
|||||||
1CF65A4E2A39FF200042FFBD /* WorkoutDetailViewModel.swift in Sources */,
|
1CF65A4E2A39FF200042FFBD /* WorkoutDetailViewModel.swift in Sources */,
|
||||||
1CF65A472A39FB6C0042FFBD /* RegisteredUser.swift in Sources */,
|
1CF65A472A39FB6C0042FFBD /* RegisteredUser.swift in Sources */,
|
||||||
1CF65A522A3A90A00042FFBD /* PreviewWorkout.swift in Sources */,
|
1CF65A522A3A90A00042FFBD /* PreviewWorkout.swift in Sources */,
|
||||||
|
1CF65A6E2A3F60480042FFBD /* CreateViewModels.swift in Sources */,
|
||||||
1CF65A4C2A39FDA20042FFBD /* WorkoutDetailView.swift in Sources */,
|
1CF65A4C2A39FDA20042FFBD /* WorkoutDetailView.swift in Sources */,
|
||||||
1CF65A432A39FB410042FFBD /* Workout.swift in Sources */,
|
1CF65A432A39FB410042FFBD /* Workout.swift in Sources */,
|
||||||
1CF65A502A3A1EA90042FFBD /* BridgeModule.swift in Sources */,
|
1CF65A502A3A1EA90042FFBD /* BridgeModule.swift in Sources */,
|
||||||
1CF65A592A3BF4B60042FFBD /* Muscle.swift in Sources */,
|
1CF65A592A3BF4B60042FFBD /* Muscle.swift in Sources */,
|
||||||
1CF65A2B2A3972840042FFBD /* Werkout_ios.xcdatamodeld in Sources */,
|
1CF65A2B2A3972840042FFBD /* Werkout_ios.xcdatamodeld in Sources */,
|
||||||
1CF65A2D2A3972840042FFBD /* MainView.swift in Sources */,
|
1CF65A2D2A3972840042FFBD /* MainView.swift in Sources */,
|
||||||
|
1CF65A732A3F60D20042FFBD /* CreateExerciseActionsView.swift in Sources */,
|
||||||
1CF65A282A3972840042FFBD /* Persistence.swift in Sources */,
|
1CF65A282A3972840042FFBD /* Persistence.swift in Sources */,
|
||||||
1CF65A5B2A3BF4BE0042FFBD /* Equipment.swift in Sources */,
|
1CF65A5B2A3BF4BE0042FFBD /* Equipment.swift in Sources */,
|
||||||
1CF65A452A39FB550042FFBD /* Exercise.swift in Sources */,
|
1CF65A452A39FB550042FFBD /* Exercise.swift in Sources */,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import Combine
|
||||||
|
|
||||||
struct AddExerciseView: View {
|
struct AddExerciseView: View {
|
||||||
@State var exercises: [ExerciseExercise]?
|
@State var exercises: [ExerciseExercise]?
|
||||||
@@ -17,6 +18,8 @@ struct AddExerciseView: View {
|
|||||||
@State var selectedEquipment = [Equipment]()
|
@State var selectedEquipment = [Equipment]()
|
||||||
@State var filteredExercises = [ExerciseExercise]()
|
@State var filteredExercises = [ExerciseExercise]()
|
||||||
|
|
||||||
|
@State var searchString: String = ""
|
||||||
|
|
||||||
@EnvironmentObject var bridgeModule: BridgeModule
|
@EnvironmentObject var bridgeModule: BridgeModule
|
||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
|
|
||||||
@@ -101,15 +104,23 @@ struct AddExerciseView: View {
|
|||||||
}.frame(height: 100)
|
}.frame(height: 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextField("Filter", text: $searchString)
|
||||||
|
.onReceive(Just(searchString)) { location in
|
||||||
|
filterExercises()
|
||||||
|
}
|
||||||
|
.padding()
|
||||||
|
|
||||||
List() {
|
List() {
|
||||||
ForEach(filteredExercises.indices, id: \.self) { i in
|
ForEach(filteredExercises.indices, id: \.self) { i in
|
||||||
let obj = filteredExercises[i]
|
let obj = filteredExercises[i]
|
||||||
VStack {
|
VStack {
|
||||||
Text(obj.name)
|
Text(obj.name)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
Text(obj.side)
|
if obj.side.count > 0 {
|
||||||
.font(.footnote)
|
Text(obj.side)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.font(.footnote)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
Text(obj.equipmentRequired)
|
Text(obj.equipmentRequired)
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
@@ -117,6 +128,7 @@ struct AddExerciseView: View {
|
|||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
}
|
}
|
||||||
|
.contentShape(Rectangle())
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
selectedWorkout(obj)
|
selectedWorkout(obj)
|
||||||
dismiss()
|
dismiss()
|
||||||
@@ -172,7 +184,11 @@ struct AddExerciseView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasCorrectMuscles && hasCorrectEquipment
|
if !searchString.isEmpty {
|
||||||
|
return exercise.name.contains(searchString) && hasCorrectMuscles && hasCorrectEquipment
|
||||||
|
} else {
|
||||||
|
return hasCorrectMuscles && hasCorrectEquipment
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
//
|
|
||||||
// CreateWorkoutView.swift
|
|
||||||
// Werkout_ios
|
|
||||||
//
|
|
||||||
// Created by Trey Tartt on 6/15/23.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
struct CreateWorkoutView: View {
|
|
||||||
@State var exercises = [ExerciseExercise]()
|
|
||||||
@State private var showAddExercise = false
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
VStack {
|
|
||||||
Button("add", action: {
|
|
||||||
showAddExercise.toggle()
|
|
||||||
})
|
|
||||||
|
|
||||||
List() {
|
|
||||||
ForEach(exercises.indices, id: \.self) { i in
|
|
||||||
let obj = exercises[i]
|
|
||||||
Text(obj.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.sheet(isPresented: $showAddExercise) {
|
|
||||||
AddExerciseView(selectedWorkout: { exercise in
|
|
||||||
addNewExercise(exercise: exercise)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func addNewExercise(exercise: ExerciseExercise) {
|
|
||||||
exercises.append(exercise)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct CreateWorkoutView_Previews: PreviewProvider {
|
|
||||||
static var previews: some View {
|
|
||||||
CreateWorkoutView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
//
|
||||||
|
// CreateViewRepsWeightView.swift
|
||||||
|
// Werkout_ios
|
||||||
|
//
|
||||||
|
// Created by Trey Tartt on 6/18/23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct CreateExerciseActionsView: View {
|
||||||
|
@ObservedObject var workoutExercise: CreateWorkoutExercise
|
||||||
|
var superset: CreateWorkoutSuperSet
|
||||||
|
var viewModel: WorkoutViewModel
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
if workoutExercise.exercise.isReps {
|
||||||
|
VStack {
|
||||||
|
HStack {
|
||||||
|
VStack {
|
||||||
|
HStack {
|
||||||
|
Text("Reps: ")
|
||||||
|
Text("\(workoutExercise.reps)")
|
||||||
|
}
|
||||||
|
Stepper("", onIncrement: {
|
||||||
|
workoutExercise.increaseReps()
|
||||||
|
}, onDecrement: {
|
||||||
|
workoutExercise.decreaseReps()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Divider()
|
||||||
|
VStack{
|
||||||
|
HStack {
|
||||||
|
Text("Weight: ")
|
||||||
|
Text("\(workoutExercise.weight)")
|
||||||
|
}
|
||||||
|
Stepper("", onIncrement: {
|
||||||
|
workoutExercise.increaseWeight()
|
||||||
|
}, onDecrement: {
|
||||||
|
workoutExercise.decreaseWeight()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if workoutExercise.exercise.isDuration {
|
||||||
|
VStack{
|
||||||
|
HStack {
|
||||||
|
Text("Duration: ")
|
||||||
|
Text("\(workoutExercise.duration)")
|
||||||
|
}
|
||||||
|
Stepper("", onIncrement: {
|
||||||
|
workoutExercise.increaseDuration()
|
||||||
|
}, onDecrement: {
|
||||||
|
workoutExercise.decreaseDuration()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Spacer()
|
||||||
|
Button(action: {
|
||||||
|
}) {
|
||||||
|
Image(systemName: "video.fill")
|
||||||
|
}
|
||||||
|
.frame(width: 88, height: 44)
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.background(.blue)
|
||||||
|
.cornerRadius(10)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
Divider()
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
superset.deleteExerciseForChosenSuperset(exercise: workoutExercise)
|
||||||
|
viewModel.objectWillChange.send()
|
||||||
|
}) {
|
||||||
|
Image(systemName: "trash.fill")
|
||||||
|
}
|
||||||
|
.frame(width: 88, height: 44)
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.background(.red)
|
||||||
|
.cornerRadius(10)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
|
||||||
|
Divider()
|
||||||
|
.background(.blue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//struct CreateViewRepsWeightView_Previews: PreviewProvider {
|
||||||
|
// static var previews: some View {
|
||||||
|
// CreateViewRepsWeightView()
|
||||||
|
// }
|
||||||
|
//}
|
||||||
98
Werkout_ios/Views/CreateWorkoutViews/CreateViewModels.swift
Normal file
98
Werkout_ios/Views/CreateWorkoutViews/CreateViewModels.swift
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
//
|
||||||
|
// CreateViewModels.swift
|
||||||
|
// Werkout_ios
|
||||||
|
//
|
||||||
|
// Created by Trey Tartt on 6/18/23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
class CreateWorkoutExercise: ObservableObject, Identifiable {
|
||||||
|
let id = UUID()
|
||||||
|
var exercise: ExerciseExercise
|
||||||
|
@Published var reps: Int = 0
|
||||||
|
@Published var duration: Int = 0
|
||||||
|
@Published var weight: Int = 0
|
||||||
|
|
||||||
|
init(exercise: ExerciseExercise, reps: Int = 0, duration: Int = 0, weight: Int = 0) {
|
||||||
|
self.exercise = exercise
|
||||||
|
self.reps = reps
|
||||||
|
self.duration = duration
|
||||||
|
self.weight = weight
|
||||||
|
}
|
||||||
|
|
||||||
|
func increaseReps() {
|
||||||
|
self.reps += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func decreaseReps() {
|
||||||
|
self.reps -= 1
|
||||||
|
if self.reps < 0 {
|
||||||
|
self.reps = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func increaseDuration() {
|
||||||
|
self.duration += 15
|
||||||
|
}
|
||||||
|
|
||||||
|
func decreaseDuration() {
|
||||||
|
self.duration -= 15
|
||||||
|
if self.duration < 0 {
|
||||||
|
self.duration = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func increaseWeight() {
|
||||||
|
self.weight += 5
|
||||||
|
}
|
||||||
|
|
||||||
|
func decreaseWeight() {
|
||||||
|
self.weight -= 15
|
||||||
|
if self.weight < 0 {
|
||||||
|
self.weight = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CreateWorkoutSuperSet: ObservableObject, Identifiable {
|
||||||
|
let id = UUID()
|
||||||
|
@Published var exercises = [CreateWorkoutExercise]()
|
||||||
|
@Published var numberOfRounds = 1
|
||||||
|
|
||||||
|
func increaseNumberOfRounds() {
|
||||||
|
self.numberOfRounds += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func decreaseNumberOfRounds() {
|
||||||
|
self.numberOfRounds -= 1
|
||||||
|
if self.numberOfRounds < 1 {
|
||||||
|
self.numberOfRounds = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func deleteExerciseForChosenSuperset(exercise: CreateWorkoutExercise) {
|
||||||
|
if let idx = exercises.firstIndex(where: {
|
||||||
|
$0.id == exercise.id
|
||||||
|
}) {
|
||||||
|
exercises.remove(at: idx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class WorkoutViewModel: ObservableObject {
|
||||||
|
@Published var superSets = [CreateWorkoutSuperSet]()
|
||||||
|
@Published var title = String()
|
||||||
|
|
||||||
|
func addNewSuperset() {
|
||||||
|
superSets.append(CreateWorkoutSuperSet())
|
||||||
|
}
|
||||||
|
|
||||||
|
func delete(superset: CreateWorkoutSuperSet) {
|
||||||
|
if let idx = superSets.firstIndex(where: {
|
||||||
|
$0.id == superset.id
|
||||||
|
}) {
|
||||||
|
superSets.remove(at: idx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
105
Werkout_ios/Views/CreateWorkoutViews/CreateWorkoutMainView.swift
Normal file
105
Werkout_ios/Views/CreateWorkoutViews/CreateWorkoutMainView.swift
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
//
|
||||||
|
// CreateWorkoutView.swift
|
||||||
|
// Werkout_ios
|
||||||
|
//
|
||||||
|
// Created by Trey Tartt on 6/15/23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct CreateWorkoutMainView: View {
|
||||||
|
@ObservedObject var viewModel = WorkoutViewModel()
|
||||||
|
@State private var showAddExercise = false
|
||||||
|
@State var selectedCreateWorkoutSuperSet: CreateWorkoutSuperSet?
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
TextField("Title", text: $viewModel.title)
|
||||||
|
.padding()
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Button("Add Superset", action: {
|
||||||
|
viewModel.addNewSuperset()
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.frame(height: 44)
|
||||||
|
.foregroundColor(.blue)
|
||||||
|
.background(.yellow)
|
||||||
|
.cornerRadius(8)
|
||||||
|
.padding()
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
|
||||||
|
Divider()
|
||||||
|
|
||||||
|
Button("Done", action: {
|
||||||
|
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.frame(height: 44)
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.background(.blue)
|
||||||
|
.cornerRadius(8)
|
||||||
|
.padding()
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
}
|
||||||
|
.frame(height: 44)
|
||||||
|
|
||||||
|
List() {
|
||||||
|
ForEach($viewModel.superSets, id: \.id) { superset in
|
||||||
|
Section {
|
||||||
|
ForEach(superset.exercises, id: \.id) { exercise in
|
||||||
|
HStack {
|
||||||
|
VStack {
|
||||||
|
Text(exercise.wrappedValue.exercise.name)
|
||||||
|
.font(.title2)
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
if exercise.wrappedValue.exercise.side.count > 0 {
|
||||||
|
Text(exercise.wrappedValue.exercise.side)
|
||||||
|
.font(.title3)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
}
|
||||||
|
CreateExerciseActionsView(workoutExercise: exercise.wrappedValue,
|
||||||
|
superset: superset.wrappedValue,
|
||||||
|
viewModel: viewModel)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Stepper("Number of rounds", onIncrement: {
|
||||||
|
superset.wrappedValue.increaseNumberOfRounds()
|
||||||
|
viewModel.objectWillChange.send()
|
||||||
|
}, onDecrement: {
|
||||||
|
superset.wrappedValue.decreaseNumberOfRounds()
|
||||||
|
viewModel.objectWillChange.send()
|
||||||
|
})
|
||||||
|
Text("\(superset.wrappedValue.numberOfRounds)")
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateWorkoutSupersetActionsView(workoutSuperSet: superset.wrappedValue,
|
||||||
|
showAddExercise: $showAddExercise,
|
||||||
|
viewModel: viewModel,
|
||||||
|
selectedCreateWorkoutSuperSet: $selectedCreateWorkoutSuperSet)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.listRowSeparator(.hidden)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.sheet(isPresented: $showAddExercise) {
|
||||||
|
AddExerciseView(selectedWorkout: { exercise in
|
||||||
|
let workoutExercise = CreateWorkoutExercise(exercise: exercise)
|
||||||
|
selectedCreateWorkoutSuperSet?.exercises.append(workoutExercise)
|
||||||
|
viewModel.objectWillChange.send()
|
||||||
|
selectedCreateWorkoutSuperSet = nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//struct CreateWorkoutView_Previews: PreviewProvider {
|
||||||
|
// static var previews: some View {
|
||||||
|
// CreateWorkoutView()
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
//
|
||||||
|
// CreateWorkoutSupersetActionsView.swift
|
||||||
|
// Werkout_ios
|
||||||
|
//
|
||||||
|
// Created by Trey Tartt on 6/18/23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct CreateWorkoutSupersetActionsView: View {
|
||||||
|
var workoutSuperSet: CreateWorkoutSuperSet
|
||||||
|
@Binding var showAddExercise: Bool
|
||||||
|
var viewModel: WorkoutViewModel
|
||||||
|
@Binding var selectedCreateWorkoutSuperSet: CreateWorkoutSuperSet?
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack {
|
||||||
|
Button(action: {
|
||||||
|
selectedCreateWorkoutSuperSet = workoutSuperSet
|
||||||
|
showAddExercise.toggle()
|
||||||
|
}) {
|
||||||
|
Text("Add exercise")
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.background(.green)
|
||||||
|
.cornerRadius(10)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
|
||||||
|
// Button(action: {
|
||||||
|
// if let selectedCreateWorkoutSuperSet = selectedCreateWorkoutSuperSet {
|
||||||
|
// viewModel.delete(superset: selectedCreateWorkoutSuperSet)
|
||||||
|
// viewModel.objectWillChange.send()
|
||||||
|
// }
|
||||||
|
// }) {
|
||||||
|
// Text("Delete superset")
|
||||||
|
// .padding()
|
||||||
|
// }
|
||||||
|
// .frame(maxWidth: .infinity)
|
||||||
|
// .foregroundColor(.white)
|
||||||
|
// .background(.red)
|
||||||
|
// .cornerRadius(10)
|
||||||
|
// .frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//struct CreateWorkoutSupersetActionsView_Previews: PreviewProvider {
|
||||||
|
// static var previews: some View {
|
||||||
|
// CreateWorkoutSupersetActionsView()
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -46,7 +46,7 @@ struct Werkout_iosApp: App {
|
|||||||
.tabItem {
|
.tabItem {
|
||||||
Label("All Workouts", systemImage: "figure.strengthtraining.traditional")
|
Label("All Workouts", systemImage: "figure.strengthtraining.traditional")
|
||||||
}
|
}
|
||||||
CreateWorkoutView()
|
CreateWorkoutMainView()
|
||||||
.tabItem {
|
.tabItem {
|
||||||
Label("Create Workout", systemImage: "plus.app.fill")
|
Label("Create Workout", systemImage: "plus.app.fill")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user