Skip to content

Repository files navigation

MultiCalendarKit

Swift Xcode RxSwift SnapKit

📅 Multiple Calendar for user variable service.

Installation

MultiCalendarKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MultiCalendarKit'

Requirements

To use this framework, you need to extension RxSwift

import RxSwift

extension RxSwift.Reactive where Base: UIViewController {
    
    public var viewWillAppear: Observable<Bool> {
        return methodInvoked(#selector(UIViewController.viewWillAppear))
            .map { $0.first as? Bool ?? false }
    }
    
    public var viewWillDisappear: Observable<Bool> {
        return methodInvoked(#selector(UIViewController.viewWillDisappear))
            .map { $0.first as? Bool ?? false }
    }
}

The calendar view provided by framework is bind to the lifecycle of the ViewController using it, so requiring the mentioned elements.

How to use

First, create a manager object for the desired calendar type, and then pass the required argument values to the initializer of the calendar controller. This will create the necessary components to control the calendar.

private let cellManager: MultiSelectCellManager = .init()
private lazy var cfController: CFController = .init(with: .multiSelectType(self.cellManager), viewWillAppear: self.rx.viewWillAppear.asDriver(onErrorJustReturn: false), viewWillDisappear: self.rx.viewWillDisappear.asDriver(onErrorJustReturn: false))

Then, add the calendar view present in the created controller to the desired ViewController where you want to display it.

self.view.addSubview(cfController.calendarView)

cfController.calendarView.snp.makeConstraints { make in
    make.leading.trailing.equalToSuperview()
    make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top)
    make.bottom.equalTo(self.view.safeAreaLayoutGuide.snp.bottom)
}

Finally, bind the desired actions to the Relay present in the used manager.

self.cellManager.tappedStartDateRelay
self.cellManager.tappedEndDateRelay

Author

Puco, https://wnsxor1993@github.com

License

MultiCalendarKit is available under the Swift license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages