Skip to content

Commit

Permalink
Merge pull request #258 from sochalewski/master
Browse files Browse the repository at this point in the history
fillColor delegate method for unselected dates (cells)
  • Loading branch information
WenchaoD committed Apr 8, 2016
2 parents d55e443 + ba2c8f7 commit 8b17ec9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions FSCalendar/FSCalendar.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (nullable UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance selectionColorForDate:(NSDate *)date;

/**
* Asks the delegate for a fill color in unselected state for the specific date.
*/
- (nullable UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance fillColorForDate:(NSDate *)date;

/**
* Asks the delegate for day text color in unselected state for the specific date.
*/
Expand Down
10 changes: 10 additions & 0 deletions FSCalendar/FSCalendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,7 @@ - (void)invalidateHeaders
- (void)invalidateAppearanceForCell:(FSCalendarCell *)cell
{
cell.preferredSelectionColor = [self preferredSelectionColorForDate:cell.date];
cell.preferredFillColor = [self preferredFillColorForDate:cell.date];
cell.preferredTitleDefaultColor = [self preferredTitleDefaultColorForDate:cell.date];
cell.preferredTitleSelectionColor = [self preferredTitleSelectionColorForDate:cell.date];
if (cell.subtitle) {
Expand Down Expand Up @@ -1701,6 +1702,15 @@ - (UIColor *)preferredSelectionColorForDate:(NSDate *)date
return nil;
}

- (UIColor *)preferredFillColorForDate:(NSDate *)date
{
if (self.delegateAppearance && [self.delegateAppearance respondsToSelector:@selector(calendar:appearance:fillColorForDate:)]) {
UIColor *color = [self.delegateAppearance calendar:self appearance:self.appearance fillColorForDate:date];
return color;
}
return nil;
}

- (UIColor *)preferredTitleDefaultColorForDate:(NSDate *)date
{
if (self.delegateAppearance && [self.delegateAppearance respondsToSelector:@selector(calendar:appearance:titleDefaultColorForDate:)]) {
Expand Down
1 change: 1 addition & 0 deletions FSCalendar/FSCalendarCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@property (readonly, nonatomic) BOOL weekend;

@property (strong, nonatomic) UIColor *preferredSelectionColor;
@property (strong, nonatomic) UIColor *preferredFillColor;
@property (strong, nonatomic) UIColor *preferredTitleDefaultColor;
@property (strong, nonatomic) UIColor *preferredTitleSelectionColor;
@property (strong, nonatomic) UIColor *preferredSubtitleDefaultColor;
Expand Down
7 changes: 5 additions & 2 deletions FSCalendar/FSCalendarCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ - (void)configureCell
}

UIColor *borderColor = self.colorForCellBorder;
BOOL shouldHiddenBackgroundLayer = !self.selected && !self.dateIsToday && !self.dateIsSelected && !borderColor;
UIColor *fillColor = self.colorForBackgroundLayer;

BOOL shouldHiddenBackgroundLayer = !self.selected && !self.dateIsToday && !self.dateIsSelected && !borderColor && !fillColor;

if (_backgroundLayer.hidden != shouldHiddenBackgroundLayer) {
_backgroundLayer.hidden = shouldHiddenBackgroundLayer;
Expand Down Expand Up @@ -304,8 +306,9 @@ - (UIColor *)colorForBackgroundLayer
{
if (self.dateIsSelected || self.isSelected) {
return self.preferredSelectionColor ?: [self colorForCurrentStateInDictionary:_appearance.backgroundColors];
} else {
return self.preferredFillColor ?: [self colorForCurrentStateInDictionary:_appearance.backgroundColors];
}
return [self colorForCurrentStateInDictionary:_appearance.backgroundColors];
}

- (UIColor *)colorForTitleLabel
Expand Down

1 comment on commit 8b17ec9

@SuEric
Copy link

@SuEric SuEric commented on 8b17ec9 Apr 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will this be updated to Pod version?

Please sign in to comment.