initial pre-viable version of watch app

This commit is contained in:
2025-07-20 19:44:53 -04:00
parent 33b88cb8f0
commit 68d90160c6
35 changed files with 2108 additions and 179 deletions

View File

@ -16,19 +16,26 @@ struct ExerciseAddEditView: View {
@State var model: Exercise
@State var originalWeight: Int? = nil
var body: some View {
NavigationStack {
Form {
Section(header: Text("Exercise")) {
Button(action: {
showingExercisePicker = true
}) {
HStack {
Text(model.name.isEmpty ? "Select Exercise" : model.name)
Spacer()
Image(systemName: "chevron.right")
.foregroundColor(.gray)
let exerciseName = model.name
if exerciseName.isEmpty {
Button(action: {
showingExercisePicker = true
}) {
HStack {
Text(model.name.isEmpty ? "Select Exercise" : model.name)
Spacer()
Image(systemName: "chevron.right")
.foregroundColor(.gray)
}
}
} else {
ListItem(title: exerciseName)
}
}
@ -52,6 +59,20 @@ struct ExerciseAddEditView: View {
.frame(width: 130)
}
}
Section (header: Text("Weight Increase")) {
HStack {
Text("Remind every \(model.weightReminderTimeIntervalWeeks) weeks")
Spacer()
Stepper("", value: $model.weightReminderTimeIntervalWeeks, in: 0...366)
}
HStack {
Text("Last weight change \(Date().humanTimeInterval(to: model.weightLastUpdated)) ago")
}
}
}
.onAppear {
originalWeight = model.weight
}
.sheet(isPresented: $showingExercisePicker) {
ExercisePickerView { exerciseNames in
@ -68,6 +89,11 @@ struct ExerciseAddEditView: View {
ToolbarItem(placement: .navigationBarTrailing) {
Button("Save") {
if let originalWeight = originalWeight {
if originalWeight != model.weight {
model.weightLastUpdated = Date()
}
}
try? modelContext.save()
dismiss()
}