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

Calendar Month Grid: Multiple markers on individual date #199

Closed
wants to merge 1 commit into from
Closed

Calendar Month Grid: Multiple markers on individual date #199

wants to merge 1 commit into from

Conversation

charliermarsh
Copy link

Devin,

Thanks for creating such a useful library. My app required the ability to add multiple markers on an individual date, so I thought I'd send a pull request with that (minimal) change. Specifically, the user is now required to provide an NSArray of integers (rather than bools) for the TKCalendarMonthView data source--each integer specifies the number of markers to appear on the day. Much of the existing code required no changes (as reading the NSNumber as a bool will work even if you stored integers, e.g. 0 is read as false -> no marks).

One quick note: if the user enters a number > 4, the calendar displays a star (*) rather than a dot (•).

Thanks!

-Charlie

@@ -401,6 +412,16 @@ - (void) selectDay:(int)day{
if ([marks count] > 0) {

Copy link

Choose a reason for hiding this comment

The 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..

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];
}

then becomes:

    self.dot.text = [self stringWithMarks:[[marks objectAtIndex:(row*7+column)] integerValue]];

which is quite nice, isn't it ?

This can be done in 2 pieces of code (old line numbers 414 & 518)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants