implement multi stopwatch

This commit is contained in:
2026-01-27 01:44:33 +01:00
parent 4291099fba
commit a3b73e101b
5 changed files with 243 additions and 6 deletions

View File

@@ -0,0 +1,40 @@
//
// 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 })
}