{"id":13990678,"url":"https://github.com/zjfjack/JZCalendarWeekView","last_synced_at":"2025-07-22T13:30:48.114Z","repository":{"id":31162189,"uuid":"127077522","full_name":"zjfjack/JZCalendarWeekView","owner":"zjfjack","description":"Calendar Week \u0026 Day View in iOS Swift","archived":false,"fork":false,"pushed_at":"2024-07-15T14:44:12.000Z","size":11384,"stargazers_count":460,"open_issues_count":65,"forks_count":121,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-11-10T21:02:54.075Z","etag":null,"topics":["calendar","calendar-view","collectionview","dayview","ios","ios-swift","swift","timetable","week-calendar","weekview"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zjfjack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-28T03:19:06.000Z","updated_at":"2024-11-03T07:32:53.000Z","dependencies_parsed_at":"2024-03-24T07:33:11.324Z","dependency_job_id":"9cc9d36e-aaf3-498f-a483-27f313fb10f7","html_url":"https://github.com/zjfjack/JZCalendarWeekView","commit_stats":{"total_commits":102,"total_committers":9,"mean_commits":"11.333333333333334","dds":0.3921568627450981,"last_synced_commit":"6177be0ddb1257711186b8a282dfef5dcb274786"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zjfjack%2FJZCalendarWeekView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zjfjack%2FJZCalendarWeekView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zjfjack%2FJZCalendarWeekView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zjfjack%2FJZCalendarWeekView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zjfjack","download_url":"https://codeload.github.com/zjfjack/JZCalendarWeekView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227098930,"owners_count":17730672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calendar","calendar-view","collectionview","dayview","ios","ios-swift","swift","timetable","week-calendar","weekview"],"created_at":"2024-08-09T13:03:05.787Z","updated_at":"2024-11-29T10:31:20.639Z","avatar_url":"https://github.com/zjfjack.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/zjfjack/JZCalendarWeekView/blob/master/Screenshots/logotype.png\"/\u003e \u003cbr /\u003e \u003cbr /\u003e\n\n[![Build Status](https://travis-ci.org/zjfjack/JZCalendarWeekView.svg?branch=master)](https://travis-ci.org/zjfjack/JZCalendarWeekView)\n[![CocoaPods](https://img.shields.io/cocoapods/v/JZCalendarWeekView.svg)](https://cocoapods.org/pods/JZCalendarWeekView)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Platform](https://img.shields.io/cocoapods/p/JZCalendarWeekView.svg?style=flat)](https://github.com/zjfjack/JZCalendarWeekView)\n[![Swift 5.0](https://img.shields.io/badge/Swift-5.0-orange.svg?style=flat)](https://developer.apple.com/swift/)\n[![license MIT](https://img.shields.io/cocoapods/l/JZCalendarWeekView.svg)](http://opensource.org/licenses/MIT)\n\niOS Calendar Week/Day View in Swift\n\nInspired from [WRCalendarView](https://github.com/wayfinders/WRCalendarView)\n\n## Features\n\n- [x] X-Day per Page (Day view: 1-day, 3-day view, weekview: 7-day)\n- [x] Two Scroll types: One-Day scroll (scroll a section) or Page scroll\n- [x] Two Types of Long Press Gestures: Add a new event \u0026 Move an existing event\n- [x] Events display on calendar view (supports events with conflict time and events crossing few days)\n- [x] Set horizontal scrollable range dates\n- [x] Support all device orientations (including iPhone X Landscape) and iPad (Slide Over and Split View)\n- [x] Customise your own current timeline\n- [x] All-Day Events\n\n\u003cimg src=\"https://raw.githubusercontent.com/zjfjack/JZCalendarWeekView/master/Screenshots/numOfDays.gif\" width=\"210\"/\u003e \u003cimg src=\"https://raw.githubusercontent.com/zjfjack/JZCalendarWeekView/master/Screenshots/longPress.gif\" width=\"210\"/\u003e \u003cimg src=\"https://raw.githubusercontent.com/zjfjack/JZCalendarWeekView/master/Screenshots/scrollType.gif\" width=\"210\"/\u003e \u003cimg src=\"https://raw.githubusercontent.com/zjfjack/JZCalendarWeekView/master/Screenshots/all-day.gif\" width=\"210\"/\u003e\n\n## Usage\n\n### ViewController\n\nIn your viewController, you only need do few things.\n\n1. Setup your own custom calendarWeekView in `viewDidLoad`\n```swift\ncalendarWeekView.setupCalendar(numOfDays: 7,\n                               setDate: Date(),\n                               allEvents: JZWeekViewHelper.getIntraEventsByDate(originalEvents: events),\n                               scrollType: .pageScroll,\n                               firstDayOfWeek: .Monday)\n```\n2. Override `viewWillTransition` and call `viewTransitionHandler` in `JZWeekViewHelper` to support all device orientations\n```swift\noverride func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {\n    JZWeekViewHelper.viewTransitionHandler(to: size, weekView: calendarWeekView)\n}\n```\n3. Setup your own custom flowLayout style in `viewDidLoad` (optional)\n```swift\ncalendarWeekView.updateFlowLayout(JZWeekViewFlowLayout(hourHeight: 50, rowHeaderWidth: 50, columnHeaderHeight: 50, hourGridDivision: JZHourGridDivision.noneDiv))\n```\n\n### JZBaseWeekView\n\nCreate your own WeekView class inheriting from `JZBaseWeekView`, and you should override the following functions.\n\n1. Register function: Register your own  `UICollectionReusableView` here. (CollectionViewCell, SupplementaryView or  DecorationView)\n\n```swift\noverride func registerViewClasses() {\n    super.registerViewClasses()\n\n    // Register CollectionViewCell\n    self.collectionView.register(UINib(nibName: \"EventCell\", bundle: nil), forCellWithReuseIdentifier: \"EventCell\")\n\n    // Register DecorationView: must provide corresponding JZDecorationViewKinds\n    self.flowLayout.register(BlackGridLine.self, forDecorationViewOfKind: JZDecorationViewKinds.verticalGridline)\n    self.flowLayout.register(BlackGridLine.self, forDecorationViewOfKind: JZDecorationViewKinds.horizontalGridline)\n\n    // Register SupplementrayView: must override collectionView viewForSupplementaryElementOfKind\n    collectionView.register(RowHeader.self, forSupplementaryViewOfKind: JZSupplementaryViewKinds.rowHeader, withReuseIdentifier: \"RowHeader\")\n}\n```\nIf you want to use your own supplementryView (including your current timeline), you should register it and override the following function\n\n```swift\noverride func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -\u003e UICollectionReusableView\n```\n2. CollectionView `cellForItemAt`: Use your custom collectionViewCell\n\n```swift\noverride func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -\u003e UICollectionViewCell {\n    let date = flowLayout.dateForColumnHeader(at: indexPath)\n    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: EventCell.className, for: indexPath) as! EventCell\n    cell.updateView(event: allEventsBySection[date]![indexPath.row] as! Event)\n    return cell\n}\n```\n\n### JZLongPressView\n\nThis view is inheriated from `JZBaseWeekView` and implements the long press gestures. You can simply follow the setup rules of `JZBaseWeekView`. \u003cbr /\u003e\nIn order to achieve the long press gestures, you should implement the `JZLongPressViewDelegate` and `JZLongPressViewDataSource` in your ViewController.\n\n```swift\npublic protocol JZLongPressViewDelegate: class {\n    /// When addNew long press gesture ends, this function will be called.\n    func weekView(_ weekView: JZLongPressWeekView, didEndAddNewLongPressAt startDate: Date)\n    /// When Move long press gesture ends, this function will be called.\n    func weekView(_ weekView: JZLongPressWeekView, editingEvent: JZBaseEvent, didEndMoveLongPressAt startDate: Date)\n    /// Sometimes the longPress will be cancelled because some curtain reason.\n    func weekView(_ weekView: JZLongPressWeekView, longPressType: JZLongPressWeekView.LongPressType, didCancelLongPressAt startDate: Date)\n}\n\npublic protocol JZLongPressViewDataSource: class {\n    /// Implement this function to customise your own AddNew longPressView\n    func weekView(_ weekView: JZLongPressWeekView, viewForAddNewLongPressAt startDate: Date) -\u003e UIView\n    /// Implement this function to customise your own Move longPressView\n    func weekView(_ weekView: JZLongPressWeekView, movingCell: UICollectionViewCell, viewForMoveLongPressAt startDate: Date) -\u003e UIView\n}\n```\nAlso, you should provide the long press types and there are some other properties you can change.\n\n```swift \ncalendarWeekView.longPressDelegate = self\ncalendarWeekView.longPressDataSource = self\ncalendarWeekView.longPressTypes = [.addNew, .move]\n\n// Optional\ncalendarWeekView.addNewDurationMins = 120\ncalendarWeekView.moveTimeMinInterval = 15\n```\nIf 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`.\n\n### JZBaseEvent\n\nIn JZCalendarWeekView, the data model is using `[Date: [Event]]` dictionary because for each day (a section in collectionView), there might be some events. \u003cbr /\u003e\n\nA static function called `getIntraEventsByDate` provided in `JZWeekViewHelper` allow you to tranform your events list into `[Date: [Event]]` dictionary.\n```swift \nopen class func getIntraEventsByDate\u003cT: JZBaseEvent\u003e(originalEvents: [T]) -\u003e [Date: [T]]\n```\nIn order to call this function, you should create a subclass of `JZBaseEvent` and also implement the `NSCopying` protocol. \u003cbr /\u003e\nFor 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. \u003cbr /\u003e\neg. 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)\n\n\n### All-Day Events\n\nAll-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 \u0026 Google Calendar)\u003cbr /\u003e\nIn order to active all-day feature, there are only two things you need to do.\n\n1. Inherit your Event class from `JZAllDayEvent` to ensure the `isAllDay` variable added.\n2. In your customised CalendarViewWeekView, override the `viewForSupplementaryElementOfKind` and use `updateView` in `AllDayHeader` to update your all-day view with your own views. [Example](Example/JZCalendarWeekViewExample/Source/LongPressViews/LongPressWeekView.swift)\n\n\n### Horizontal Scrollable Range\n\nHorizontal 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.\n\n1. You can set `scrollableRange` when you call `setupCalendar()` or simply change this variable.\n2. If you change `scrollType` without calling `forceReload()`, you should call `setHorizontalEdgesOffsetX()` to reset the edges, because for different scroll types, the edges are different.\n\n#### For futher usage, you can also check the example project, some comments in code or just email me.\u003cbr /\u003e\n\n## Requirements\n\n- iOS 9.0+\n- Xcode 10+\n- Swift 4.2\n\n## Installation\n\n### Swift Package Manager\nJZCalendarWeekView can be added to your project by adding the following dependency to your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/zjfjack/JZCalendarWeekView.git\", .upToNextMajor(from: \"0.7.2\"))\n```\n\n### Cocoapods\nJZCalendarWeekView can be added to your project by adding the following line to your `Podfile`:\n\n```ruby\n# Latest release in CocoaPods (recommend to use latest version before v1.0.0 release, optional: provide version number)\npod 'JZCalendarWeekView'\n```\n\n### Carthage\nJZCalendarWeekView can be added to your project by adding the following line to your `Cartfile`:\n\n```ruby\n# Latest release on Carthage (recommend to use latest version before v1.0.0 release, optional: provide version number)\ngithub \"zjfjack/JZCalendarWeekView\"\n```\n\n## Todo\n\n- [ ] DecorationView for different background views (refer to #12)\n- [ ] Limited date range: start time and end Time (vertical) in CalendarView\n- [ ] Theme implementation\n- [ ] New scroll type: Infinite scroll\n- [ ] Support different types of event arrangment rules\n\n## Author\n\nJeff Zhang, zekejeff@gmail.com \u003c/br\u003e\nIf you have any questions and suggestions, feel free to contact me.\n\n## License\n\nJZCalendarWeekView is available under the MIT license. See the [LICENSE](https://github.com/zjfjack/JZCalendarWeekView/blob/master/LICENSE)  for more info.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzjfjack%2FJZCalendarWeekView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzjfjack%2FJZCalendarWeekView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzjfjack%2FJZCalendarWeekView/lists"}