Skip to content

Commit

Permalink
coverflow and calendar month view bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
devinross committed Jan 30, 2011
1 parent a84bb1b commit 9201750
Show file tree
Hide file tree
Showing 35 changed files with 119 additions and 82 deletions.
4 changes: 2 additions & 2 deletions src/TapkuLibrary/NSArray+TKCategory.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

@interface NSArray (TKCategory)

- (id)firstObject;
- (id) firstObject;

- (id)randomObject;
- (id) randomObject;

@end
4 changes: 2 additions & 2 deletions src/TapkuLibrary/TKAlertCenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
*/

#import <Foundation/Foundation.h>
#import <TapkuLibrary/TapkuLibrary.h>
@class TKAlertView;
#import <UIKit/UIKit.h>

@class TKAlertView;

@interface TKAlertCenter : NSObject {

Expand Down
1 change: 1 addition & 0 deletions src/TapkuLibrary/TKAlertCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/

#import "TKAlertCenter.h"
#import "UIView+TKCategory.h"

@interface TKAlertCenter()
@property (nonatomic,retain) NSMutableArray *alerts;
Expand Down
2 changes: 1 addition & 1 deletion src/TapkuLibrary/TKBarButtonItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef enum {
TKBarButtonItemStylePlain,
Expand Down
14 changes: 8 additions & 6 deletions src/TapkuLibrary/TKBarButtonItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ - (UIImage*) imageForStyle:(TKBarButtonItemStyle)s{

NSString *url = [NSString stringWithFormat:@"TapkuLibrary.bundle/Images/gui/%@%@.png",imageName,scale];


UIImage *img = [UIImage imageWithCGImage:[UIImage imageWithContentsOfFile:TKBUNDLE(url)].CGImage
scale:[[UIScreen mainScreen] scale] orientation:UIImageOrientationUp];


return [img stretchableImageWithLeftCapWidth:24 topCapHeight:0];
}
Expand Down Expand Up @@ -135,11 +136,15 @@ - (void) setupButtonWithStyle:(TKBarButtonItemStyle)s{
_buttonContainer.frame = CGRectMake(_buttonContainer.frame.origin.x, _buttonContainer.frame.origin.y, glyph.size.width + e.left + e.right, 30);
}

UIImage *img = [self imageForStyle:s];

[_buttonContainer setBackgroundImage:[self imageForStyle:s] forState:UIControlStateNormal];
//[_buttonContainer setImage:img forState:UIControlStateNormal];
[_buttonContainer setBackgroundImage:img forState:UIControlStateNormal];
[_buttonContainer setBackgroundImage:[self hoverImageForStyle:s] forState:UIControlStateHighlighted];
_buttonContainer.showsTouchWhenHighlighted = NO;
_buttonContainer.adjustsImageWhenHighlighted = NO;


}


Expand Down Expand Up @@ -186,7 +191,7 @@ - (id) initWithImage:(UIImage*)img style:(TKBarButtonItemStyle)s target:(id)t ac
[_buttonContainer setImage:img forState:UIControlStateNormal];
[_buttonContainer addTarget:t action:a forControlEvents:UIControlEventTouchUpInside];
[self setupButtonWithStyle:s];

self.customView = _buttonContainer;

_style = s;
Expand Down Expand Up @@ -226,9 +231,6 @@ - (TKBarButtonItemStyle) buttonStyle{
- (void) setButtonStyle:(TKBarButtonItemStyle)s{
_style = s;
[self setupButtonWithStyle:s];



}


Expand Down
2 changes: 1 addition & 1 deletion src/TapkuLibrary/TKButtonCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/


#import <UIKit/UIKit.h>

@interface TKButtonCell : UITableViewCell {
UILabel *title;
Expand Down
2 changes: 2 additions & 0 deletions src/TapkuLibrary/TKCalendarDayEventView.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*/

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "TapDetectingView.h"

#define VERTICAL_DIFF 50.0
Expand Down
2 changes: 1 addition & 1 deletion src/TapkuLibrary/TKCalendarMonthTableViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
UITableView *_tableView;
}
@property (retain,nonatomic) UITableView *tableView;
- (void) updateTableOffset;
- (void) updateTableOffset:(BOOL)animated;
@end
16 changes: 10 additions & 6 deletions src/TapkuLibrary/TKCalendarMonthTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,23 @@ - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexP

- (void) calendarMonthView:(TKCalendarMonthView*)monthView didSelectDate:(NSDate*)d{
}
- (void) calendarMonthView:(TKCalendarMonthView*)monthView monthDidChange:(NSDate*)d{
[self updateTableOffset];
- (void) calendarMonthView:(TKCalendarMonthView*)monthView monthDidChange:(NSDate*)month animated:(BOOL)animated{
[self updateTableOffset:animated];
}

- (void) updateTableOffset{
- (void) updateTableOffset:(BOOL)animated{

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.4];

if(animated){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.4];
}


float y = self.monthView.frame.origin.y + self.monthView.frame.size.height;
self.tableView.frame = CGRectMake(self.tableView.frame.origin.x, y, self.tableView.frame.size.width, self.view.frame.size.height - y );

[UIView commitAnimations];
if(animated) [UIView commitAnimations];
}


Expand Down
15 changes: 6 additions & 9 deletions src/TapkuLibrary/TKCalendarMonthView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
OTHER DEALINGS IN THE SOFTWARE.
*/

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


@class TKCalendarMonthTiles;
@protocol TKCalendarMonthViewDelegate, TKCalendarMonthViewDataSource;

Expand All @@ -47,13 +50,11 @@
id <TKCalendarMonthViewDataSource> dataSource;

}
- (id) initWithSundayAsFirst:(BOOL)sunday; // or Monday

@property (nonatomic,assign) id <TKCalendarMonthViewDelegate> delegate;
@property (nonatomic,assign) id <TKCalendarMonthViewDataSource> dataSource;

- (id) initWithSundayAsFirst:(BOOL)sunday; // or Monday


- (NSDate*) dateSelected;
- (NSDate*) monthDate;
- (void) selectDate:(NSDate*)date;
Expand All @@ -63,15 +64,11 @@


@protocol TKCalendarMonthViewDelegate <NSObject>

@optional
- (void) calendarMonthView:(TKCalendarMonthView*)monthView didSelectDate:(NSDate*)d;
- (void) calendarMonthView:(TKCalendarMonthView*)monthView monthDidChange:(NSDate*)d;

- (void) calendarMonthView:(TKCalendarMonthView*)monthView didSelectDate:(NSDate*)date;
- (void) calendarMonthView:(TKCalendarMonthView*)monthView monthDidChange:(NSDate*)month animated:(BOOL)animated;
@end

@protocol TKCalendarMonthViewDataSource <NSObject>

- (NSArray*) calendarMonthView:(TKCalendarMonthView*)monthView marksFromDate:(NSDate*)startDate toDate:(NSDate*)lastDate;

@end
47 changes: 21 additions & 26 deletions src/TapkuLibrary/TKCalendarMonthView.m
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,15 @@ - (id) initWithMonth:(NSDate*)date marks:(NSArray*)markArray startDayOnSunday:(B

return self;
}
- (void) dealloc {
[currentDay release];
[dot release];
[selectedImageView release];
[marks release];
[monthDate release];
[super dealloc];
}

- (void) setTarget:(id)t action:(SEL)a{
target = t;
action = a;
Expand Down Expand Up @@ -582,16 +591,6 @@ - (UIImageView *) selectedImageView{
return selectedImageView;
}

- (void)dealloc {
[currentDay release];
[dot release];
[selectedImageView release];
[marks release];
[monthDate release];
[super dealloc];
}


@end


Expand All @@ -608,18 +607,18 @@ @interface TKCalendarMonthView (private)
@end



@implementation TKCalendarMonthView
@synthesize delegate,dataSource;


- (id) init{
return [self initWithSundayAsFirst:YES];
self = [self initWithSundayAsFirst:YES];
return self;
}
- (id) initWithSundayAsFirst:(BOOL)s{

if (!(self = [super initWithFrame:CGRectZero])) return nil;

self.backgroundColor = [UIColor grayColor];

sunday = s;


Expand Down Expand Up @@ -647,11 +646,9 @@ - (id) initWithSundayAsFirst:(BOOL)s{

[self addSubview:self.leftArrow];
[self addSubview:self.rightArrow];

[self addSubview:self.shadow];
self.shadow.frame = CGRectMake(0, self.frame.size.height-self.shadow.frame.size.height+21, self.shadow.frame.size.width, self.shadow.frame.size.height);

self.backgroundColor = [UIColor grayColor];

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"eee"];
Expand Down Expand Up @@ -807,8 +804,8 @@ - (void) changeMonthAnimation:(UIView*)sender{
- (void) changeMonth:(UIButton *)sender{

[self changeMonthAnimation:sender];
if([delegate respondsToSelector:@selector(calendarMonthView:monthDidChange:)])
[delegate calendarMonthView:self monthDidChange:currentTile.monthDate];
if([delegate respondsToSelector:@selector(calendarMonthView:monthDidChange:animated:)])
[delegate calendarMonthView:self monthDidChange:currentTile.monthDate animated:YES];

}
- (void) animationEnded{
Expand All @@ -833,7 +830,6 @@ - (void) selectDate:(NSDate*)date{
return;
}else {

//NSDate *month = [self firstOfMonthFromDate:date];
NSArray *dates = [TKCalendarMonthTiles rangeOfDatesInMonthGrid:month startOnSunday:sunday];
NSArray *data = [dataSource calendarMonthView:self marksFromDate:[dates objectAtIndex:0] toDate:[dates lastObject]];
TKCalendarMonthTiles *newTile = [[TKCalendarMonthTiles alloc] initWithMonth:month
Expand All @@ -848,9 +844,11 @@ - (void) selectDate:(NSDate*)date{
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.bounds.size.width, self.tileBox.frame.size.height+self.tileBox.frame.origin.y);

self.shadow.frame = CGRectMake(0, self.frame.size.height-self.shadow.frame.size.height+21, self.shadow.frame.size.width, self.shadow.frame.size.height);
self.monthYear.text = [NSString stringWithFormat:@"%@ %@",[month month],[month year]];
self.monthYear.text = [NSString stringWithFormat:@"%@ %@",[date month],[date year]];
[currentTile selectDay:info.day];

if([self.delegate respondsToSelector:@selector(calendarMonthView:monthDidChange:animated:)])
[self.delegate calendarMonthView:self monthDidChange:date animated:NO];


}
Expand Down Expand Up @@ -893,17 +891,15 @@ - (void) tile:(NSArray*)ar{
NSDate *dateForMonth = [NSDate dateFromDateInformation:info];
[currentTile selectDay:day];

if([delegate respondsToSelector:@selector(calendarMonthView:monthDidChange:)])
[delegate calendarMonthView:self monthDidChange:dateForMonth];
if([delegate respondsToSelector:@selector(calendarMonthView:monthDidChange:animated:)])
[delegate calendarMonthView:self monthDidChange:dateForMonth animated:YES];


}

}




- (UIImageView *) topBackground{
if(topBackground==nil){
topBackground = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:TKBUNDLE(@"TapkuLibrary.bundle/Images/calendar/Month Grid Top Bar.png")]];
Expand Down Expand Up @@ -963,5 +959,4 @@ - (UIImageView *) shadow{
return shadow;
}


@end
@end
2 changes: 2 additions & 0 deletions src/TapkuLibrary/TKCoverflowCoverView.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
*/


#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

@interface TKCoverflowCoverView : UIView {
UIImage *image;
Expand Down
4 changes: 2 additions & 2 deletions src/TapkuLibrary/TKCoverflowView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
OTHER DEALINGS IN THE SOFTWARE.
*/

#import <QuartzCore/QuartzCore.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

@protocol TKCoverflowViewDelegate,TKCoverflowViewDataSource;
@class TKCoverflowCoverView;
Expand Down
6 changes: 6 additions & 0 deletions src/TapkuLibrary/TKCoverflowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ - (int) indexOfFrontCoverView{
return currentIndex;
}
- (void) bringCoverAtIndexToFront:(int)index animated:(BOOL)animated{

if(index == currentIndex) return;

currentIndex = index;
[self snapToAlbum];

[self animateToIndex:index animated:animated];
}

Expand Down
2 changes: 1 addition & 1 deletion src/TapkuLibrary/TKGraphController.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/


#import <UIKit/UIKit.h>
#import "TKGraphView.h"

@interface TKGraphController : UIViewController {
Expand Down
3 changes: 3 additions & 0 deletions src/TapkuLibrary/TKGraphView.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
*/

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>


@class TKGraph, TKGraphViewPlotView, TKGraphViewIndicator,TKGraphViewGoalLabel;
@protocol TKGraphViewPoint;

Expand Down
2 changes: 1 addition & 1 deletion src/TapkuLibrary/TKImageCenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@


#import <Foundation/Foundation.h>

#import <UIKit/UIKit.h>

@interface TKImageCenter : NSObject {

Expand Down
1 change: 1 addition & 0 deletions src/TapkuLibrary/TKLabelCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

#import <UIKit/UIKit.h>


@interface TKLabelCell : UITableViewCell {
Expand Down
1 change: 1 addition & 0 deletions src/TapkuLibrary/TKProgressAlertView.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/


#import <UIKit/UIKit.h>
#import "TKProgressBarView.h"

Expand Down
Loading

0 comments on commit 9201750

Please sign in to comment.