GithubHelp home page GithubHelp logo

sukkuuuuu / calendarkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from richardtop/calendarkit

0.0 2.0 0.0 660 KB

๐Ÿ“… Fully customizable calendar for iOS

License: MIT License

Ruby 0.65% Swift 99.35%

calendarkit's Introduction

CalendarKit License SwiftPM compatible Swift Compatibility Platform Compatibility Tag Version

CalendarKit

CalendarKit is a Swift calendar UI library for iOS, iPadOS and Mac Catalyst. It looks similar to the Apple Calendar app out-of-the-box, while allowing customization when needed. CalendarKit is composed of multiple modules which can be used together or independently.

Need Help?

If you have a programming question about how to use CalendarKit in your application, ask it on StackOverflow with the CalendarKit tag.

Please, use GitHub Issues only for reporting a bug or requesting a new feature.

Examples

Video

Try live in a browser

To try CalendarKit with CocoaPods issue the following command in the Terminal:

pod try CalendarKit

Installation

CalendarKit can be installed with Swift Package Manager or with CocoaPods.

Swift Package Manager (Xcode 12 or higher)

The preferred way of installing CalendarKit is via the Swift Package Manager.

  1. In Xcode, open your project and navigate to File โ†’ Swift Packages โ†’ Add Package Dependency...
  2. Paste the repository URL (https://github.com/richardtop/CalendarKit.git) and click Next.
  3. For Rules, select Version (Up to Next Major) and click Next.
  4. Click Finish.

Adding Package Dependencies to Your App

CocoaPods

To install it, add the following line to your Podfile:

pod 'CalendarKit'

Adding Pods to an Xcode project

Usage

  1. Subclass DayViewController
  2. Implement EventDataSource protocol to show events.

CalendarKit requires EventDataSource to return an array of objects conforming to EventDescriptor protocol, specifying all the information needed to display a particular event. You're free to use a default Event class as a model or create your own class conforming to the EventDescriptor protocol.

// Return an array of EventDescriptors for particular date
override func eventsForDate(_ date: Date) -> [EventDescriptor] {
  var models = myAppEventStore.getEventsForDate(date) // Get events (models) from the storage / API

  var events = [Event]()

  for model in models {
      // Create new EventView
      let event = Event()
      // Specify StartDate and EndDate
      event.startDate = model.startDate
      event.endDate = model.endDate
      // Add info: event title, subtitle, location to the array of Strings
      var info = [model.title, model.location]
      info.append("\(datePeriod.beginning!.format(with: "HH:mm")) - \(datePeriod.end!.format(with: "HH:mm"))")
      // Set "text" value of event by formatting all the information needed for display
      event.text = info.reduce("", {$0 + $1 + "\n"})
      events.append(event)
  }
  return events
}

After receiving an array of events for a particular day, CalendarKit will handle view layout and display.

Usage

To respond to the user input, override mehtods of DayViewDelegate, for example:

override func dayViewDidSelectEventView(_ eventView: EventView) {
  print("Event has been selected: \(eventview.data)")
}

override func dayViewDidLongPressEventView(_ eventView: EventView) {
  print("Event has been longPressed: \(eventView.data)")
}

Localization

CalendarKit supports localization and uses iOS default locale to display month and day names. First day of the week is also selected according to the iOS locale.

GermanNorwegian

Styles

By default, CalendarKit looks similar to the Apple Calendar app and fully supports Dark Mode. If needed, CalendarKit's look can be easily customized. Steps to apply a custom style are as follows:

  1. Create a new CalendarStyle object (or copy existing one)
  2. Change style by updating the properties.
  3. Invoke updateStyle method with the new CalendarStyle.
let style = CalendarStyle()
style.backgroundColor = UIColor.black
dayView.updateStyle(style)

Light theme Dark theme

Requirements

  • iOS 9.0+, iPadOS 13.0+, macOS 10.15+
  • Swift 4+ (Library is written in Swift 5.3)

Contributing

The list of features currently in development can be viewed on the issues page.

Before contributing, please review guidelines and code style.

Author

Richard Topchii

License

CalendarKit is available under the MIT license. See the LICENSE file for more info.

calendarkit's People

Contributors

basthomas avatar bithavoc avatar cstlex avatar danlozano avatar degemenc avatar diego-ta avatar farshadtx avatar grosch avatar inahuelzapata avatar jameswwwebster avatar jaytrisw avatar jdtzmn avatar jmorliaguet avatar joeljfischer avatar jpauljm avatar keith-nativemobile avatar linniergames avatar mihai-moldovan avatar mochathecoder avatar orihpt avatar rarescrap avatar rich86man avatar richardtop avatar spiccinocchi avatar tgymnich avatar tomaculum avatar v-ken avatar vadymmarkov avatar zenangst avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.