Note:a visually different project
class EventModel {
var eventName: String
var eventDate: Date
var backgroundColor: String
var iconName: String
var notification: Bool
}
@Environment(.modelContext) var context
@Query(sort: EventModel.eventDate) private var events: [EventModel]
List {
ForEach(events) { index in
EventView(state: model.makeEventCellViewState(event: index))
.onTapGesture {
model.eventToEdit = index
}
}
.onDelete { indexSet in
for index in indexSet {
context.delete(events[index])
}
}
.listRowBackground(Color.clear)
.listRowSeparator(.hidden)
}
.listStyle(PlainListStyle())
As in the sample image, I want to group the content by months according to the date information in eventDate. How can I do this grouping using Section?
As in the sample image, I want to group the content by months according to the date information in eventDate. How can I do this grouping using Section.