Skip to content

Commit

Permalink
Add buzzer cell gradient.
Browse files Browse the repository at this point in the history
Looks awesome on the phone -- thanks Roger!
  • Loading branch information
theory committed Apr 14, 2010
1 parent 89dfde7 commit 0370875
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
4 changes: 4 additions & 0 deletions Buzzalot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
63834ABA112BCF13009A9CA6 /* HumanIntervalTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63834AB9112BCF13009A9CA6 /* HumanIntervalTest.m */; };
6394376B1119356500E39D09 /* ABTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6394376A1119356500E39D09 /* ABTableViewCell.m */; };
639438CF111A3D4C00E39D09 /* icon_frame.png in Resources */ = {isa = PBXBuildFile; fileRef = 639438CE111A3D4C00E39D09 /* icon_frame.png */; };
639573A2117577BA0008B791 /* cell_gradient.png in Resources */ = {isa = PBXBuildFile; fileRef = 639573A1117577BA0008B791 /* cell_gradient.png */; };
63CA77D4114DA75700AF62C9 /* ComposeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 63CA77D2114DA75700AF62C9 /* ComposeViewController.m */; };
63CB6BD71119238D00738680 /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 63CB6BD61119238D00738680 /* RootViewController.m */; };
63CB6BEE1119266F00738680 /* BuzzerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 63CB6BED1119266F00738680 /* BuzzerCell.m */; };
Expand Down Expand Up @@ -98,6 +99,7 @@
639437691119356500E39D09 /* ABTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ABTableViewCell.h; sourceTree = "<group>"; };
6394376A1119356500E39D09 /* ABTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ABTableViewCell.m; sourceTree = "<group>"; };
639438CE111A3D4C00E39D09 /* icon_frame.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon_frame.png; sourceTree = "<group>"; };
639573A1117577BA0008B791 /* cell_gradient.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cell_gradient.png; sourceTree = "<group>"; };
63CA77D1114DA75700AF62C9 /* ComposeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposeViewController.h; sourceTree = "<group>"; };
63CA77D2114DA75700AF62C9 /* ComposeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposeViewController.m; sourceTree = "<group>"; };
63CB6BD51119238D00738680 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -230,6 +232,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
639573A1117577BA0008B791 /* cell_gradient.png */,
63505CB911742329000BB488 /* icon_shadow.png */,
63CFD9211144CB070098C0DF /* green_button.png */,
63CFD8D51144C78C0098C0DF /* blue_button.png */,
Expand Down Expand Up @@ -352,6 +355,7 @@
63505B7B1173E91A000BB488 /* my_bubble.png in Resources */,
63505B7C1173E91A000BB488 /* your_bubble.png in Resources */,
63505CBA11742329000BB488 /* icon_shadow.png in Resources */,
639573A2117577BA0008B791 /* cell_gradient.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
37 changes: 20 additions & 17 deletions Classes/BuzzerCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@ @implementation BuzzerCell

@synthesize buzzer;

static UIFont *buzzerNameFont = nil;
static UIFont *bodyTextFont = nil;
static UIFont *whenTextFont = nil;
static UIFont *buzzerNameFont = nil;
static UIFont *bodyTextFont = nil;
static UIFont *whenTextFont = nil;
static UIImage *gradientImage = nil;

+ (void)initialize {
if (self == [BuzzerCell class]) {
buzzerNameFont = [[UIFont boldSystemFontOfSize:14] retain];
bodyTextFont = [[UIFont systemFontOfSize:14] retain];
whenTextFont = [[UIFont systemFontOfSize:14] retain];
// this is a good spot to load any graphics you might be drawing in
// -drawContentView: just load them and retain them here (ONLY if
// they're small enough that you don't care about them wasting memory)
// the idea is to do as LITTLE work (e.g. allocations) in
// -drawContentView: as possible
bodyTextFont = [[UIFont systemFontOfSize:14] retain];
whenTextFont = [[UIFont systemFontOfSize:14] retain];
gradientImage = [[[UIImage imageNamed:@"cell_gradient.png"] stretchableImageWithLeftCapWidth:0 topCapHeight:65] retain];
}
}

Expand Down Expand Up @@ -60,27 +57,33 @@ - (void)drawContentView:(CGRect)r {
CGContextFillRect(context, r);
[textColor set];

// Determine the cell height.
CGFloat height = [self.buzzer.body sizeWithFont:bodyTextFont constrainedToSize:CGSizeMake(kBuzzerBodyWidth, 2000)].height;

// Draw gradient.
[gradientImage drawInRect:CGRectMake(0, MAX(height + kBuzzerBodyY + 6, 60) - 65, [[UIScreen mainScreen] bounds].size.width, 65)];
// return MAX(size.height + kBuzzerBodyY + 6, 60);

// Draw date/time.
if (!self.selected) [textColor = [UIColor blueGrayColor] set];
NSString *reltime = [self.buzzer.when humanIntervalSinceNow];
CGSize size = [reltime sizeWithFont:whenTextFont constrainedToSize:CGSizeMake(120, 2000)];
CGPoint p = {296 - size.width, 4};
CGFloat width = [reltime sizeWithFont:whenTextFont constrainedToSize:CGSizeMake(120, 2000)].width;
CGPoint p = {296 - width, 4};
[reltime drawAtPoint:p withFont:whenTextFont];

// Draw buzzer name.
if (!self.selected) [textColor = [UIColor darkTextColor] set];
p.x = 60;
p.y = 4;
[self.buzzer.name drawAtPoint:p forWidth: 232 - size.width withFont:buzzerNameFont lineBreakMode:UILineBreakModeWordWrap ];
[self.buzzer.name drawAtPoint:p forWidth: 232 - width withFont:buzzerNameFont lineBreakMode:UILineBreakModeWordWrap ];

// CGContextStrokeRect(context, CGRectMake(60, 4, 232-size.width, 20));
// CGContextStrokeRect(context, CGRectMake(60, 4, 232-width, 20));

// Draw body.
if (!self.selected) [textColor = [UIColor darkGrayColor] set];
size = [self.buzzer.body sizeWithFont:bodyTextFont constrainedToSize:CGSizeMake(kBuzzerBodyWidth, 2000)];
[self.buzzer.body drawInRect:CGRectMake(p.x, 22, 235, size.height) withFont:bodyTextFont];
[self.buzzer.body drawInRect:CGRectMake(p.x, 22, 235, height) withFont:bodyTextFont];

// CGContextStrokeRect(context, CGRectMake(p.x, kBuzzerBodyY, kBuzzerBodyWidth, size.height));
// CGContextStrokeRect(context, CGRectMake(p.x, kBuzzerBodyY, kBuzzerBodyWidth, height));

[[UIImage imageNamed:@"icon_shadow.png"] drawInRect:CGRectMake(2, 3, 52, 52)];
UIImage *img = [IconFinder getForEmail: self.buzzer.email];
Expand Down
Binary file added cell_gradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0370875

Please sign in to comment.