From 2ce7239b4c71bed5d4dc36c03a035270ff739d42 Mon Sep 17 00:00:00 2001 From: Michael Michailidis Date: Mon, 8 Jan 2018 17:00:02 +0100 Subject: [PATCH] Fixes #27 --- KDCalendar/CalendarView/CalendarDayCell.swift | 10 +++++----- KDCalendar/CalendarView/CalendarFlowLayout.swift | 6 +++--- KDCalendar/CalendarView/CalendarHeaderView.swift | 4 ++-- .../CalendarView/CalendarView+DataSource.swift | 8 ++++---- KDCalendar/CalendarView/CalendarView+Delegate.swift | 8 ++++---- KDCalendar/CalendarView/CalendarView.swift | 12 ++++-------- KDCalendar/CalendarView/EventsLoader.swift | 2 +- 7 files changed, 23 insertions(+), 27 deletions(-) diff --git a/KDCalendar/CalendarView/CalendarDayCell.swift b/KDCalendar/CalendarView/CalendarDayCell.swift index dd57213..da3af46 100644 --- a/KDCalendar/CalendarView/CalendarDayCell.swift +++ b/KDCalendar/CalendarView/CalendarDayCell.swift @@ -25,9 +25,9 @@ import UIKit -class CalendarDayCell: UICollectionViewCell { +open class CalendarDayCell: UICollectionViewCell { - override var description: String { + override open var description: String { let dayString = self.textLabel.text ?? " " return "" } @@ -53,7 +53,7 @@ class CalendarDayCell: UICollectionViewCell { } } - override var isSelected : Bool { + override open var isSelected : Bool { didSet { switch isSelected { case true: @@ -88,11 +88,11 @@ class CalendarDayCell: UICollectionViewCell { } - required init?(coder aDecoder: NSCoder) { + required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } - override func layoutSubviews() { + override open func layoutSubviews() { super.layoutSubviews() diff --git a/KDCalendar/CalendarView/CalendarFlowLayout.swift b/KDCalendar/CalendarView/CalendarFlowLayout.swift index 46e3dae..a2738c8 100644 --- a/KDCalendar/CalendarView/CalendarFlowLayout.swift +++ b/KDCalendar/CalendarView/CalendarFlowLayout.swift @@ -25,10 +25,10 @@ import UIKit -class CalendarFlowLayout: UICollectionViewFlowLayout { +open class CalendarFlowLayout: UICollectionViewFlowLayout { - override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { + override open func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { return super.layoutAttributesForElements(in: rect)?.map { attrs in let attrscp = attrs.copy() as! UICollectionViewLayoutAttributes @@ -38,7 +38,7 @@ class CalendarFlowLayout: UICollectionViewFlowLayout { } - override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { + override open func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { if let attrs = super.layoutAttributesForItem(at: indexPath) { let attrscp = attrs.copy() as! UICollectionViewLayoutAttributes diff --git a/KDCalendar/CalendarView/CalendarHeaderView.swift b/KDCalendar/CalendarView/CalendarHeaderView.swift index 35f0c2f..0957596 100644 --- a/KDCalendar/CalendarView/CalendarHeaderView.swift +++ b/KDCalendar/CalendarView/CalendarHeaderView.swift @@ -25,7 +25,7 @@ import UIKit -class CalendarHeaderView: UIView { +open class CalendarHeaderView: UIView { lazy var monthLabel : UILabel = { @@ -64,7 +64,7 @@ class CalendarHeaderView: UIView { }() - override func layoutSubviews() { + override open func layoutSubviews() { super.layoutSubviews() diff --git a/KDCalendar/CalendarView/CalendarView+DataSource.swift b/KDCalendar/CalendarView/CalendarView+DataSource.swift index 6c5db3a..22ab547 100644 --- a/KDCalendar/CalendarView/CalendarView+DataSource.swift +++ b/KDCalendar/CalendarView/CalendarView+DataSource.swift @@ -27,7 +27,7 @@ import UIKit extension CalendarView: UICollectionViewDataSource { - func numberOfSections(in collectionView: UICollectionView) -> Int { + public func numberOfSections(in collectionView: UICollectionView) -> Int { guard let dateSource = self.dataSource else { return 0 } @@ -58,7 +58,7 @@ extension CalendarView: UICollectionViewDataSource { } - internal func getMonthInfo(for date: Date) -> (firstDay: Int, daysTotal: Int)? { + public func getMonthInfo(for date: Date) -> (firstDay: Int, daysTotal: Int)? { var firstWeekdayOfMonthIndex = self.calendar.component(.weekday, from: date) firstWeekdayOfMonthIndex = firstWeekdayOfMonthIndex - 1 // firstWeekdayOfMonthIndex should be 0-Indexed @@ -72,7 +72,7 @@ extension CalendarView: UICollectionViewDataSource { return (firstDay: firstWeekdayOfMonthIndex, daysTotal: numberOfDaysInMonth) } - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { var monthOffsetComponents = DateComponents() monthOffsetComponents.month = section; @@ -88,7 +88,7 @@ extension CalendarView: UICollectionViewDataSource { } - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let dayCell = collectionView.dequeueReusableCell(withReuseIdentifier: cellReuseIdentifier, for: indexPath) as! CalendarDayCell diff --git a/KDCalendar/CalendarView/CalendarView+Delegate.swift b/KDCalendar/CalendarView/CalendarView+Delegate.swift index 8511c49..d726195 100644 --- a/KDCalendar/CalendarView/CalendarView+Delegate.swift +++ b/KDCalendar/CalendarView/CalendarView+Delegate.swift @@ -27,7 +27,7 @@ import UIKit extension CalendarView: UICollectionViewDelegateFlowLayout { - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { guard let date = self.dateFromIndexPath(indexPath) else { return } @@ -52,7 +52,7 @@ extension CalendarView: UICollectionViewDelegateFlowLayout { } - func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { + public func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { guard let dateBeingSelected = self.dateFromIndexPath(indexPath) else { return false } @@ -66,12 +66,12 @@ extension CalendarView: UICollectionViewDelegateFlowLayout { // MARK: UIScrollViewDelegate - func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { + public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { self.updateAndNotifyScrolling() } - func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { + public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { self.updateAndNotifyScrolling() } diff --git a/KDCalendar/CalendarView/CalendarView.swift b/KDCalendar/CalendarView/CalendarView.swift index 39f50ca..1d5d6b2 100644 --- a/KDCalendar/CalendarView/CalendarView.swift +++ b/KDCalendar/CalendarView/CalendarView.swift @@ -73,7 +73,7 @@ extension CalendarViewDelegate { } -class CalendarView: UIView { +open class CalendarView: UIView { struct Style { @@ -156,20 +156,16 @@ class CalendarView: UIView { } } - - - - override init(frame: CGRect) { super.init(frame: frame) self.setup() } - required init?(coder aDecoder: NSCoder) { + required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } - override func awakeFromNib() { + override open func awakeFromNib() { super.awakeFromNib() self.setup() } @@ -212,7 +208,7 @@ class CalendarView: UIView { return self.collectionView.collectionViewLayout as! CalendarFlowLayout } - override func layoutSubviews() { + override open func layoutSubviews() { super.layoutSubviews() diff --git a/KDCalendar/CalendarView/EventsLoader.swift b/KDCalendar/CalendarView/EventsLoader.swift index d004b1e..e0f696e 100644 --- a/KDCalendar/CalendarView/EventsLoader.swift +++ b/KDCalendar/CalendarView/EventsLoader.swift @@ -26,7 +26,7 @@ import Foundation import EventKit -class EventsLoader { +open class EventsLoader { private static let store = EKEventStore()