-
Notifications
You must be signed in to change notification settings - Fork 2
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
Blackout #1
base: master
Are you sure you want to change the base?
Blackout #1
Changes from 4 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)
} 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? 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 | ||
}() | ||
|
||
|
@@ -118,6 +118,17 @@ public class CalendarView: UIView { | |
return calFlowLayout | ||
} | ||
|
||
// var startOfMonth = { | ||
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. No longer needed? Can a shim be used for backwards compatibility? |
||
// let startDate = dataSource?.startDate() | ||
// | ||
// var firstDayOfStartMonthComponents = self.calendar.dateComponents([.era, .year, .month], from: startDate) | ||
// firstDayOfStartMonthComponents.day = 1 | ||
// | ||
// let firstDayOfStartMonthDate = self.calendar.date(from: firstDayOfStartMonthComponents)! | ||
// | ||
// self.startOfMonthCache = firstDayOfStartMonthDate | ||
// } | ||
|
||
// MARK: - public | ||
|
||
public var displayDate: Date? | ||
|
@@ -329,8 +340,10 @@ 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 } | ||
print("startOfMonthCache = \(startOfMonthCache)") | ||
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. stray print statements |
||
print("endDateCache = \(endDateCache)") | ||
guard (date >= startOfMonthCache) && (date <= endDateCache) else { return } | ||
print("in range") | ||
self.collectionView.setContentOffset(self.scrollViewOffset(for: date), animated: animated) | ||
self.displayDateOnHeader(date) | ||
} | ||
|
@@ -372,6 +385,21 @@ extension CalendarView { | |
goToMonthWithOffet(1) | ||
} | ||
|
||
public func isLastMonth() -> Bool { | ||
var dateComponents = DateComponents() | ||
dateComponents.month = 1 | ||
print("isLastMonth") | ||
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. stray print statements |
||
guard let displayDate = self.displayDate else { return true } | ||
print("has display date") | ||
guard let newDate = self.calendar.date(byAdding: dateComponents, to: displayDate) else { return true } | ||
print("able to test next month") | ||
if newDate <= endDateCache { | ||
return false | ||
} else { | ||
return true | ||
} | ||
} | ||
|
||
/* | ||
method: - goToPreviousMonth | ||
function: - scroll the calendar by one month in the past | ||
|
@@ -380,6 +408,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
isWeekend
to give us our blackout behavior, and this is actually un-doing that.isWeekend
should be back to normal now, and un-used by our app. We set.marksWeekends
to false now.