SwiftUI view to display paginated calendar months and list events per selected day.
- Internationalized, localized reusable SwiftUI calendar view
- Generic event data type
- List representation of events for a given day
- View generation for each event is handled by the parent view
- Customizable styles for "today" and "selected" dates
CalendarList takes two main arguments:
- Array of
CalendarEvent
elements. This type wraps the date for the event and the actual data you want to use. As long as the data comforms to theHashable
protocol, you can use any type you want. - A
@ViewBuilder
block that will be used to generate the view that represents an event on a given day.
This is a very basic example using String
as type for the data and a Text
view to represent the event data:
struct ContentView: View {
var events = [
CalendarEvent(dateString: "03/21/2020", data: "Event 1"),
CalendarEvent(dateString: "03/23/2020", data: "Event 2"),
CalendarEvent(dateString: "03/26/2020", data: "Event 3"),
CalendarEvent(dateString: "03/26/2020", data: "Event 4"),
]
var body: some View {
CalendarList(events: self.events) { event in
Text("\(event.data)")
}
}
}
This results in the following:
- iOS 13+ / macOS 10.15+
- Xcode 11+
- Swift 5+
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate CalendarList into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'CalendarList', '~> 1.0'
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate CalendarList into your Xcode project using Carthage, specify it in your Cartfile
:
github "tiusender/CalendarList" ~> 1.0
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift
compiler. Just add the following dependency on your Xcode project:
https://github.com/tiusender/CalendarList.git
Feel free to open an issue, or find me @tiusender on Twitter.