48 lines
1.3 KiB
Swift
48 lines
1.3 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()
|
|
}
|
|
|
|
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: {})
|
|
}
|