Files
multi-chrono-ios/MultiChrono/StopwatchRow.swift
2026-01-27 01:57:26 +01:00

57 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
var onDelete: () -> Void
var body: some View {
HStack {
VStack(alignment: .leading) {
Text(stopwatch.name)
.font(.headline)
Text("\(stopwatch.formattedTime)")
.font(.largeTitle)
.monospacedDigit()
}
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 ? .orange : .green)
}
.buttonStyle(PlainButtonStyle())
Button(action: onDelete) {
Image(systemName: "trash.circle.fill")
.resizable()
.frame(width: 44, height: 44)
.foregroundColor(.red)
}
.buttonStyle(PlainButtonStyle())
.padding(.leading, 10)
}
.padding(.vertical, 8)
}
}
#Preview {
StopwatchRow(stopwatch: Stopwatch(name: "Test Timer"), onDelete: {})
}