-
Notifications
You must be signed in to change notification settings - Fork 2
Blackout #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Blackout #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,11 +32,10 @@ extension CalendarView: UICollectionViewDelegateFlowLayout { | |
| guard let date = self.dateFromIndexPath(indexPath) else { return } | ||
|
|
||
| if let index = selectedIndexPaths.index(of: indexPath) { | ||
|
|
||
| delegate?.calendar(self, didDeselectDate: date) | ||
|
|
||
| selectedIndexPaths.remove(at: index) | ||
| selectedDates.remove(at: index) | ||
| // We want to prevent deselecting ship date | ||
| // delegate?.calendar(self, didDeselectDate: date) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could make this more mergeable with another delegate method: if delegate?.calendar(self, canDeselectDate: date) ?? false {
delegate?.calendar(self, didDeselectDate: date)
selectedIndexPaths.remove(at: index)
selectedDates.remove(at: index)
}
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another "too big of a refactor" where I think the correct generalization would be a |
||
| // selectedIndexPaths.remove(at: index) | ||
| // selectedDates.remove(at: index) | ||
|
|
||
| } else { | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,7 +81,7 @@ public class CalendarView: UIView { | |
|
|
||
| public lazy var calendar: Calendar = { | ||
| var gregorian = Calendar(identifier: .gregorian) | ||
| gregorian.timeZone = TimeZone(abbreviation: "UTC")! | ||
| //gregorian.timeZone = TimeZone(abbreviation: "UTC")! | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the Calendar should always be in the user's current time zone?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be in the timezone of the shipping facility, if known, but this fixes an off-by-one error since it handles day-dates as "midnight". There is a lot of clean-up that could improve this, but it'd be a large refactor on the pod. |
||
| return gregorian | ||
| }() | ||
|
|
||
|
|
@@ -329,8 +329,7 @@ extension CalendarView { | |
| function: - scroll calendar at date (month/year) passed as parameter. | ||
| */ | ||
| public func setDisplayDate(_ date: Date, animated: Bool = false) { | ||
|
|
||
| guard (date >= startDateCache) && (date <= endDateCache) else { return } | ||
| guard (date >= startOfMonthCache) && (date <= endDateCache) else { return } | ||
| self.collectionView.setContentOffset(self.scrollViewOffset(for: date), animated: animated) | ||
| self.displayDateOnHeader(date) | ||
| } | ||
|
|
@@ -372,6 +371,18 @@ extension CalendarView { | |
| goToMonthWithOffet(1) | ||
| } | ||
|
|
||
| public func isLastMonth() -> Bool { | ||
| var dateComponents = DateComponents() | ||
| dateComponents.month = 1 | ||
| guard let displayDate = self.displayDate else { return true } | ||
| guard let newDate = self.calendar.date(byAdding: dateComponents, to: displayDate) else { return true } | ||
| if newDate <= endDateCache { | ||
| return false | ||
| } else { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| method: - goToPreviousMonth | ||
| function: - scroll the calendar by one month in the past | ||
|
|
@@ -380,6 +391,18 @@ extension CalendarView { | |
| goToMonthWithOffet(-1) | ||
| } | ||
|
|
||
| public func isFirstMonth() -> Bool { | ||
| var dateComponents = DateComponents() | ||
| dateComponents.month = -1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My favorite month of the year is |
||
| guard let displayDate = self.displayDate else { return true } | ||
| guard let newDate = self.calendar.date(byAdding: dateComponents, to: displayDate) else { return true } | ||
| if newDate >= startOfMonthCache { | ||
| return false | ||
| } else { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| public func loadEvents(onComplete: ((Error?) -> Void)? = nil) { | ||
|
|
||
| EventsManager.load(from: self.startDateCache, to: self.endDateCache) { // (events:[CalendarEvent]?) in | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to add backwards compatibility for
isWeekend?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was originally trying to re-purpose
isWeekendto give us our blackout behavior, and this is actually un-doing that.isWeekendshould be back to normal now, and un-used by our app. We set.marksWeekendsto false now.