Permalink
Browse files

Return BOOL for selectDate if the date is marked.

  • Loading branch information...
1 parent 32435ff commit fa79b7d90151636d6357392763f4416ca51a6945 @devinross committed Mar 21, 2013
Showing with 16 additions and 18 deletions.
  1. +2 −1 src/TapkuLibrary/TKCalendarMonthView.h
  2. +14 −17 src/TapkuLibrary/TKCalendarMonthView.m
@@ -84,7 +84,7 @@
/** Selects a specific date in the month grid.
@param date The date that will be highlighed.
*/
-- (void) selectDate:(NSDate*)date;
+- (BOOL) selectDate:(NSDate*)date;
/** Reloads the current month grid. */
- (void) reloadData;
@@ -94,6 +94,7 @@
*/
- (void) animateToNextOrPreviousMonth:(BOOL)next;
+
@end
#pragma mark - TKCalendarMonthViewDelegate
@@ -64,14 +64,6 @@ @interface TKCalendarMonthTiles : UIView {
@property (nonatomic,strong) NSDate *monthDate;
@property (nonatomic,strong) NSMutableArray *accessibleElements;
-- (id) initWithMonth:(NSDate*)date marks:(NSArray*)marks startDayOnSunday:(BOOL)sunday timeZone:(NSTimeZone*)timeZone;
-- (void) setTarget:(id)target action:(SEL)action;
-
-- (void) selectDay:(NSInteger)day;
-- (NSDate*) dateSelected;
-
-+ (NSArray*) rangeOfDatesInMonthGrid:(NSDate*)date startOnSunday:(BOOL)sunday timeZone:(NSTimeZone*)timeZone;
-
@property (nonatomic,strong) UIImageView *selectedImageView;
@property (nonatomic,strong) UILabel *currentDay;
@property (nonatomic,strong) UILabel *dot;
@@ -403,7 +395,7 @@ - (void) drawRect:(CGRect)rect {
}
-- (void) selectDay:(NSInteger)day{
+- (BOOL) selectDay:(NSInteger)day{
int pre = firstOfPrev < 0 ? 0 : lastOfPrev - firstOfPrev + 1;
int tot = day + pre;
@@ -415,7 +407,7 @@ - (void) selectDay:(NSInteger)day{
self.currentDay.font = [UIFont boldSystemFontOfSize:DATE_FONT_SIZE];
-
+ BOOL hasDot = NO;
if(day == today){
self.currentDay.shadowOffset = CGSizeMake(0, -1);
@@ -436,9 +428,10 @@ - (void) selectDay:(NSInteger)day{
if (self.marks.count > 0) {
- if([self.marks[row * 7 + column] boolValue])
+ if([self.marks[row * 7 + column] boolValue]){
+ hasDot = YES;
[self.selectedImageView addSubview:self.dot];
- else
+ }else
[self.dot removeFromSuperview];
}else [self.dot removeFromSuperview];
@@ -452,6 +445,8 @@ - (void) selectDay:(NSInteger)day{
[self addSubview:self.selectedImageView];
+ return hasDot;
+
}
- (NSDate*) dateSelected{
if(selectedDay < 1 || selectedPortion != 1) return nil;
@@ -1020,17 +1015,17 @@ - (NSDate*) monthDate{
return [[NSDate date] monthDateWithTimeZone:self.timeZone];
return [self.currentTile monthDate];
}
-- (void) selectDate:(NSDate*)date{
+- (BOOL) selectDate:(NSDate*)date{
NSDateComponents *info = [date dateComponentsWithTimeZone:self.timeZone];
NSDate *month = [date firstOfMonthWithTimeZone:self.timeZone];
+ BOOL ret = NO;
if([month isEqualToDate:[self.currentTile monthDate]]){
- [self.currentTile selectDay:info.day];
- return;
+ ret = [self.currentTile selectDay:info.day];
}else {
if ([self.delegate respondsToSelector:@selector(calendarMonthView:monthShouldChange:animated:)] && ![self.delegate calendarMonthView:self monthShouldChange:month animated:YES])
- return;
+ return NO;
if ([self.delegate respondsToSelector:@selector(calendarMonthView:monthWillChange:animated:)] )
[self.delegate calendarMonthView:self monthWillChange:month animated:YES];
@@ -1046,13 +1041,14 @@ - (void) selectDate:(NSDate*)date{
if([self.delegate respondsToSelector:@selector(calendarMonthView:monthDidChange:animated:)])
[self.delegate calendarMonthView:self monthDidChange:date animated:NO];
- [self.currentTile selectDay:info.day];
+ ret = [self.currentTile selectDay:info.day];
}
if([self.delegate respondsToSelector:@selector(calendarMonthView:didSelectDate:)])
[self.delegate calendarMonthView:self didSelectDate:[self dateSelected]];
+ return ret;
}
- (void) reloadData{
@@ -1076,4 +1072,5 @@ - (void) reloadData{
}
+
@end

0 comments on commit fa79b7d

Please sign in to comment.