wip
This commit is contained in:
@@ -32,7 +32,7 @@ struct ExerciseElement: Codable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ExerciseExercise: Codable, Hashable {
|
struct ExerciseExercise: Codable, Hashable, Identifiable {
|
||||||
static func == (lhs: ExerciseExercise, rhs: ExerciseExercise) -> Bool {
|
static func == (lhs: ExerciseExercise, rhs: ExerciseExercise) -> Bool {
|
||||||
lhs.id == rhs.id
|
lhs.id == rhs.id
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,11 @@ struct AddExerciseView: View {
|
|||||||
|
|
||||||
@StateObject var bridgeModule = BridgeModule.shared
|
@StateObject var bridgeModule = BridgeModule.shared
|
||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
var selectedWorkout: ((ExerciseExercise) -> Void)
|
var selectedExercise: ((ExerciseExercise) -> Void)
|
||||||
@State var createWorkoutItemPickerViewModel: CreateWorkoutItemPickerViewModel?
|
@State var createWorkoutItemPickerViewModel: CreateWorkoutItemPickerViewModel?
|
||||||
@State var createWorkoutItemPickerViewType: CreateWorkoutItemPickerViewType?
|
@State var createWorkoutItemPickerViewType: CreateWorkoutItemPickerViewType?
|
||||||
@State var searchString: String = ""
|
@State var searchString: String = ""
|
||||||
|
@State var videoExercise: ExerciseExercise?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
@@ -59,6 +60,9 @@ struct AddExerciseView: View {
|
|||||||
selectedEquipment = equipment
|
selectedEquipment = equipment
|
||||||
filteredExercises = exercises
|
filteredExercises = exercises
|
||||||
}
|
}
|
||||||
|
.sheet(item: $videoExercise) { exercise in
|
||||||
|
VideoPlayerView(currentExercise: exercise)
|
||||||
|
}
|
||||||
.sheet(item: $createWorkoutItemPickerViewModel) { item in
|
.sheet(item: $createWorkoutItemPickerViewModel) { item in
|
||||||
CreateWorkoutItemPickerView(viewModel: item, completed: { selectedids in
|
CreateWorkoutItemPickerView(viewModel: item, completed: { selectedids in
|
||||||
if let viewType = createWorkoutItemPickerViewType {
|
if let viewType = createWorkoutItemPickerViewType {
|
||||||
@@ -193,30 +197,31 @@ struct AddExerciseView: View {
|
|||||||
func exerciseView() -> some View {
|
func exerciseView() -> some View {
|
||||||
List() {
|
List() {
|
||||||
ForEach(filteredExercises.indices, id: \.self) { i in
|
ForEach(filteredExercises.indices, id: \.self) { i in
|
||||||
let obj = filteredExercises[i]
|
let exercise = filteredExercises[i]
|
||||||
if searchString.isEmpty || obj.name.lowercased().contains(searchString.lowercased()) {
|
if searchString.isEmpty || exercise.name.lowercased().contains(searchString.lowercased()) {
|
||||||
HStack {
|
HStack {
|
||||||
VStack {
|
VStack {
|
||||||
Text(obj.name)
|
Text(exercise.name)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
if obj.side.count > 0 {
|
if exercise.side.count > 0 {
|
||||||
Text(obj.side)
|
Text(exercise.side)
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
}
|
}
|
||||||
Text(obj.equipmentRequired)
|
Text(exercise.equipmentRequired)
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
Text(obj.muscleGroups)
|
Text(exercise.muscleGroups)
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
}
|
}
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
selectedWorkout(obj)
|
selectedExercise(exercise)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
Button(action: {
|
Button(action: {
|
||||||
|
videoExercise = exercise
|
||||||
}) {
|
}) {
|
||||||
Image(systemName: "video.fill")
|
Image(systemName: "video.fill")
|
||||||
}
|
}
|
||||||
@@ -233,6 +238,6 @@ struct AddExerciseView: View {
|
|||||||
|
|
||||||
struct AddExerciseView_Previews: PreviewProvider {
|
struct AddExerciseView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
AddExerciseView(selectedWorkout: { _ in })
|
AddExerciseView(selectedExercise: { _ in })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ struct CreateWorkoutMainView: View {
|
|||||||
.padding(.bottom)
|
.padding(.bottom)
|
||||||
}
|
}
|
||||||
.sheet(isPresented: $showAddExercise) {
|
.sheet(isPresented: $showAddExercise) {
|
||||||
AddExerciseView(selectedWorkout: { exercise in
|
AddExerciseView(selectedExercise: { exercise in
|
||||||
let workoutExercise = CreateWorkoutExercise(exercise: exercise)
|
let workoutExercise = CreateWorkoutExercise(exercise: exercise)
|
||||||
selectedCreateWorkoutSuperSet?.exercises.append(workoutExercise)
|
selectedCreateWorkoutSuperSet?.exercises.append(workoutExercise)
|
||||||
viewModel.objectWillChange.send()
|
viewModel.objectWillChange.send()
|
||||||
|
|||||||
Reference in New Issue
Block a user