//
//  AlarmRowView.swift
//  TheNoiseClock
//
//  Created by Matt Bruce on 9/7/25.
//

import SwiftUI
import Bedrock

/// 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: Design.Spacing.xSmall) {
                Text(alarm.formattedTime())
                    .font(.headline)
                    .foregroundColor(AppTextColors.primary)
                
                Text(alarm.label)
                    .font(.subheadline)
                    .foregroundColor(AppTextColors.secondary)
                
                Text("• \(AlarmSoundService.shared.getSoundDisplayName(alarm.soundName))")
                    .font(.caption)
                    .foregroundColor(AppTextColors.secondary)
            }
            
            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: {}
        )
    }
}
