Skip to content

Commit

Permalink
Fix for ruslanskorb#48, allow limiting dates in the calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaxt committed Jun 29, 2015
1 parent d2d6c14 commit 7b32c20
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 88 deletions.
2 changes: 1 addition & 1 deletion Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ SPEC CHECKSUMS:
OCMock: a6a7dc0e3997fb9f35d99f72528698ebf60d64f2
Specta: a353759f073ffcc0a365b782fe4aaeac064c03c6

COCOAPODS: 0.36.3
COCOAPODS: 0.37.2
12 changes: 12 additions & 0 deletions RSDayFlow/RSDFDatePickerDayCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
*/
@property (nonatomic, getter = isMarked) BOOL marked;

/**
A Boolean value that determines whether the cell is enabled or not.
*/
@property (nonatomic, getter = isDisabled) BOOL disabled;

/**
The color of the default mark image for the cell of the day. Default value is [UIColor colorWithRed:184/255.0f green:184/255.0f blue:184/255.0f alpha:1.0f].
Expand Down Expand Up @@ -124,6 +129,13 @@
*/
- (UIColor *)dayOffLabelTextColor;

/**
The text color for the label of the disabled day (not in range of start/end date set on calendar). Default value is [UIColor colorWithRed:184/255.0f green:184/255.0f blue:184/255.0f alpha:1.0f].
@discussion Can be overridden in subclasses for customization.
*/
- (UIColor *)disabledDayLabelTextColor;

/**
The text color for the label of the day that's not this month. Default value is [UIColor clearColor].
Expand Down
100 changes: 57 additions & 43 deletions RSDayFlow/RSDFDatePickerDayCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,49 +213,58 @@ - (void)updateSubviews
self.overlayImageView.hidden = !self.isHighlighted || self.isNotThisMonth;
self.markImageView.hidden = !self.isMarked || self.isNotThisMonth;
self.dividerImageView.hidden = self.isNotThisMonth;

if (self.isNotThisMonth) {
self.dateLabel.textColor = [self notThisMonthLabelTextColor];
self.dateLabel.font = [self dayLabelFont];
} else {
if (!self.isSelected) {
if (!self.isToday) {
self.dateLabel.font = [self dayLabelFont];
if (!self.dayOff) {
if (self.isPastDate) {
self.dateLabel.textColor = [self pastDayLabelTextColor];
} else {
self.dateLabel.textColor = [self dayLabelTextColor];
}
} else {
if (self.isPastDate) {
self.dateLabel.textColor = [self pastDayOffLabelTextColor];
} else {
self.dateLabel.textColor = [self dayOffLabelTextColor];
}
}
} else {
self.dateLabel.font = [self todayLabelFont];
self.dateLabel.textColor = [self todayLabelTextColor];
}
} else {
if (!self.isToday) {
self.dateLabel.font = [self selectedDayLabelFont];
self.dateLabel.textColor = [self selectedDayLabelTextColor];
self.selectedDayImageView.image = [self selectedDayImage];
} else {
self.dateLabel.font = [self selectedTodayLabelFont];
self.dateLabel.textColor = [self selectedTodayLabelTextColor];
self.selectedDayImageView.image = [self selectedTodayImage];
}
}

if (self.marked) {
self.markImageView.image = self.markImage;
} else {
self.markImageView.image = nil;
}
}
self.userInteractionEnabled = YES;

if (self.isNotThisMonth) {
self.dateLabel.textColor = [self notThisMonthLabelTextColor];
self.dateLabel.font = [self dayLabelFont];
} else {
if (self.disabled) {
self.userInteractionEnabled = NO;
self.dateLabel.textColor = [self disabledDayLabelTextColor];
}
else {
if (!self.isSelected) {
if (!self.isToday) {
self.dateLabel.font = [self dayLabelFont];
if (!self.dayOff) {
if (self.isPastDate) {
self.dateLabel.textColor = [self pastDayLabelTextColor];
} else {
self.dateLabel.textColor = [self dayLabelTextColor];
}
} else {
if (self.isPastDate) {
self.dateLabel.textColor = [self pastDayOffLabelTextColor];
} else {
self.dateLabel.textColor = [self dayOffLabelTextColor];
}
}
} else {
self.dateLabel.font = [self todayLabelFont];
self.dateLabel.textColor = [self todayLabelTextColor];
}

} else {
if (!self.isToday) {
self.dateLabel.font = [self selectedDayLabelFont];
self.dateLabel.textColor = [self selectedDayLabelTextColor];
self.selectedDayImageView.image = [self selectedDayImage];
} else {
self.dateLabel.font = [self selectedTodayLabelFont];
self.dateLabel.textColor = [self selectedTodayLabelTextColor];
self.selectedDayImageView.image = [self selectedTodayImage];
}
}

if (self.marked) {
self.markImageView.image = self.markImage;
} else {
self.markImageView.image = nil;
}
}
}

}

+ (NSCache *)imageCache
Expand Down Expand Up @@ -339,6 +348,11 @@ - (UIColor *)dayOffLabelTextColor
return [UIColor colorWithRed:184/255.0f green:184/255.0f blue:184/255.0f alpha:1.0f];
}

- (UIColor *)disabledDayLabelTextColor
{
return [UIColor colorWithRed:184/255.0f green:184/255.0f blue:184/255.0f alpha:1.0f];
}

- (UIColor *)notThisMonthLabelTextColor
{
return [UIColor clearColor];
Expand Down
11 changes: 11 additions & 0 deletions RSDayFlow/RSDFDatePickerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@
*/
- (instancetype)initWithFrame:(CGRect)frame calendar:(NSCalendar *)calendar;


/**
Designated initializer. Initializes and returns a newly allocated view object with the specified frame rectangle and the specified calendar.
@param frame The frame rectangle for the view, measured in points.
@param calendar The calendar for the date picker view.
@param startDate First selectable date
@param endDate Last selectable date
*/
- (instancetype)initWithFrame:(CGRect)frame calendar:(NSCalendar *)calendar startDate:(NSDate *)startDate endDate:(NSDate *)endDate;

///-----------------------------
/// @name Accessing the Delegate
///-----------------------------
Expand Down

0 comments on commit 7b32c20

Please sign in to comment.