Files
workoutsplus/WorkoutsPlus/Components/SetListItem.swift
2024-09-27 17:17:32 +02:00

68 lines
1.4 KiB
Swift

//
// SetListItem.swift
// WorkoutsPlus
//
// Created by Felix Förtsch on 02.09.24.
//
import SwiftUI
struct SetListItem: View {
var workout: Workout
@Binding var set: WorkoutItem
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.set) { workoutItem in
WorkoutListItem(workout, workoutItem)
.padding(.leading)
}
}
private func addExerciseToSet() {
}
}
#Preview {
@Previewable @State var set = WorkoutItem(set: [
WorkoutItem(reps: 10, "Squat"),
WorkoutItem(reps: 10, "Squat"),
WorkoutItem(reps: 10, "Squat")])
List {
SetListItem(workout: Workout(name: "RR"), set: $set)
}
}
#Preview("Empty Database") {
@Previewable @State var set = WorkoutItem(set: [])
List {
SetListItem(workout: Workout(name: "RR"), set: $set)
}
}