Schema & Models: - Add notes, loadType, duration fields to WorkoutLog - Align Watch schema with iOS (use duration Date instead of separate mins/secs) - Add duration helper properties to Exercise and WorkoutLog UI Changes: - Remove Splits and Settings tabs, single Workout Logs view - Add gear button in nav bar to access Settings as sheet - Move Splits section into Settings view with inline list - Redesign ExerciseView with read-only Plan/Notes tiles and Edit buttons - Add PlanEditView and NotesEditView with Cancel/Save buttons - Auto-dismiss ExerciseView when completing last set - Navigate to ExerciseView when adding new exercise Data Flow: - Plan edits sync to both WorkoutLog and corresponding Exercise - Changes propagate up navigation chain via CoreData
53 lines
1.3 KiB
Swift
53 lines
1.3 KiB
Swift
//
|
|
// NotesEditView.swift
|
|
// Workouts
|
|
//
|
|
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
import CoreData
|
|
|
|
struct NotesEditView: View {
|
|
@Environment(\.managedObjectContext) private var viewContext
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
@ObservedObject var workoutLog: WorkoutLog
|
|
|
|
@State private var notesText: String = ""
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
Form {
|
|
Section {
|
|
TextEditor(text: $notesText)
|
|
.frame(minHeight: 200)
|
|
}
|
|
}
|
|
.navigationTitle("Edit Notes")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar {
|
|
ToolbarItem(placement: .cancellationAction) {
|
|
Button("Cancel") {
|
|
dismiss()
|
|
}
|
|
}
|
|
ToolbarItem(placement: .confirmationAction) {
|
|
Button("Save") {
|
|
saveChanges()
|
|
dismiss()
|
|
}
|
|
}
|
|
}
|
|
.onAppear {
|
|
notesText = workoutLog.notes ?? ""
|
|
}
|
|
}
|
|
}
|
|
|
|
private func saveChanges() {
|
|
workoutLog.notes = notesText
|
|
try? viewContext.save()
|
|
}
|
|
}
|