A skinnable calendar.
The onus is on the implementing developer to build the following.
- 4 x
UICollectionViewCell
subclasses representingDayPositions
. - 2 x
UICollectionReusableView
subclasses representingTitlePositions
.
Take a look at the SummerSnowflake example.
let dayTypes = DayPosition.allCases.map { SummerSnowflake.userInterface(for: $0) }
let titleTypes = TitlePosition.allCases.map { SummerSnowflake.userInterface(for: $0) }
let userInterface = UserInterface(dayTypes: dayTypes, titleTypes: titleTypes)
do {
let calendarView = try PagingGridView(startDate: start, endDate: end, userInterface: userInterface)
calendarView.backgroundColor = backgroundColor
// add subview
} catch let error as PagingGridView.Error {
handleError(error) // The date ranges must make sense.
} catch let error as UserInterface.Error {
handleError(error) // All UI elements must be present.
} catch {
fatalError("Unexpected error.")
}
// Switch over the error cases or print like this.
private func handleError(_ error: LocalizedError) {
let errorDescription = error.errorDescription!
let failureReason = error.failureReason!
let recoverySuggestion = error.recoverySuggestion!
fatalError(errorDescription + failureReason + recoverySuggestion)
}
// Find the current selection like so
let date = calendarView.currentSelection?.date
A demo App is available here.
Tap the following image to launch Appetize.
List this package in your Package.swift
manifest file as a Swift Package dependency. Releases Page.