Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jvanmetre
committed
Nov 19, 2011
0 parents
commit 7b8a72b
Showing
14 changed files
with
770 additions
and
0 deletions.
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,15 @@ | |||
# xcode noise | |||
build/* | |||
*.pbxuser | |||
*.mode1v3 | |||
xcuserdata | |||
|
|||
# auto git version noise | |||
InfoPlist.h | |||
|
|||
# old skool | |||
.svn | |||
|
|||
# osx noise | |||
.DS_Store | |||
profile |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
// | |||
// ICBAppDelegate.h | |||
// ICBPrettyTableView | |||
// | |||
// Created by James Van Metre on 11/17/11. | |||
// Copyright (c) 2011 ELC Technologies. All rights reserved. | |||
// | |||
|
|||
#import <UIKit/UIKit.h> | |||
|
|||
@class ICBTableViewController; | |||
|
|||
@interface ICBAppDelegate : UIResponder <UIApplicationDelegate> | |||
|
|||
@property (strong, nonatomic) UIWindow *window; | |||
|
|||
@property (strong, nonatomic) ICBTableViewController *viewController; | |||
|
|||
@end |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,74 @@ | |||
// | |||
// ICBAppDelegate.m | |||
// ICBPrettyTableView | |||
// | |||
// Created by James Van Metre on 11/17/11. | |||
// Copyright (c) 2011 ELC Technologies. All rights reserved. | |||
// | |||
|
|||
#import "ICBAppDelegate.h" | |||
|
|||
#import "ICBTableViewController.h" | |||
|
|||
@implementation ICBAppDelegate | |||
|
|||
@synthesize window = _window; | |||
@synthesize viewController = _viewController; | |||
|
|||
- (void)dealloc | |||
{ | |||
[_window release]; | |||
[_viewController release]; | |||
[super dealloc]; | |||
} | |||
|
|||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |||
{ | |||
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; | |||
// Override point for customization after application launch. | |||
self.viewController = [[[ICBTableViewController alloc] initWithStyle:UITableViewStylePlain] autorelease]; | |||
self.window.rootViewController = self.viewController; | |||
[self.window makeKeyAndVisible]; | |||
return YES; | |||
} | |||
|
|||
- (void)applicationWillResignActive:(UIApplication *)application | |||
{ | |||
/* | |||
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | |||
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | |||
*/ | |||
} | |||
|
|||
- (void)applicationDidEnterBackground:(UIApplication *)application | |||
{ | |||
/* | |||
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | |||
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | |||
*/ | |||
} | |||
|
|||
- (void)applicationWillEnterForeground:(UIApplication *)application | |||
{ | |||
/* | |||
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. | |||
*/ | |||
} | |||
|
|||
- (void)applicationDidBecomeActive:(UIApplication *)application | |||
{ | |||
/* | |||
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | |||
*/ | |||
} | |||
|
|||
- (void)applicationWillTerminate:(UIApplication *)application | |||
{ | |||
/* | |||
Called when the application is about to terminate. | |||
Save data if appropriate. | |||
See also applicationDidEnterBackground:. | |||
*/ | |||
} | |||
|
|||
@end |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
// | |||
// ICBTableViewCell.h | |||
// ICBPrettyTableView | |||
// | |||
// Created by James Van Metre on 11/17/11. | |||
// Copyright (c) 2011 ELC Technologies. All rights reserved. | |||
// | |||
|
|||
#import <UIKit/UIKit.h> | |||
#import <AddressBook/AddressBook.h> | |||
|
|||
@interface ICBTableViewCell : UITableViewCell | |||
|
|||
@property (nonatomic, retain) NSString *firstName; | |||
@property (nonatomic, retain) NSString *lastName; | |||
@property (nonatomic, retain) NSString *email; | |||
@property (nonatomic, retain) NSString *phone; | |||
//@property (nonatomic, retain) UIImage *image; | |||
@property (nonatomic, retain) NSString *address; | |||
|
|||
- (void)setRecord:(ABRecordRef)record; | |||
- (void)setDictionary:(NSDictionary *)dict; | |||
|
|||
@end |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,142 @@ | |||
// | |||
// ICBTableViewCell.m | |||
// ICBPrettyTableView | |||
// | |||
// Created by James Van Metre on 11/17/11. | |||
// Copyright (c) 2011 ELC Technologies. All rights reserved. | |||
// | |||
|
|||
#import "ICBTableViewCell.h" | |||
|
|||
@implementation ICBTableViewCell | |||
|
|||
@synthesize firstName = _firstName; | |||
@synthesize lastName = _lastName; | |||
@synthesize email = _email; | |||
@synthesize phone = _phone; | |||
@synthesize address = _address; | |||
|
|||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier | |||
{ | |||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; | |||
if (self) { | |||
self.selectionStyle = UITableViewCellSelectionStyleNone; | |||
} | |||
return self; | |||
} | |||
|
|||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated | |||
{ | |||
[super setSelected:selected animated:animated]; | |||
|
|||
// Configure the view for the selected state | |||
} | |||
|
|||
- (NSString *)getFirstEmail:(ABRecordRef)record | |||
{ | |||
ABMultiValueRef valueRef = ABRecordCopyValue(record, kABPersonEmailProperty); | |||
NSInteger count = ABMultiValueGetCount(valueRef); | |||
if (count > 0) { | |||
NSString *string = (NSString *)ABMultiValueCopyValueAtIndex(valueRef, 0); | |||
CFRelease(valueRef); | |||
return [string autorelease]; | |||
} else { | |||
CFRelease(valueRef); | |||
return nil; | |||
} | |||
} | |||
|
|||
- (NSString *)getFirstPhone:(ABRecordRef)record | |||
{ | |||
ABMultiValueRef valueRef = ABRecordCopyValue(record, kABPersonPhoneProperty); | |||
NSInteger count = ABMultiValueGetCount(valueRef); | |||
if (count > 0) { | |||
NSString *string = (NSString *)ABMultiValueCopyValueAtIndex(valueRef, 0); | |||
CFRelease(valueRef); | |||
return [string autorelease]; | |||
} else { | |||
CFRelease(valueRef); | |||
return nil; | |||
} | |||
} | |||
|
|||
- (void)setRecord:(ABRecordRef)record | |||
{ | |||
self.firstName = [(NSString *)ABRecordCopyValue(record, kABPersonFirstNameProperty) autorelease]; | |||
self.lastName = [(NSString *)ABRecordCopyValue(record, kABPersonLastNameProperty) autorelease]; | |||
self.email = [self getFirstEmail:record]; | |||
self.phone = [self getFirstPhone:record]; | |||
[self setNeedsDisplay]; | |||
} | |||
|
|||
- (void)setDictionary:(NSDictionary *)dict | |||
{ | |||
self.firstName = [dict objectForKey:@"firstName"]; | |||
self.lastName = [dict objectForKey:@"lastName"]; | |||
self.email = [dict objectForKey:@"email"]; | |||
self.phone = [dict objectForKey:@"phone"]; | |||
[self setNeedsDisplay]; | |||
} | |||
|
|||
- (void)drawRect:(CGRect)rect | |||
{ | |||
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |||
|
|||
CGContextClipToRect(ctx, rect); | |||
//If even | |||
if (((self.tag % 2) == 0)) { | |||
CGContextSetFillColorWithColor(ctx, [UIColor colorWithWhite:0.1f alpha:1.f].CGColor); | |||
} else { | |||
CGContextSetFillColorWithColor(ctx, [UIColor colorWithWhite:0.15f alpha:1.f].CGColor); | |||
} | |||
|
|||
CGContextFillRect(ctx, rect); | |||
|
|||
//Vertically center our text, if no email | |||
BOOL isCentered = (self.email == nil); | |||
|
|||
CGRect tempRect; | |||
CGFloat midY = CGRectGetMidY(rect); | |||
[[UIColor whiteColor] set]; | |||
UIFont *defaultFont = [UIFont systemFontOfSize:16]; | |||
CGSize size = [self.firstName sizeWithFont:defaultFont]; | |||
if (isCentered == NO) { | |||
tempRect = CGRectMake(5, 0, size.width, size.height); | |||
} else { | |||
tempRect = CGRectMake(5, midY - size.height/2, size.width, size.height); | |||
} | |||
[self.firstName drawInRect:tempRect withFont:defaultFont]; | |||
|
|||
[[UIColor lightGrayColor] set]; | |||
size = [self.lastName sizeWithFont:defaultFont]; | |||
if (isCentered == NO) { | |||
tempRect = CGRectMake(CGRectGetMaxX(tempRect)+5, 0, size.width, size.height); | |||
} else { | |||
tempRect = CGRectMake(CGRectGetMaxX(tempRect)+5, midY - size.height/2, size.width, size.height); | |||
} | |||
[self.lastName drawInRect:tempRect withFont:defaultFont]; | |||
|
|||
if (self.phone != nil) { | |||
[[UIColor redColor] set]; | |||
size = [self.phone sizeWithFont:defaultFont]; | |||
CGFloat end = CGRectGetMaxX(tempRect) + size.width; | |||
if (end > rect.size.width) { | |||
size.width = CGRectGetMaxX(rect) - CGRectGetMaxX(tempRect) - 10; //-10 so that we get 5 from the end of last name, and 5 from the end of rect | |||
} | |||
if (isCentered == NO) { | |||
tempRect = CGRectMake(CGRectGetMaxX(rect) - size.width - 5, 0, size.width, size.height); | |||
} else { | |||
tempRect = CGRectMake(CGRectGetMaxX(rect) - size.width - 5, midY - size.height/2, size.width, size.height); | |||
} | |||
[self.phone drawInRect:tempRect withFont:defaultFont lineBreakMode:UILineBreakModeTailTruncation]; | |||
} | |||
|
|||
if (self.email != nil) { | |||
[[UIColor blueColor] set]; | |||
size = [self.email sizeWithFont:defaultFont]; | |||
tempRect = CGRectMake(5, midY, size.width, size.height); | |||
[self.email drawInRect:tempRect withFont:defaultFont]; | |||
} | |||
} | |||
|
|||
@end |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
// | |||
// ICBViewController.h | |||
// ICBPrettyTableView | |||
// | |||
// Created by James Van Metre on 11/17/11. | |||
// Copyright (c) 2011 ELC Technologies. All rights reserved. | |||
// | |||
|
|||
#import <UIKit/UIKit.h> | |||
#import <AddressBook/AddressBook.h> | |||
|
|||
@interface ICBTableViewController : UITableViewController | |||
{ | |||
ABAddressBookRef _addressBook; | |||
} | |||
|
|||
@property (nonatomic, retain) NSArray *contacts; | |||
|
|||
@end |
Oops, something went wrong.