All Projects → zjfjack → Jzcalendarweekview

zjfjack / Jzcalendarweekview

Licence: mit
Calendar Week & Day View in iOS Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Jzcalendarweekview

Flutterweekview
Displays a highly customizable week view (or day view) which is able to display events, to be scrolled, to be zoomed-in & out and a lot more !
Stars: ✭ 130 (-52.21%)
Mutual labels:  calendar, calendar-view
Kvkcalendar
A most fully customization calendar and timeline library for iOS 📅
Stars: ✭ 160 (-41.18%)
Mutual labels:  calendar, calendar-view
Timetable
📅 Customizable flutter calendar widget including day and week views
Stars: ✭ 140 (-48.53%)
Mutual labels:  calendar, calendar-view
Recyclercalendarandroid
A simple DIY library to generate your own custom Calendar View using RecyclerView, written in Kotlin
Stars: ✭ 83 (-69.49%)
Mutual labels:  calendar, calendar-view
Supercalendar
@deprecated android 自定义日历控件 支持左右无限滑动 周月切换 标记日期显示 自定义显示效果跳转到指定日期
Stars: ✭ 2,732 (+904.41%)
Mutual labels:  calendar, calendar-view
Swift Week View
An iOS calendar library for displaying calendar events in a week view.
Stars: ✭ 88 (-67.65%)
Mutual labels:  calendar, calendar-view
Xamarin.plugin.calendar
Calendar plugin for Xamarin.Forms
Stars: ✭ 159 (-41.54%)
Mutual labels:  calendar, calendar-view
Calendarview
Android上一个优雅、万能自定义UI、仿iOS、支持垂直、水平方向切换、支持周视图、自定义周起始、性能高效的日历控件,支持热插拔实现的UI定制!支持标记、自定义颜色、农历、自定义月视图各种显示模式等。Canvas绘制,速度快、占用内存低,你真的想不到日历居然还可以如此优雅!An elegant, highly customized and high-performance Calendar Widget on Android.
Stars: ✭ 7,998 (+2840.44%)
Mutual labels:  calendar, calendar-view
Customizablecalendar
CustomizableCalendar is a library that allows you to create your calendar, customizing UI and behaviour
Stars: ✭ 214 (-21.32%)
Mutual labels:  calendar, calendar-view
Eventscalendar
Events Calendar is a user-friendly library that helps you achieve a cool Calendar UI with events mapping. You can customise every pixel of the calendar as per your wish and still achieve in implementing all the functionalities of the native android calendar in addition with adding dots to the calendar which represents the presence of an event on the respective dates. It can be done easily, you are just a few steps away from implementing your own badass looking Calendar for your very own project!
Stars: ✭ 188 (-30.88%)
Mutual labels:  calendar, calendar-view
Kotlin Agendacalendarview
Android calendar library provides easy to use widget with events
Stars: ✭ 81 (-70.22%)
Mutual labels:  calendar, calendar-view
THCalendar
Calendar like iOS
Stars: ✭ 21 (-92.28%)
Mutual labels:  calendar, collectionview
Calendarview2
Calendar view for Android. Pretty.
Stars: ✭ 72 (-73.53%)
Mutual labels:  calendar, calendar-view
Aircalendarview
Airbnb APP CalendarView
Stars: ✭ 96 (-64.71%)
Mutual labels:  calendar, calendar-view
Yycalendar
Simple and Clear Calendar
Stars: ✭ 46 (-83.09%)
Mutual labels:  calendar, calendar-view
Calendar Ios
Calendar View
Stars: ✭ 154 (-43.38%)
Mutual labels:  calendar, calendar-view
Table calendar
Highly customizable, feature-packed Flutter Calendar with gestures, animations and multiple formats
Stars: ✭ 897 (+229.78%)
Mutual labels:  calendar, calendar-view
Peppy Calendarview
Simple and fast Material Design calendar view for Android.
Stars: ✭ 30 (-88.97%)
Mutual labels:  calendar, calendar-view
Android Week Calendar
android可自定义日历方案,支持农历、自定义日历控件、排班、左右滑动、周月切换、跳转到指定日期等功能
Stars: ✭ 186 (-31.62%)
Mutual labels:  calendar, calendar-view
GCCalendar
A customizable calendar view for iOS 9+ written in Swift.
Stars: ✭ 53 (-80.51%)
Mutual labels:  calendar, calendar-view



Build Status CocoaPods Carthage compatible Platform Swift 5.0 license MIT

iOS Calendar Week/Day View in Swift

Inspired from WRCalendarView

Features

  • [x] X-Day per Page (Day view: 1-day, 3-day view, weekview: 7-day)
  • [x] Two Scroll types: One-Day scroll (scroll a section) or Page scroll
  • [x] Two Types of Long Press Gestures: Add a new event & Move an existing event
  • [x] Events display on calendar view (supports events with conflict time and events crossing few days)
  • [x] Set horizontal scrollable range dates
  • [x] Support all device orientations (including iPhone X Landscape) and iPad (Slide Over and Split View)
  • [x] Customise your own current timeline
  • [x] All-Day Events

Usage

ViewController

In your viewController, you only need do few things.

  1. Setup your own custom calendarWeekView in viewDidLoad
calendarWeekView.setupCalendar(numOfDays: 7,
                               setDate: Date(),
                               allEvents: JZWeekViewHelper.getIntraEventsByDate(originalEvents: events),
                               scrollType: .pageScroll,
                               firstDayOfWeek: .Monday)
  1. Override viewWillTransition and call viewTransitionHandler in JZWeekViewHelper to support all device orientations
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    JZWeekViewHelper.viewTransitionHandler(to: size, weekView: calendarWeekView)
}
  1. Setup your own custom flowLayout style in viewDidLoad (optional)
calendarWeekView.updateFlowLayout(JZWeekViewFlowLayout(hourHeight: 50, rowHeaderWidth: 50, columnHeaderHeight: 50, hourGridDivision: JZHourGridDivision.noneDiv))

JZBaseWeekView

Create your own WeekView class inheriting from JZBaseWeekView, and you should override the following functions.

  1. Register function: Register your own UICollectionReusableView here. (CollectionViewCell, SupplementaryView or DecorationView)
override func registerViewClasses() {
    super.registerViewClasses()

    // Register CollectionViewCell
    self.collectionView.register(UINib(nibName: "EventCell", bundle: nil), forCellWithReuseIdentifier: "EventCell")

    // Register DecorationView: must provide corresponding JZDecorationViewKinds
    self.flowLayout.register(BlackGridLine.self, forDecorationViewOfKind: JZDecorationViewKinds.verticalGridline)
    self.flowLayout.register(BlackGridLine.self, forDecorationViewOfKind: JZDecorationViewKinds.horizontalGridline)

    // Register SupplementrayView: must override collectionView viewForSupplementaryElementOfKind
    collectionView.register(RowHeader.self, forSupplementaryViewOfKind: JZSupplementaryViewKinds.rowHeader, withReuseIdentifier: "RowHeader")
}

If you want to use your own supplementryView (including your current timeline), you should register it and override the following function

override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView
  1. CollectionView cellForItemAt: Use your custom collectionViewCell
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let date = flowLayout.dateForColumnHeader(at: indexPath)
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: EventCell.className, for: indexPath) as! EventCell
    cell.updateView(event: allEventsBySection[date]![indexPath.row] as! Event)
    return cell
}

JZLongPressView

This view is inheriated from JZBaseWeekView and implements the long press gestures. You can simply follow the setup rules of JZBaseWeekView.
In order to achieve the long press gestures, you should implement the JZLongPressViewDelegate and JZLongPressViewDataSource in your ViewController.

public protocol JZLongPressViewDelegate: class {
    /// When addNew long press gesture ends, this function will be called.
    func weekView(_ weekView: JZLongPressWeekView, didEndAddNewLongPressAt startDate: Date)
    /// When Move long press gesture ends, this function will be called.
    func weekView(_ weekView: JZLongPressWeekView, editingEvent: JZBaseEvent, didEndMoveLongPressAt startDate: Date)
    /// Sometimes the longPress will be cancelled because some curtain reason.
    func weekView(_ weekView: JZLongPressWeekView, longPressType: JZLongPressWeekView.LongPressType, didCancelLongPressAt startDate: Date)
}

public protocol JZLongPressViewDataSource: class {
    /// Implement this function to customise your own AddNew longPressView
    func weekView(_ weekView: JZLongPressWeekView, viewForAddNewLongPressAt startDate: Date) -> UIView
    /// Implement this function to customise your own Move longPressView
    func weekView(_ weekView: JZLongPressWeekView, movingCell: UICollectionViewCell, viewForMoveLongPressAt startDate: Date) -> UIView
}

Also, you should provide the long press types and there are some other properties you can change.

calendarWeekView.longPressDelegate = self
calendarWeekView.longPressDataSource = self
calendarWeekView.longPressTypes = [.addNew, .move]

// Optional
calendarWeekView.addNewDurationMins = 120
calendarWeekView.moveTimeMinInterval = 15

If you want to use the move type long press, you have to inherit your UICollectionViewCell from JZLongPressEventCell to allow retrieving editing JZBaseEvent because of UICollectionView reuse problem. Also, remember to set your cell backgroundColor in cell contentView.

JZBaseEvent

In JZCalendarWeekView, the data model is using [Date: [Event]] dictionary because for each day (a section in collectionView), there might be some events.

A static function called getIntraEventsByDate provided in JZWeekViewHelper allow you to tranform your events list into [Date: [Event]] dictionary.

open class func getIntraEventsByDate<T: JZBaseEvent>(originalEvents: [T]) -> [Date: [T]]

In order to call this function, you should create a subclass of JZBaseEvent and also implement the NSCopying protocol.
For the intraStartDate and intraEndDate in JZBaseEvent, it means that if a event crosses two days, it should be divided into two events but with different intraStartDate and intraEndDate.
eg. startDate = 180329 14:00, endDate = 180330 03:00, then two events should be generated: 1. 180329 14:00(IntraStart) - 23:59(IntraEnd) 2. 180330 00:00(IntraStart) - 03:00(IntraEnd)

All-Day Events

All-Day feature is aimed to display all-day events separately, but only events tagged isAllDay true can be shown. For those events crossing few days would better keep them isAllDay false. (Refer to Apple Calendar & Google Calendar)
In order to active all-day feature, there are only two things you need to do.

  1. Inherit your Event class from JZAllDayEvent to ensure the isAllDay variable added.
  2. In your customised CalendarViewWeekView, override the viewForSupplementaryElementOfKind and use updateView in AllDayHeader to update your all-day view with your own views. Example

Horizontal Scrollable Range

Horizontal scrollable range dates allow you to set your preferred scrollable range. CalendarWeekView can only be horizontal scrollable between startDate(including) and endDate(including). nil means no limit.

  1. You can set scrollableRange when you call setupCalendar() or simply change this variable.
  2. If you change scrollType without calling forceReload(), you should call setHorizontalEdgesOffsetX() to reset the edges, because for different scroll types, the edges are different.

For futher usage, you can also check the example project, some comments in code or just email me.

Requirements

  • iOS 9.0+
  • Xcode 10+
  • Swift 4.2

Installation

Swift Package Manager

JZCalendarWeekView can be added to your project by adding the following dependency to your Package.swift:

.package(url: "https://github.com/zjfjack/JZCalendarWeekView.git", .upToNextMajor(from: "0.7.2"))

Cocoapods

JZCalendarWeekView can be added to your project by adding the following line to your Podfile:

# Latest release in CocoaPods (recommend to use latest version before v1.0.0 release, optional: provide version number)
pod 'JZCalendarWeekView'

Carthage

JZCalendarWeekView can be added to your project by adding the following line to your Cartfile:

# Latest release on Carthage (recommend to use latest version before v1.0.0 release, optional: provide version number)
github "zjfjack/JZCalendarWeekView"

Todo

  • [ ] DecorationView for different background views (refer to #12)
  • [ ] Limited date range: start time and end Time (vertical) in CalendarView
  • [ ] Theme implementation
  • [ ] New scroll type: Infinite scroll
  • [ ] Support different types of event arrangment rules

Author

Jeff Zhang, [email protected] If you have any questions and suggestions, feel free to contact me.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].