Files
multi-chrono-ios/MultiChrono/StopwatchRow.swift

52 lines
1.5 KiB
Swift

//
// StopwatchRow.swift
// MultiChrono
//
// Created by Beatrice Dellacà on 26/01/26.
//
import SwiftUI
struct StopwatchRow: View {
@ObservedObject var stopwatch: Stopwatch
@ObservedObject var settings = AppSettings.shared
var onDelete: () -> Void
var body: some View {
HStack {
VStack(alignment: .leading) {
Text(stopwatch.name)
.font(.headline)
Text("\(stopwatch.formattedTime(format: settings.timeFormat))")
.font(.largeTitle)
.monospacedDigit()
Text("Laps: \(stopwatch.laps.count + (stopwatch.isRunning ? 1 : 0))")
.font(.caption)
.monospaced()
.foregroundStyle(.secondary)
}
Spacer()
Button(action: {
if stopwatch.isRunning {
stopwatch.pause()
} else {
stopwatch.start()
}
}) {
Image(systemName: stopwatch.isRunning ? "pause.circle.fill" : "play.circle.fill")
.resizable()
.frame(width: 44, height: 44)
.foregroundStyle(stopwatch.isRunning ? .yellow : .green)
}
.buttonStyle(PlainButtonStyle())
}
.padding(.vertical, 8)
}
}
#Preview {
StopwatchRow(stopwatch: Stopwatch(name: "Test Timer"), onDelete: {})
}