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

fillColor delegate method for unselected dates (cells) #258

Merged
merged 3 commits into from
Apr 8, 2016
Merged
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
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