diff --git a/Sources/Internal/VisibleItemsProvider.swift b/Sources/Internal/VisibleItemsProvider.swift index 476dbd9..71dee75 100644 --- a/Sources/Internal/VisibleItemsProvider.swift +++ b/Sources/Internal/VisibleItemsProvider.swift @@ -950,13 +950,11 @@ final class VisibleItemsProvider { daysAndFrames: dayRangeLayoutContext.daysAndFrames, boundingUnionRectOfDayFrames: dayRangeLayoutContext.boundingUnionRectOfDayFrames) - if let dayRangeItemModel = dayRangeItemProvider(dayRangeLayoutContext) { - context.visibleItems.insert( - VisibleItem( - calendarItemModel: dayRangeItemModel, - itemType: .dayRange(dayRange), - frame: frame)) - } + context.visibleItems.insert( + VisibleItem( + calendarItemModel: dayRangeItemProvider(dayRangeLayoutContext), + itemType: .dayRange(dayRange), + frame: frame)) } private func handlePinnedDaysOfWeekIfNeeded( @@ -1031,8 +1029,7 @@ final class VisibleItemsProvider { let layoutContext = overlayLayoutContext( for: overlaidItemLocation, inBounds: bounds, - context: &context), - let itemModel = itemModelProvider(layoutContext) + context: &context) else { continue @@ -1040,7 +1037,7 @@ final class VisibleItemsProvider { context.visibleItems.insert( VisibleItem( - calendarItemModel: itemModel, + calendarItemModel: itemModelProvider(layoutContext), itemType: .overlayItem(overlaidItemLocation), frame: bounds)) } diff --git a/Sources/Public/CalendarViewContent.swift b/Sources/Public/CalendarViewContent.swift index 8737231..176cd9b 100644 --- a/Sources/Public/CalendarViewContent.swift +++ b/Sources/Public/CalendarViewContent.swift @@ -338,7 +338,7 @@ public final class CalendarViewContent { for dateRanges: Set>, _ dayRangeItemProvider: @escaping ( _ dayRangeLayoutContext: DayRangeLayoutContext) - -> AnyCalendarItemModel?) + -> AnyCalendarItemModel) -> CalendarViewContent { let dayRanges = Set(dateRanges.map { DayRange(containing: $0, in: calendar) }) @@ -366,7 +366,7 @@ public final class CalendarViewContent { for overlaidItemLocations: Set, _ overlayItemProvider: @escaping ( _ overlayLayoutContext: OverlayLayoutContext) - -> AnyCalendarItemModel?) + -> AnyCalendarItemModel) -> CalendarViewContent { overlaidItemLocationsAndItemProvider = (overlaidItemLocations, overlayItemProvider) @@ -398,10 +398,10 @@ public final class CalendarViewContent { private(set) var monthBackgroundItemProvider: ((MonthLayoutContext) -> AnyCalendarItemModel?)? private(set) var dayRangesAndItemProvider: ( dayRanges: Set, - dayRangeItemProvider: (DayRangeLayoutContext) -> AnyCalendarItemModel?)? + dayRangeItemProvider: (DayRangeLayoutContext) -> AnyCalendarItemModel)? private(set) var overlaidItemLocationsAndItemProvider: ( overlaidItemLocations: Set, - overlayItemProvider: (OverlayLayoutContext) -> AnyCalendarItemModel?)? + overlayItemProvider: (OverlayLayoutContext) -> AnyCalendarItemModel)? /// The default `monthHeaderItemProvider` if no provider has been configured, /// or if the existing provider returns nil. diff --git a/Tests/CalendarContentTests.swift b/Tests/CalendarContentTests.swift index 22da1b4..abf6864 100644 --- a/Tests/CalendarContentTests.swift +++ b/Tests/CalendarContentTests.swift @@ -22,12 +22,6 @@ final class CalendarContentTests: XCTestCase { .dayBackgroundItemProvider { _ in nil } - .dayRangeItemProvider(for: Set([Date.distantPast...Date.distantFuture])) { _ in - nil - } - .overlayItemProvider(for: Set([.day(containingDate: .distantPast)])) { _ in - nil - } } func testNilDayItemUsesDefaultValue() {