add draft views for sets of exercises
This commit is contained in:
48
WorkoutsPlus/Components/ExerciseListItem.swift
Normal file
48
WorkoutsPlus/Components/ExerciseListItem.swift
Normal file
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// ExerciseListItem.swift
|
||||
// WorkoutsPlus
|
||||
//
|
||||
// Created by Felix Förtsch on 02.09.24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ExerciseListItem: View {
|
||||
var workout: Workout
|
||||
@State var exercise: WorkoutItem
|
||||
|
||||
init(_ workout: Workout, _ exercise: WorkoutItem ) {
|
||||
self.workout = workout
|
||||
self.exercise = exercise
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Button(action: {
|
||||
// workout.addExercise(from: exercise)
|
||||
}) {
|
||||
HStack {
|
||||
Text(String(exercise.reps))
|
||||
.font(.system(size: 14, weight: .bold))
|
||||
.foregroundStyle(.white)
|
||||
.frame(width: 20, height: 10)
|
||||
.padding(8)
|
||||
.background(Color.blue)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 8))
|
||||
Text(exercise.name)
|
||||
.foregroundStyle(.black)
|
||||
Spacer()
|
||||
Stepper(
|
||||
value: $exercise.reps,
|
||||
in: 0...100,
|
||||
step: 1
|
||||
) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
List {
|
||||
ExerciseListItem(Workout(name: "RR"), WorkoutItem(from: Exercise("Push-ups")))
|
||||
}
|
||||
}
|
||||
72
WorkoutsPlus/Components/SetListItem.swift
Normal file
72
WorkoutsPlus/Components/SetListItem.swift
Normal file
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// SetListItem.swift
|
||||
// WorkoutsPlus
|
||||
//
|
||||
// Created by Felix Förtsch on 02.09.24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SetListItem: View {
|
||||
var workout: Workout
|
||||
@State var set: WorkoutItem
|
||||
|
||||
init(_ workout: Workout, _ set: WorkoutItem ) {
|
||||
self.workout = workout
|
||||
self.set = set
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
HStack {
|
||||
Text(String(set.reps))
|
||||
.font(.system(size: 14, weight: .bold))
|
||||
.foregroundStyle(.white)
|
||||
.frame(width: 20, height: 10)
|
||||
.padding(8)
|
||||
.background(Color.blue)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 8))
|
||||
Image(systemName: "repeat")
|
||||
Text("Set")
|
||||
}
|
||||
.fontWeight(.bold)
|
||||
Spacer()
|
||||
Stepper(
|
||||
value: $set.reps,
|
||||
in: 0...100,
|
||||
step: 1
|
||||
) {}
|
||||
Button(action: {
|
||||
|
||||
}) {
|
||||
Image(systemName: "plus.circle.fill")
|
||||
.foregroundStyle(.green)
|
||||
}
|
||||
}
|
||||
ForEach(set.workoutItems) { workoutItem in
|
||||
ExerciseListItem(workout, workoutItem)
|
||||
.padding(.leading)
|
||||
}
|
||||
}
|
||||
|
||||
private func addExerciseToSet() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
let set = WorkoutItem(workoutItems: [
|
||||
WorkoutItem(10, "Squat"),
|
||||
WorkoutItem(10, "Squat"),
|
||||
WorkoutItem(10, "Squat")])
|
||||
List {
|
||||
SetListItem(Workout(name: "RR"), set)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview("Empty Database") {
|
||||
let set = WorkoutItem(workoutItems: [])
|
||||
List {
|
||||
SetListItem(Workout(name: "RR"), set)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user