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

Indicate the next/previous page with the selete date and mark it(default is 1st). #312

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Example/Example/CustomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ - (void)viewDidLoad

#pragma mark - CalendarManager delegate

- (void)calendar:(JTCalendarManager *)calendar didLoadCalendar:(NSDate *)currentDate {

BOOL isCurrentMonth = [_calendarManager.dateHelper date:currentDate isTheSameMonthThan:[NSDate date]];
if (isCurrentMonth) {
_dateSelected = [NSDate date];
} else {
_dateSelected = [_calendarManager.dateHelper firstDayOfMonth:currentDate];
}
NSLog(@"%s == currentDate = %@", __FUNCTION__, currentDate);

}


// Exemple of implementation of prepareDayView method
// Used to customize the appearance of dayView
- (void)calendar:(JTCalendarManager *)calendar prepareDayView:(JTCalendarDayView *)dayView
Expand Down
7 changes: 7 additions & 0 deletions JTCalendar/JTCalendarDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@
*/
- (void)calendarDidLoadNextPage:(JTCalendarManager *)calendar;


/*!
* Indicate the next/previous page with the selete date and mark it(default is 1st).
*/
- (void)calendar:(JTCalendarManager *)calendar didLoadCalendar:(NSDate *)currentDate;


/*!
* Provide a view conforming to `JTCalendarPage` protocol, used as page for the contentView.
* Return an instance of `JTCalendarPageView` by default.
Expand Down
3 changes: 3 additions & 0 deletions JTCalendar/Managers/JTCalendarDelegateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
- (NSDate *)dateForPreviousPageWithCurrentDate:(NSDate *)currentDate;
- (NSDate *)dateForNextPageWithCurrentDate:(NSDate *)currentDate;

//default is 1st
- (void)didLoadCurrentMonthSeletedDayWithCurrentDate:(NSDate *)currentDate;

// Page view

- (UIView<JTCalendarWeekDay> *)buildWeekDayView;
Expand Down
8 changes: 8 additions & 0 deletions JTCalendar/Managers/JTCalendarDelegateManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ - (NSDate *)dateForNextPageWithCurrentDate:(NSDate *)currentDate
}
}

- (void)didLoadCurrentMonthSeletedDayWithCurrentDate:(NSDate *)currentDate {
NSAssert(currentDate != nil, @"currentDate cannot be nil");

if(_manager.delegate && [_manager.delegate respondsToSelector:@selector(calendar:didLoadCalendar:)]){
[_manager.delegate calendar:self.manager didLoadCalendar:currentDate];
}
}

#pragma mark - Page view

- (UIView<JTCalendarWeekDay> *)buildWeekDayView
Expand Down
2 changes: 2 additions & 0 deletions JTCalendar/Views/JTHorizontalCalendarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ - (void)loadNextPageWithAnimation

- (void)loadPreviousPage
{
[_manager.delegateManager didLoadCurrentMonthSeletedDayWithCurrentDate:_rightView.date];
NSDate *nextDate = [_manager.delegateManager dateForPreviousPageWithCurrentDate:_leftView.date];

// Must be set before chaging date for PageView for updating day views
Expand Down Expand Up @@ -240,6 +241,7 @@ - (void)loadPreviousPage

- (void)loadNextPage
{
[_manager.delegateManager didLoadCurrentMonthSeletedDayWithCurrentDate:_rightView.date];
NSDate *nextDate = [_manager.delegateManager dateForNextPageWithCurrentDate:_rightView.date];

// Must be set before chaging date for PageView for updating day views
Expand Down
2 changes: 2 additions & 0 deletions JTCalendar/Views/JTVerticalCalendarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ - (void)loadNextPageWithAnimation

- (void)loadPreviousPage
{
[_manager.delegateManager didLoadCurrentMonthSeletedDayWithCurrentDate:_rightView.date];
NSDate *nextDate = [_manager.delegateManager dateForPreviousPageWithCurrentDate:_leftView.date];

// Must be set before chaging date for PageView for updating day views
Expand Down Expand Up @@ -240,6 +241,7 @@ - (void)loadPreviousPage

- (void)loadNextPage
{
[_manager.delegateManager didLoadCurrentMonthSeletedDayWithCurrentDate:_rightView.date];
NSDate *nextDate = [_manager.delegateManager dateForNextPageWithCurrentDate:_rightView.date];

// Must be set before chaging date for PageView for updating day views
Expand Down