Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
wanggang316 committed Jul 5, 2016
2 parents 3d885ec + 3e48023 commit 8d46079
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 55 deletions.
2 changes: 1 addition & 1 deletion ZBJCalendar.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "ZBJCalendar"
s.version = "0.0.2"
s.version = "0.0.3"
s.summary = "ZBJCalendar is a simple calendar framework."

s.homepage = "https://github.com/wanggang316/ZBJCalendar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ - (id)initWithFrame:(CGRect)frame {

- (void)layoutSubviews {
[super layoutSubviews];
self.monthLabel.frame = CGRectMake(0, 0, CGRectGetWidth(self.monthLabel.frame), 20);
self.monthLabel.center = CGPointMake(25 * ((self.weekday - 1) * 2 + 1), CGRectGetHeight(self.frame) / 2);
self.monthLabel.frame = CGRectMake(10, (CGRectGetHeight(self.frame) - 20) / 2, CGRectGetWidth(self.monthLabel.frame), 20);
}

#pragma mark - events
Expand All @@ -48,8 +47,7 @@ - (void)setFirstDateOfMonth:(NSDate *)firstDateOfMonth {
_firstDateOfMonth = firstDateOfMonth;
NSCalendar *calendar = [NSDate gregorianCalendar];
NSDateComponents *components = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitWeekday fromDate:firstDateOfMonth];
self.weekday = components.weekday;
self.monthLabel.text = [NSString stringWithFormat:@"%ld", components.month];
self.monthLabel.text = [NSString stringWithFormat:@"%ld%ld", components.month, components.year];
[self.monthLabel sizeToFit];
[self layoutSubviews];
}
Expand All @@ -59,9 +57,10 @@ - (void)setFirstDateOfMonth:(NSDate *)firstDateOfMonth {
- (UILabel *)monthLabel {
if (!_monthLabel) {
_monthLabel = [[UILabel alloc] init];
_monthLabel.font = [UIFont systemFontOfSize:17];
_monthLabel.textColor = [UIColor darkTextColor];
_monthLabel.font = [UIFont systemFontOfSize:18];
_monthLabel.textColor = [UIColor grayColor];
}
return _monthLabel;
}

@end
37 changes: 4 additions & 33 deletions ZBJCalendar/MutipleSelection/ZBJSimpleMutipleSelectionCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,74 +54,45 @@ - (void)setCellState:(ZBJCalendarCellState)cellState {

switch (_cellState) {
case ZBJCalendarCellStateEmpty: {

self.backView.image = nil;
self.dateLabel.text = nil;

self.dateLabel.textColor = [UIColor whiteColor];

break;
}
case ZBJCalendarCellStateDisabled: {

self.backView.image = nil;
self.dateLabel.textColor = [UIColor lightGrayColor];

break;
}
case ZBJCalendarCellStateNormal: {

self.backView.image = nil;
if ([self.date isToday]) {
self.dateLabel.textColor = [UIColor colorWithRed:255.0/255.0 green:60.0/255.0 blue:57.0/255.0 alpha:1.0];
} else {
self.dateLabel.textColor = [UIColor darkTextColor];
}

break;
}
case ZBJCalendarCellStateSelected: {
self.dateLabel.textColor = [UIColor whiteColor];

self.backView.image = [UIImage imageNamed:@"selected"];

if ([self.date isToday]) {
} else {
}
self.backView.image = [UIImage imageNamed:@"cal_selected"];
break;
}
case ZBJCalendarCellStateSelectedLeft: {

self.dateLabel.textColor = [UIColor whiteColor];
self.backView.image = [UIImage imageNamed:@"left"];

if ([self.date isToday]) {
} else {
}
self.backView.image = [UIImage imageNamed:@"cal_selected_left"];

break;
}
case ZBJCalendarCellStateSelectedRight: {

self.dateLabel.textColor = [UIColor whiteColor];
self.backView.image = [UIImage imageNamed:@"right"];

if ([self.date isToday]) {
} else {
}

self.backView.image = [UIImage imageNamed:@"cal_selected_right"];
break;
}
case ZBJCalendarCellStateSelectedMiddle: {

self.dateLabel.textColor = [UIColor whiteColor];
self.backView.image = [UIImage imageNamed:@"middle"];

if ([self.date isToday]) {
self.dateLabel.backgroundColor = [UIColor colorWithRed:255.0/255.0 green:60.0/255.0 blue:57.0/255.0 alpha:1.0];
} else {
}

self.backView.image = [UIImage imageNamed:@"cal_selected_middle"];
break;
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ - (void)addDateFromMonth:(NSDate *)month {
}
} else {
[self.selectedMonths addObject:month];
NSDateComponents *todayComponents = [calendar components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear fromDate:[NSDate date]];
NSDate *today = [calendar dateFromComponents:todayComponents];
for (int i = 1; i <= count; i++) {
components.day = i;
NSDate *date = [calendar dateFromComponents:components];
[self.selectedDates addObject:date];
if ([date compare:today] != NSOrderedAscending) {
[self.selectedDates addObject:date];
}
}
}
}
Expand Down Expand Up @@ -121,7 +125,9 @@ - (void)calendarView:(ZBJCalendarView *)calendarView configureSectionHeaderView:
__weak ZBJSimpleMutipleSelectionViewController *me = self;
headerView.tapHandler = ^(NSDate *month) {
[me addDateFromMonth:month];
[me.calendarView reloadItemsAtMonths:[NSMutableSet setWithObjects:month, nil]];
[me setSelectedTypes];
[me.calendarView reloadData];
NSLog(@"selected dates is : %@", self.selectedDates);
};
}

Expand Down Expand Up @@ -152,7 +158,6 @@ - (void)calendarView:(ZBJCalendarView *)calendarView didSelectDate:(NSDate *)dat
}

[self setSelectedTypes];
// [calendarView reloadItemsAtDates:[NSMutableSet setWithObjects:date, nil]];
[calendarView reloadData];
NSLog(@"selected dates is : %@", self.selectedDates);
}
Expand All @@ -175,13 +180,13 @@ - (void)setSelectedTypes {
BOOL containsPreDate = [self.selectedDates containsObject:preDate];

if (containsNextDate && containsPreDate) {
self.selectedTypes[date] = @5;
self.selectedTypes[date] = @(ZBJCalendarCellStateSelectedMiddle);
} else if (containsNextDate) {
self.selectedTypes[date] = @4;
self.selectedTypes[date] = @(ZBJCalendarCellStateSelectedLeft);
} else if (containsPreDate) {
self.selectedTypes[date] = @6;
self.selectedTypes[date] = @(ZBJCalendarCellStateSelectedRight);
} else {
self.selectedTypes[date] = @3;
self.selectedTypes[date] = @(ZBJCalendarCellStateSelected);
}
}
}
Expand All @@ -199,7 +204,7 @@ - (ZBJCalendarView *)calendarView {
_calendarView.backgroundColor = [UIColor whiteColor];
_calendarView.contentInsets = UIEdgeInsetsMake(0, 12.5, 0, 12.5);
_calendarView.cellScale = 1;
_calendarView.sectionHeaderHeight = 27;
_calendarView.sectionHeaderHeight = 50;
_calendarView.weekViewHeight = 20;
_calendarView.weekView.backgroundColor = [UIColor colorWithRed:249.0f/255.0f green:249.0f/255.0f blue:249.0f/255.0f alpha:1.0];
}
Expand Down
9 changes: 2 additions & 7 deletions ZBJCalendar/ZBJCalendar/ZBJCalendarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ - (void)layoutSubviews {
self.contentInsets = inset;
}
self.collectionView.contentInset = self.contentInsets;
self.collectionView.scrollIndicatorInsets = UIEdgeInsetsMake(self.contentInsets.top, 0, self.contentInsets.bottom, 0);
self.weekView.contentInsets = self.contentInsets;

UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;

Expand Down Expand Up @@ -99,13 +101,6 @@ - (void)registerSectionFooter:(id)clazz withReuseIdentifier:(NSString *)identifi
[self.collectionView registerClass:clazz forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:identifier];
}

- (void)setContentInsets:(UIEdgeInsets)contentInsets {
_contentInsets = contentInsets;
self.weekView.contentInsets = _contentInsets;
self.collectionView.contentInset = _contentInsets;
self.collectionView.scrollIndicatorInsets = UIEdgeInsetsMake(_contentInsets.top, 0, _contentInsets.bottom, 0);
}

- (void)setWeekViewHeight:(CGFloat)weekViewHeight {
_weekViewHeight = weekViewHeight;
self.weekView.frame = CGRectMake(0, 0, CGRectGetWidth(self.frame), _weekViewHeight);
Expand Down

0 comments on commit 8d46079

Please sign in to comment.