# InfiniteCalendar
**Repository Path**: curryluya-github/InfiniteCalendar
## Basic Information
- **Project Name**: InfiniteCalendar
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2023-12-18
- **Last Updated**: 2023-12-18
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# InfiniteCalendar
**Google Calendar-like infinite scrollable calendar for SwiftUI.**
[](https://twitter.com/ShoheOhtani)

[](https://swift.org/package-manager)
[](./LICENSE)
InfiniteCalendar is infinite scrollable calendar for iOS written in Swift.
UI/UX design inspired by GoogleCalendar. Implementation inspired by JZCalendarWeekView.
___ ### Features - [x] Infinite scroll - [x] Multiple scroll type - [x] Custamazable UI - [x] Support long tap gesture actions - [x] Support autoScroll for drag - [x] Support handling multiple actions - [x] Support vibrate feedback like GoogleCalendar ## Requirements - Swift 5.1 - iOS 13.0 or later ## Installation #### Swift Package Manager InfiniteCalendar is available through [Swift Package Manager](https://swift.org/package-manager). Add it to an existing Xcode project as a package dependency: 1. From the **File** menu, select **Add Packages…** 2. Enter "https://github.com/shohe/InfiniteCalendar.git" into the package repository URL text field ## Documentation - [1. Initialization](#1-initialization) - [2. Handling](#2-handling) - [.onCurrentDateChanged](#oncurrentdatechanged) - [.onItemSelected](#onitemselected) - [.onEventAdded](#oneventadded) - [.onEventMoved](#oneventmoved) - [.onEventCanceled](#oneventcanceled) - [3. Settings](#3-settings) - [numOfDays](#numofdays) - [initDate](#initdate) - [scrollType](#scrolltype) - [moveTimeMinInterval](#movetimemininterval) - [timeRange](#timerange) - [withVibrateFeedback](#withvibratefeedback) - [4. Custom UI components](#4-custom-ui-components) - [Sample custom component (DateHeader)](#sample-custom-component-dateheader) ### 1. Initialization You need to define View, ViewModel and CollectionViewCell for display cell on Calendar: 1. Create View complianted for CellableView protocol: ```swift struct EventCellView: CellableView { typealias VM = ViewModel // MARK: ViewModel struct ViewModel: ICEventable { ... } // MARK: View var viewModel: ViewModel init(_ viewModel: ViewModel) { self.viewModel = viewModel } var body: some View { ... } } ``` 2. Implement ViewModel complianted for ICEventable protocol: ```swift struct ViewModel: ICEventable { private(set) var id: String = UUID().uuidString var text: String var startDate: Date var endDate: Date? var intraStartDate: Date var intraEndDate: Date var editState: EditState? var isAllDay: Bool init(text: String, start: Date, end: Date?, isAllDay: Bool = false, editState: EditState? = nil) { ... } // ! Make sure copy current object, otherwise view won't display properly when SwiftUI View is updated. func copy() -> EventCellView.ViewModel { var copy = ViewModel(text: text, start: startDate, end: endDate, isAllDay: isAllDay, editState: editState) ... return copy } static func create(from eventable: EventCellView.ViewModel?, state: EditState?) -> EventCellView.ViewModel { if var model = eventable?.copy() { model.editState = state return model } return ViewModel(text: "New", start: Date(), end: nil, editState: state) } } ``` 3. Create CollectionViewCell complianted for ViewHostingCell protocol: ```swift final class EventCell: ViewHostingCell
#### datePosition
The display position of Date **only for One-day layout**.
Sample: `datePosition = .top`, `datePosition = .left`
#### initDate
The display date for lounch app
#### scrollType
There is two kinds of scroll type, `Section` and `Page`.
SectionType will deside scroll amount by **scroll velocity**. On the other hand PageType is always scroll to next / prev page with scroll gesture.
#### moveTimeMinInterval
Interval minutes time for drag gesture.
**Default value is 15**. Which means when item was created/moved time will move every 15 minutes
#### timeRange
The display time on time header as a label.
**Default value is (1, 23)**. Which means display 1:00 ~ 23:00.
#### withVibrateFeedback
If vibration is needed during dragging gesture.
**Default value is true**. Vibration feedback is almost same as GoogleCalendar.
----
### 4. Custom UI components
You can customize each components on the bellow.
- SupplementaryCell (Use as SupplementaryCell in CollectionView)
- TimeHeader
- DateHeader
- DateHeaderCorner
- AllDayHeader
- AllDayHeaderCorner
- Timeline
- DecorationCell (Use as DecorationCell in CollectionView)
- TimeHeaderBackground
- DateHeaderBackground
- AllDayHeaderBackground
**Associatedtypes**
Component class is define as typealias to customize.
```swift
//* When you customize, set two of classes to custom class you created.
// TimeHeader
associatedtype TimeHeaderView: ICTimeHeaderView
associatedtype TimeHeader: ICTimeHeader