Permalink
Browse files

Fixes #108 The content height of the event view is used to determine…

… when to stack or split day events.
  • Loading branch information...
devinross committed Mar 20, 2013
1 parent 8cece45 commit 7aa6d0adacaf508d528da135cd6b7b812d1fc232
@@ -24,7 +24,7 @@ - (void) viewDidLoad{
self.data = @[
@[@"Meeting with five random dudes", @"Five Guys", @5, @0, @10, @0],
- @[@"Second ultra mega hypra long text to test again with more", @"", @7, @0, @12, @0],
+ @[@"Unlimited bread rolls got me sprung", @"Olive Garden", @7, @0, @12, @0],
@[@"Appointment", @"Dennys", @15, @0, @18, @0],
@[@"Hamburger Bliss", @"Wendys", @15, @0, @18, @0],
@[@"Fishy Fishy Fishfelayyyyyyyy", @"McDonalds", @5, @30, @6, @0],
@@ -58,5 +58,7 @@
/** The location label for the event. */
@property (nonatomic,strong) UILabel *locationLabel;
+- (CGFloat) contentHeight;
+
@end
@@ -111,6 +111,8 @@ - (void) layoutSubviews{
if(h < 75){
self.titleLabel.frame = CGRectInset(self.bounds, 5, 5);
+ CGFloat y = self.titleLabel.frame.size.height + self.titleLabel.frame.origin.y;
+ self.locationLabel.frame = CGRectMake(self.titleLabel.frame.origin.x, y, 0, 0);
self.locationLabel.hidden = YES;
return;
}
@@ -133,10 +135,27 @@ - (void) layoutSubviews{
r = CGRectIntersection(r, self.bounds);
self.locationLabel.frame = r;
- self.locationLabel.hidden = NO;
+ self.locationLabel.hidden = self.locationLabel.text.length > 0 ? NO : YES;
[self.locationLabel sizeToFit];
}
+- (CGFloat) contentHeight{
+
+ if(!self.locationLabel.hidden && self.locationLabel.text.length > 0)
+ return self.locationLabel.frame.size.height + self.locationLabel.frame.origin.y - 4;
+
+
+
+ if(!self.titleLabel.hidden && self.titleLabel.text.length > 0)
+ return self.titleLabel.frame.size.height + self.titleLabel.frame.origin.y - 4;
+
+
+
+ return 0;
+
+}
+
+
@end
@@ -439,6 +439,8 @@ - (void) _realignEventsAtIndex:(NSInteger)index{
CGFloat startMarker = -100.0f; // starting point to check if they match
CGFloat endMarker = -100.0f;
+ CGFloat startMarkerHeight = 0;
+
CGFloat topOrigin = -1;
for (TKCalendarDayEventView *event in timeline.events) {
@@ -481,7 +483,9 @@ - (void) _realignEventsAtIndex:(NSInteger)index{
// split control - adjusts balloon widths so their times/titles don't overlap
// offset control - adjusts starting balloon position so you can see all starts/ends
- if ((hourStartPosition + minuteStartPosition) - startMarker <= VERTICAL_DIFF/1.5) {
+ NSLog(@"%f - %f - %f %@",(hourStartPosition + minuteStartPosition),startMarker,startMarkerHeight,event.titleLabel.text);
+
+ if ((hourStartPosition + minuteStartPosition) - startMarker - startMarkerHeight < 0) {
repeatNumber++;
} else {
repeatNumber = 0;
@@ -496,14 +500,7 @@ - (void) _realignEventsAtIndex:(NSInteger)index{
}
}
- startMarker = hourStartPosition + minuteStartPosition;
- endMarker = MAX(endMarker,hourEndPosition + minuteEndPosition);
-
- if(topOrigin<0)
- topOrigin = startMarker;
-
- topOrigin = MIN(topOrigin,startMarker);
-
+
@@ -523,15 +520,27 @@ - (void) _realignEventsAtIndex:(NSInteger)index{
[sameTimeEvent setNeedsLayout];
}
[sameTimeEvents addObject:event];
+
+ [event setNeedsLayout];
+
+
+ startMarker = hourStartPosition + minuteStartPosition;
+ endMarker = MAX(endMarker,hourEndPosition + minuteEndPosition);
+
+ if(topOrigin<0)
+ topOrigin = startMarker;
+
+ topOrigin = MIN(topOrigin,startMarker);
+
+ startMarkerHeight = [event contentHeight];
+
}
+
if(topOrigin>0)
timeline.startY = topOrigin;
-
-
-
- if(sv == self.nowLineView.superview){
+ if(sv == self.nowLineView.superview)
[sv bringSubviewToFront:self.nowLineView];
- }
+
}

0 comments on commit 7aa6d0a

Please sign in to comment.