// // AddStopwatchView.swift // MultiChrono // // Created by Beatrice DellacĂ  on 26/01/26. // import SwiftUI struct AddStopwatchView: View { @Environment(\.dismiss) var dismiss @State private var name: String = "" var onAdd: (String) -> Void var body: some View { NavigationStack { Form { TextField("Stopwatch Name", text: $name) } .navigationTitle("New Stopwatch") .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Cancel") { dismiss() } } ToolbarItem(placement: .confirmationAction) { Button("Add") { onAdd(name.isEmpty ? "Stopwatch" : name) dismiss() } } } } } } #Preview { AddStopwatchView(onAdd: { _ in }) }