can't see what the problem is .. Im getting the error: Type '()' cannot conform to 'View'
struct CalendarView: View {
@StateObject private var viewModel = CalendarViewModel()
@State private var selectedDate: CalendarDate?
@State private var showModal = false
var body: some View {
VStack {
Text("Calendar App")
.font(.largeTitle)
.padding()
GridStack(rows: 5, columns: 7) { row, col in
let index = row * 7 + col
if index < viewModel.calendarDates.count {
let calendarDate = viewModel.calendarDates[index]
Text("\(Calendar.current.component(.day, from: calendarDate.date))")
.frame(width: 40, height: 40)
.background(calendarDate.isSelected ? Color.blue : Color.clear)
.cornerRadius(10)
.foregroundColor(calendarDate.isSelected ? Color.white : Color.black)
.onLongPressGesture {
selectedDate = calendarDate
showModal = true
}
}
}
}
.background(Color.gray)
.sheet(isPresented: $showModal) {
if let date = selectedDate {
DateSelectionModal(selectedDate: date)
}
}
}
}
struct GridStack<Content: View>: View {
let rows: Int
let columns: Int
let content: (Int, Int) -> Content
var body: some View {
VStack {
ForEach(0..<rows) { row in
HStack {
ForEach(0..<columns) { column in
content(row, column)
}
}
}
}
}
}
#Preview {
CalendarView()
}