diff --git a/JTAppleCalendar.podspec b/JTAppleCalendar.podspec index 1cb6da5c..3834a9d6 100644 --- a/JTAppleCalendar.podspec +++ b/JTAppleCalendar.podspec @@ -1,16 +1,16 @@ Pod::Spec.new do |s| - s.name = "JTAppleCalendar" - s.version = "8.0.3" + s.name = "JTAppleCalendarGreenRoad" + s.version = "1.0.0" s.summary = "The Unofficial Swift Apple Calendar Library. View. Control. for iOS & tvOS" s.description = <<-DESC A highly configurable Apple calendar control. Contains features like boundary dates, month and week view. Very light weight. DESC - s.homepage = "https://patchthecode.com" + s.homepage = "https://github.com/alexvaiman/" # s.screenshots = "https://patchthecode.github.io/" s.license = 'MIT' s.author = { "JayT" => "patchthecode@gmail.com" } - s.source = { :git => "https://github.com/patchthecode/JTAppleCalendar.git", :tag => s.version.to_s } + s.source = { :git => "https://github.com/alexvaiman/JTAppleCalendar.git", :tag => s.version.to_s } s.swift_version = '5' @@ -18,5 +18,4 @@ A highly configurable Apple calendar control. Contains features like boundary da s.tvos.deployment_target = '10.0' s.source_files = 'Sources/JTAppleCalendar/*.swift' -end - +end \ No newline at end of file diff --git a/Sources/JTAppleCalendar/JTACInteractionMonthFunctions.swift b/Sources/JTAppleCalendar/JTACInteractionMonthFunctions.swift index 43a1cf31..0c5f0ba0 100644 --- a/Sources/JTAppleCalendar/JTACInteractionMonthFunctions.swift +++ b/Sources/JTAppleCalendar/JTACInteractionMonthFunctions.swift @@ -26,6 +26,20 @@ import UIKit extension JTACMonthView { + /// Returns the cellStatus of a date that is visible on the screen. + /// If the point does not correspond to existing indexPath cell, + /// then nil is returned + /// Parameter: point of the cell you want to find + /// - returns: + /// - CellState: The state of the found cell + public func cellStatusForDate(at point: CGPoint) -> CellState? { + guard let indexPath = indexPathForItem(at: point) else { + return nil + } + + return cellStatusForDate(at: indexPath.item / maxNumberOfDaysInWeek , column: indexPath.item % maxNumberOfDaysInWeek) + } + /// Returns the cellStatus of a date that is visible on the screen. /// If the row and column for the date cannot be found, /// then nil is returned @@ -104,10 +118,26 @@ extension JTACMonthView { /// - returns: /// - CellState: The state of the found cell public func cellStatus(at point: CGPoint) -> CellState? { - if let indexPath = indexPathForItem(at: point) { - let cell = cellForItem(at: indexPath) as? JTACDayCell - return cellStateFromIndexPath(indexPath, cell: cell) + guard let indexPath = indexPathForItem(at: point) else { + return nil + } + + guard let section = currentSection() else { + return nil } + + let i = indexPath.item + let row = i / maxNumberOfDaysInWeek + let column = i % maxNumberOfDaysInWeek + let convertedRow = (row * maxNumberOfDaysInWeek) + column + let indexPathToFind = IndexPath(item: convertedRow, section: section) + + if let date = dateOwnerInfoFromPath(indexPathToFind) { + let cell = cellForItem(at: indexPathToFind) as? JTACDayCell + let stateOfCell = cellStateFromIndexPath(indexPathToFind, withDateInfo: date,cell: cell) + return stateOfCell + } + return nil } diff --git a/Sources/JTAppleCalendar/JTACMonthViewProtocols.swift b/Sources/JTAppleCalendar/JTACMonthViewProtocols.swift index d65df022..f3b40d3a 100644 --- a/Sources/JTAppleCalendar/JTACMonthViewProtocols.swift +++ b/Sources/JTAppleCalendar/JTACMonthViewProtocols.swift @@ -138,6 +138,9 @@ public protocol JTACMonthViewDelegate: class { /// Informs the delegate that the user just lifted their finger from swiping the calendar func scrollDidEndDecelerating(for calendar: JTACMonthView) + /// Informs the delegate that the scrolling animation concludes + func scrollDidEndScrollingAnimation(for calendar: JTACMonthView) + /// Tells the delegate that a scroll occured func calendarDidScroll(_ calendar: JTACMonthView) @@ -178,4 +181,5 @@ public extension JTACMonthViewDelegate { func calendarSizeForMonths(_ calendar: JTACMonthView?) -> MonthSize? { return nil } func sizeOfDecorationView(indexPath: IndexPath) -> CGRect { return .zero } func scrollDidEndDecelerating(for calendar: JTACMonthView) {} + func scrollDidEndScrollingAnimation(for calendar: JTACMonthView) {} } diff --git a/Sources/JTAppleCalendar/JTACScrollViewDelegates.swift b/Sources/JTAppleCalendar/JTACScrollViewDelegates.swift index ec2d7290..77f50568 100644 --- a/Sources/JTAppleCalendar/JTACScrollViewDelegates.swift +++ b/Sources/JTAppleCalendar/JTACScrollViewDelegates.swift @@ -197,6 +197,7 @@ extension JTACMonthView: UIScrollViewDelegate { DispatchQueue.main.async { // https://github.com/patchthecode/JTAppleCalendar/issues/778 self.executeDelayedTasks(.scroll) + self.calendarDelegate?.scrollDidEndScrollingAnimation(for: self) } }