Skip to content
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

Making it easier to track the visible start and end dates of a calendar page. #348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions JTCalendar/Protocols/JTCalendarPage.h
Expand Up @@ -16,6 +16,9 @@
- (NSDate *)date;
- (void)setDate:(NSDate *)date;

- (NSDate *)startDate;
- (NSDate *)endDate;

- (void)reload;

@end
3 changes: 3 additions & 0 deletions JTCalendar/Protocols/JTContent.h
Expand Up @@ -16,6 +16,9 @@
- (NSDate *)date;
- (void)setDate:(NSDate *)date;

- (NSDate *)visibleStartDate;
- (NSDate *)visibleEndDate;

- (void)loadPreviousPage;
- (void)loadNextPage;

Expand Down
3 changes: 3 additions & 0 deletions JTCalendar/Views/JTCalendarPageView.h
Expand Up @@ -13,6 +13,9 @@

@property (nonatomic, weak) JTCalendarManager *manager;

@property (nonatomic, readonly) NSDate *startDate;
@property (nonatomic, readonly) NSDate *endDate;

@property (nonatomic) NSDate *date;

/*!
Expand Down
4 changes: 4 additions & 0 deletions JTCalendar/Views/JTCalendarPageView.m
Expand Up @@ -96,6 +96,8 @@ - (void)reload
weekDate = [_manager.dateHelper firstWeekDayOfMonth:_date];
}

_startDate = weekDate;

for(NSUInteger i = 0; i < _numberOfWeeksDisplayed; i++){
UIView<JTCalendarWeek> *weekView = _weeksViews[i];

Expand All @@ -112,6 +114,8 @@ - (void)reload
weekDate = [_manager.dateHelper addToDate:weekDate weeks:1];
}

_endDate = [_manager.dateHelper addToDate:weekDate days:-1];

for(NSUInteger i = _numberOfWeeksDisplayed; i < MAX_WEEKS_BY_MONTH; i++){
UIView<JTCalendarWeek> *weekView = _weeksViews[i];

Expand Down
2 changes: 2 additions & 0 deletions JTCalendar/Views/JTHorizontalCalendarView.h
Expand Up @@ -14,6 +14,8 @@
@property (nonatomic, weak) JTCalendarManager *manager;

@property (nonatomic) NSDate *date;
@property (nonatomic, readonly) NSDate *visibleStartDate;
@property (nonatomic, readonly) NSDate *visibleEndDate;

/*!
* Must be call if override the class
Expand Down
8 changes: 8 additions & 0 deletions JTCalendar/Views/JTHorizontalCalendarView.m
Expand Up @@ -349,6 +349,14 @@ - (void)setDate:(NSDate *)date
[self repositionViews];
}

- (NSDate *)visibleStartDate {
return _centerView.startDate;
}

- (NSDate *)visibleEndDate {
return _centerView.endDate;
}

- (void)setManager:(JTCalendarManager *)manager
{
self->_manager = manager;
Expand Down
2 changes: 2 additions & 0 deletions JTCalendar/Views/JTVerticalCalendarView.h
Expand Up @@ -14,6 +14,8 @@
@property (nonatomic, weak) JTCalendarManager *manager;

@property (nonatomic) NSDate *date;
@property (nonatomic, readonly) NSDate *visibleStartDate;
@property (nonatomic, readonly) NSDate *visibleEndDate;

/*!
* Must be call if override the class
Expand Down
8 changes: 8 additions & 0 deletions JTCalendar/Views/JTVerticalCalendarView.m
Expand Up @@ -349,6 +349,14 @@ - (void)setDate:(NSDate *)date
[self repositionViews];
}

- (NSDate *)visibleStartDate {
return _centerView.startDate;
}

- (NSDate *)visibleEndDate {
return _centerView.endDate;
}

- (void)setManager:(JTCalendarManager *)manager
{
self->_manager = manager;
Expand Down