CalendarDayCell.swift (1142B)
1 import SwiftUI 2 3 struct CalendarDayCell: View { 4 let dayNumber: Int 5 let isEnabled: Bool 6 let isToday: Bool 7 let isSelected: Bool 8 let onTap: () -> Void 9 10 var body: some View { 11 Button(action: onTap) { 12 Text("\(dayNumber)") 13 .font(.body) 14 .fontWeight(isToday || isSelected ? .bold : .regular) 15 .frame(maxWidth: .infinity, minHeight: 44) 16 .foregroundStyle(foregroundColor) 17 .background { 18 if isSelected { 19 Circle() 20 .fill(Color.accentColor) 21 .frame(width: 36, height: 36) 22 } else if isToday { 23 Circle() 24 .fill(Color.accentColor.opacity(0.15)) 25 .frame(width: 36, height: 36) 26 } 27 } 28 } 29 .buttonStyle(.plain) 30 .disabled(!isEnabled) 31 } 32 33 private var foregroundColor: Color { 34 if isSelected { return .white } 35 return isEnabled ? .primary : .secondary.opacity(0.4) 36 } 37 }