/CalendarList

SwiftUI view to display paginated calendar months and list events per selected day.

Primary LanguageSwiftMIT LicenseMIT

CalendarList

Badge Badge Badge Badge

SwiftUI view to display paginated calendar months and list events per selected day.

Features

  • 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

Usage

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 the Hashable 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:

Requirements

  • iOS 13+ / macOS 10.15+
  • Xcode 11+
  • Swift 5+

Installation

CocoaPods

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

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

Swift Package Manager

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

Questions or feedback?

Feel free to open an issue, or find me @tiusender on Twitter.