60 lines
1.9 KiB
Swift
60 lines
1.9 KiB
Swift
//
|
||
// SplitExerciseAssignment.swift
|
||
// Workouts
|
||
//
|
||
// Created by rzen on 7/15/25 at 7:12 AM.
|
||
//
|
||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||
//
|
||
|
||
import SwiftUI
|
||
|
||
struct SplitExerciseAssignmentAddEditView: View {
|
||
@Environment(\.modelContext) private var modelContext
|
||
@Environment(\.dismiss) private var dismiss
|
||
|
||
@State var model: SplitExerciseAssignment
|
||
|
||
var body: some View {
|
||
NavigationStack {
|
||
Form {
|
||
Section(header: Text("Sets/Reps")) {
|
||
Stepper("Sets: \(model.sets)", value: $model.sets, in: 1...10)
|
||
Stepper("Reps: \(model.reps)", value: $model.reps, in: 1...50)
|
||
}
|
||
|
||
// Weight section
|
||
Section(header: Text("Weight")) {
|
||
HStack {
|
||
VStack(alignment: .center) {
|
||
Text("\(model.weight) lbs")
|
||
.font(.headline)
|
||
}
|
||
Spacer()
|
||
VStack(alignment: .trailing) {
|
||
Stepper("±1", value: $model.weight, in: 0...1000)
|
||
Stepper("±5", value: $model.weight, in: 0...1000, step: 5)
|
||
}
|
||
.frame(width: 130)
|
||
}
|
||
}
|
||
}
|
||
.navigationTitle("\(model.exercise?.name ?? Exercise.unnamed)")
|
||
.toolbar {
|
||
ToolbarItem(placement: .navigationBarLeading) {
|
||
Button("Cancel") {
|
||
dismiss()
|
||
}
|
||
}
|
||
|
||
ToolbarItem(placement: .navigationBarTrailing) {
|
||
Button("Save") {
|
||
try? modelContext.save()
|
||
dismiss()
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|