import SwiftUI
import Bedrock

struct TodayHabitRowView: View {
    private let title: String
    private let symbolName: String
    private let isCompleted: Bool
    private let action: () -> Void

    init(
        title: String,
        symbolName: String,
        isCompleted: Bool,
        action: @escaping () -> Void
    ) {
        self.title = title
        self.symbolName = symbolName
        self.isCompleted = isCompleted
        self.action = action
    }

    var body: some View {
        Button(action: action) {
            HStack(spacing: Design.Spacing.medium) {
                Image(systemName: symbolName)
                    .font(.title3)
                    .foregroundStyle(isCompleted ? AppStatus.success : AppAccent.primary)
                    .frame(width: AppMetrics.Size.iconLarge)
                    .accessibilityHidden(true)

                Text(title)
                    .font(.body)
                    .foregroundStyle(AppTextColors.primary)

                Spacer(minLength: Design.Spacing.medium)

                Image(systemName: isCompleted ? "checkmark.circle.fill" : "circle")
                    .font(.title3)
                    .foregroundStyle(isCompleted ? AppStatus.success : AppBorder.subtle)
                    .accessibilityHidden(true)
            }
            .padding(.horizontal, Design.Spacing.large)
            .padding(.vertical, Design.Spacing.medium)
            .background(AppSurface.card)
            .clipShape(.rect(cornerRadius: Design.CornerRadius.medium))
        }
        .accessibilityLabel(Text(title))
        .accessibilityValue(isCompleted ? String(localized: "Completed") : String(localized: "Not completed"))
        .accessibilityHint(isCompleted ? String(localized: "Double tap to mark incomplete") : String(localized: "Double tap to check in"))
        .buttonStyle(.plain)
    }
}
