TheNoiseClock/TheNoiseClock/Views/Alarms/Components/AlarmRowView.swift

61 lines
1.4 KiB
Swift

//
// AlarmRowView.swift
// TheNoiseClock
//
// Created by Matt Bruce on 9/7/25.
//
import SwiftUI
/// Component for displaying individual alarm row
struct AlarmRowView: View {
// MARK: - Properties
let alarm: Alarm
let onToggle: () -> Void
let onEdit: () -> Void
// MARK: - Body
var body: some View {
HStack {
VStack(alignment: .leading, spacing: UIConstants.Spacing.extraSmall) {
Text(alarm.formattedTime())
.font(.headline)
.foregroundColor(UIConstants.Colors.primaryText)
Text(alarm.label)
.font(.subheadline)
.foregroundColor(UIConstants.Colors.secondaryText)
Text("\(AlarmSoundService.shared.getSoundDisplayName(alarm.soundName))")
.font(.caption)
.foregroundColor(UIConstants.Colors.secondaryText)
}
Spacer()
Toggle("", isOn: Binding(
get: { alarm.isEnabled },
set: { _ in onToggle() }
))
.labelsHidden()
}
.contentShape(Rectangle())
.onTapGesture {
onEdit()
}
}
}
// MARK: - Preview
#Preview {
List {
AlarmRowView(
alarm: Alarm(time: Date()),
onToggle: {},
onEdit: {}
)
}
}