-
Notifications
You must be signed in to change notification settings - Fork 653
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
Calendar Month Grid: Multiple markers on individual date #199
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,6 +259,9 @@ - (id) initWithMonth:(NSDate*)date marks:(NSArray*)markArray startDayOnSunday:(B | |
|
||
[self.selectedImageView addSubview:self.currentDay]; | ||
[self.selectedImageView addSubview:self.dot]; | ||
if (self.dateSelected) { | ||
self.dot.text = [self stringWithMarks:[[markArray objectAtIndex:[[dates objectAtIndex:0] daysBetweenDate:self.dateSelected]] integerValue]]; | ||
} | ||
self.multipleTouchEnabled = NO; | ||
|
||
|
||
|
@@ -269,6 +272,12 @@ - (void) setTarget:(id)t action:(SEL)a{ | |
action = a; | ||
} | ||
|
||
|
||
- (NSString*)stringWithMarks:(int)marksForDay | ||
{ | ||
return (marksForDay < 5)? [@"••••" substringToIndex:marksForDay] : @"*"; | ||
|
||
} | ||
|
||
- (CGRect) rectForCellAtIndex:(int)index{ | ||
|
||
|
@@ -277,7 +286,7 @@ - (CGRect) rectForCellAtIndex:(int)index{ | |
|
||
return CGRectMake(col*46, row*44+6, 47, 45); | ||
} | ||
- (void) drawTileInRect:(CGRect)r day:(int)day mark:(BOOL)mark font:(UIFont*)f1 font2:(UIFont*)f2{ | ||
- (void) drawTileInRect:(CGRect)r day:(int)day mark:(int)mark font:(UIFont*)f1 font2:(UIFont*)f2{ | ||
|
||
NSString *str = [NSString stringWithFormat:@"%d",day]; | ||
|
||
|
@@ -289,10 +298,12 @@ - (void) drawTileInRect:(CGRect)r day:(int)day mark:(BOOL)mark font:(UIFont*)f1 | |
alignment: UITextAlignmentCenter]; | ||
|
||
if(mark){ | ||
NSString *markString = [self stringWithMarks:mark]; | ||
|
||
r.size.height = 10; | ||
r.origin.y += 18; | ||
[@"•" drawInRect: r | ||
r.origin.y += ([markString isEqualToString:@"*"])? 22 : 18; | ||
[markString drawInRect: r | ||
withFont: f2 | ||
lineBreakMode: UILineBreakModeWordWrap | ||
alignment: UITextAlignmentCenter]; | ||
|
@@ -327,9 +338,9 @@ - (void) drawRect:(CGRect)rect { | |
for(int i = firstOfPrev;i<= lastOfPrev;i++){ | ||
r = [self rectForCellAtIndex:index]; | ||
if ([marks count] > 0) | ||
[self drawTileInRect:r day:i mark:[[marks objectAtIndex:index] boolValue] font:font font2:font2]; | ||
[self drawTileInRect:r day:i mark:[[marks objectAtIndex:index] integerValue] font:font font2:font2]; | ||
else | ||
[self drawTileInRect:r day:i mark:NO font:font font2:font2]; | ||
[self drawTileInRect:r day:i mark:0 font:font font2:font2]; | ||
index++; | ||
} | ||
} | ||
|
@@ -343,9 +354,9 @@ - (void) drawRect:(CGRect)rect { | |
if(today == i) [[UIColor whiteColor] set]; | ||
|
||
if ([marks count] > 0) | ||
[self drawTileInRect:r day:i mark:[[marks objectAtIndex:index] boolValue] font:font font2:font2]; | ||
[self drawTileInRect:r day:i mark:[[marks objectAtIndex:index] integerValue] font:font font2:font2]; | ||
else | ||
[self drawTileInRect:r day:i mark:NO font:font font2:font2]; | ||
[self drawTileInRect:r day:i mark:0 font:font font2:font2]; | ||
if(today == i) [color set]; | ||
index++; | ||
} | ||
|
@@ -355,9 +366,9 @@ - (void) drawRect:(CGRect)rect { | |
while(index % 7 != 0){ | ||
r = [self rectForCellAtIndex:index] ; | ||
if ([marks count] > 0) | ||
[self drawTileInRect:r day:i mark:[[marks objectAtIndex:index] boolValue] font:font font2:font2]; | ||
[self drawTileInRect:r day:i mark:[[marks objectAtIndex:index] integerValue] font:font font2:font2]; | ||
else | ||
[self drawTileInRect:r day:i mark:NO font:font font2:font2]; | ||
[self drawTileInRect:r day:i mark:0 font:font font2:font2]; | ||
i++; | ||
index++; | ||
} | ||
|
@@ -366,7 +377,7 @@ - (void) drawRect:(CGRect)rect { | |
} | ||
|
||
- (void) selectDay:(int)day{ | ||
|
||
int pre = firstOfPrev < 0 ? 0 : lastOfPrev - firstOfPrev + 1; | ||
|
||
int tot = day + pre; | ||
|
@@ -401,6 +412,16 @@ - (void) selectDay:(int)day{ | |
if ([marks count] > 0) { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When using multiple dot's it is probably easier to just leave out the subview and don't remove it when there are 0 dot's to display..
then becomes:
which is quite nice, isn't it ? This can be done in 2 pieces of code (old line numbers 414 & 518) |
||
if([[marks objectAtIndex: row * 7 + column ] boolValue]){ | ||
self.dot.text = [self stringWithMarks:[[marks objectAtIndex:(row*7+column)] integerValue]]; | ||
if ([self.dot.text isEqualToString:@"*"]) { | ||
CGRect r = self.selectedImageView.bounds; | ||
r.origin.y += 17; | ||
self.dot.frame = r; | ||
} else { | ||
CGRect r = self.selectedImageView.bounds; | ||
r.origin.y += 13; | ||
self.dot.frame = r; | ||
} | ||
[self.selectedImageView addSubview:self.dot]; | ||
}else{ | ||
[self.dot removeFromSuperview]; | ||
|
@@ -495,9 +516,19 @@ - (void) reactToTouch:(UITouch*)touch down:(BOOL)down{ | |
self.currentDay.text = [NSString stringWithFormat:@"%d",day]; | ||
|
||
if ([marks count] > 0) { | ||
if([[marks objectAtIndex: row * 7 + column] boolValue]) | ||
if([[marks objectAtIndex: row * 7 + column] boolValue]) { | ||
self.dot.text = [self stringWithMarks:[[marks objectAtIndex:(row*7+column)] integerValue]]; | ||
if ([self.dot.text isEqualToString:@"*"]) { | ||
CGRect r = self.selectedImageView.bounds; | ||
r.origin.y += 17; | ||
self.dot.frame = r; | ||
} else { | ||
CGRect r = self.selectedImageView.bounds; | ||
r.origin.y += 13; | ||
self.dot.frame = r; | ||
} | ||
[self.selectedImageView addSubview:self.dot]; | ||
else | ||
} else | ||
[self.dot removeFromSuperview]; | ||
}else{ | ||
[self.dot removeFromSuperview]; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those additions are not necessary, the right dot's will always been set in the
drawTileInRect
method