// // DayOfWeekPicker.swift // Severed // import SwiftUI /// "On these days:" — seven circular toggles (S M T W T F S) with a /// human-readable summary, as in the reference rule editors. struct DayOfWeekPicker: View { @Binding var days: Set var body: some View { VStack(alignment: .leading, spacing: 14) { HStack { Text("On these days:") .font(.system(size: 15, weight: .semibold)) Spacer() Text(days.summary) .font(.system(size: 14)) .foregroundStyle(Theme.textSecondary) } HStack(spacing: 8) { ForEach(Weekday.displayOrder, id: \.self) { day in dayToggle(day) } } } .padding(16) .background(Theme.surface, in: RoundedRectangle(cornerRadius: 18)) } private func dayToggle(_ day: Weekday) -> some View { let isOn = days.contains(day) return Button { if isOn { days.remove(day) } else { days.insert(day) } } label: { Text(day.shortLabel) .font(.system(size: 15, weight: .semibold)) .foregroundStyle(isOn ? .black : Theme.textSecondary) .frame(maxWidth: .infinity) .aspectRatio(1, contentMode: .fit) .background(isOn ? Color.white : Theme.surfaceElevated, in: Circle()) } .buttonStyle(.plain) .accessibilityIdentifier("dayToggle-\(day.rawValue)") .accessibilityLabel(day.abbreviation) .accessibilityAddTraits(isOn ? .isSelected : []) } } #Preview { @Previewable @State var days = Weekday.weekdays DayOfWeekPicker(days: $days) .padding() .background(Theme.background) }