From 6a23e1d33abe3446e8ffdb68434ff57bf476af33 Mon Sep 17 00:00:00 2001 From: Sam Soffes Date: Thu, 11 Mar 2010 21:00:33 -0600 Subject: [PATCH] Cleaned up ivars and removed switch cell --- TWToolkit.xcodeproj/project.pbxproj | 8 --- TWToolkit/TWGradientView.h | 24 ++++---- TWToolkit/TWGradientView.m | 56 +++++++++--------- TWToolkit/TWHUDView.h | 10 ++-- TWToolkit/TWHUDView.m | 57 +++++++++--------- TWToolkit/TWLoadingView.h | 20 +++---- TWToolkit/TWLoadingView.m | 47 ++++++++------- TWToolkit/TWMessageTableViewCellBubbleView.m | 12 ++-- TWToolkit/TWMessagesViewController.h | 3 + TWToolkit/TWMessagesViewController.m | 2 +- TWToolkit/TWSwitchTableViewCell.h | 16 ----- TWToolkit/TWSwitchTableViewCell.m | 62 -------------------- TWToolkit/TWTextField.h | 2 +- TWToolkit/TWTextField.m | 4 +- 14 files changed, 120 insertions(+), 203 deletions(-) delete mode 100644 TWToolkit/TWSwitchTableViewCell.h delete mode 100644 TWToolkit/TWSwitchTableViewCell.m diff --git a/TWToolkit.xcodeproj/project.pbxproj b/TWToolkit.xcodeproj/project.pbxproj index 5e08245..d7609f0 100644 --- a/TWToolkit.xcodeproj/project.pbxproj +++ b/TWToolkit.xcodeproj/project.pbxproj @@ -31,8 +31,6 @@ B2974D75106299CB00C9F4A6 /* UIImage+crop.m in Sources */ = {isa = PBXBuildFile; fileRef = B2974D64106299CB00C9F4A6 /* UIImage+crop.m */; }; B2974D78106299CB00C9F4A6 /* UIView+fading.h in Headers */ = {isa = PBXBuildFile; fileRef = B2974D67106299CB00C9F4A6 /* UIView+fading.h */; }; B2974D79106299CB00C9F4A6 /* UIView+fading.m in Sources */ = {isa = PBXBuildFile; fileRef = B2974D68106299CB00C9F4A6 /* UIView+fading.m */; }; - B2A41E9A107287BA006EF521 /* TWSwitchTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B2A41E98107287BA006EF521 /* TWSwitchTableViewCell.h */; }; - B2A41E9B107287BA006EF521 /* TWSwitchTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B2A41E99107287BA006EF521 /* TWSwitchTableViewCell.m */; }; B2C20770106296FB00AE1B56 /* NSArray+shuffle.h in Headers */ = {isa = PBXBuildFile; fileRef = B2C20766106296FB00AE1B56 /* NSArray+shuffle.h */; }; B2C20771106296FB00AE1B56 /* NSArray+shuffle.m in Sources */ = {isa = PBXBuildFile; fileRef = B2C20767106296FB00AE1B56 /* NSArray+shuffle.m */; }; B2C20772106296FB00AE1B56 /* NSData+MD5Sum.h in Headers */ = {isa = PBXBuildFile; fileRef = B2C20768106296FB00AE1B56 /* NSData+MD5Sum.h */; }; @@ -79,8 +77,6 @@ B2974D64106299CB00C9F4A6 /* UIImage+crop.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+crop.m"; sourceTree = ""; }; B2974D67106299CB00C9F4A6 /* UIView+fading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+fading.h"; sourceTree = ""; }; B2974D68106299CB00C9F4A6 /* UIView+fading.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+fading.m"; sourceTree = ""; }; - B2A41E98107287BA006EF521 /* TWSwitchTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TWSwitchTableViewCell.h; sourceTree = ""; }; - B2A41E99107287BA006EF521 /* TWSwitchTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TWSwitchTableViewCell.m; sourceTree = ""; }; B2C20766106296FB00AE1B56 /* NSArray+shuffle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+shuffle.h"; sourceTree = ""; }; B2C20767106296FB00AE1B56 /* NSArray+shuffle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+shuffle.m"; sourceTree = ""; }; B2C20768106296FB00AE1B56 /* NSData+MD5Sum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+MD5Sum.h"; sourceTree = ""; }; @@ -193,8 +189,6 @@ B2A41E97107287A5006EF521 /* Cells */ = { isa = PBXGroup; children = ( - B2A41E98107287BA006EF521 /* TWSwitchTableViewCell.h */, - B2A41E99107287BA006EF521 /* TWSwitchTableViewCell.m */, B2C6829B114954DB006EDD71 /* TWMessageTableViewCell.h */, B2C6829C114954DB006EDD71 /* TWMessageTableViewCell.m */, ); @@ -277,7 +271,6 @@ B2974D78106299CB00C9F4A6 /* UIView+fading.h in Headers */, B28517DA1063E43E008D42E7 /* TWPickerViewController.h in Headers */, B28517E01063E442008D42E7 /* TWLoadingView.h in Headers */, - B2A41E9A107287BA006EF521 /* TWSwitchTableViewCell.h in Headers */, B253C1FA10728DC500E0CE10 /* TWHUDView.h in Headers */, B2503B9510A90DA6009B0E7B /* TWGradientView.h in Headers */, B24B551810B36F6B0014994C /* UIImage+BundleImage.h in Headers */, @@ -345,7 +338,6 @@ B2974D79106299CB00C9F4A6 /* UIView+fading.m in Sources */, B28517DB1063E43E008D42E7 /* TWPickerViewController.m in Sources */, B28517E11063E442008D42E7 /* TWLoadingView.m in Sources */, - B2A41E9B107287BA006EF521 /* TWSwitchTableViewCell.m in Sources */, B253C1FB10728DC500E0CE10 /* TWHUDView.m in Sources */, B2503B9610A90DA6009B0E7B /* TWGradientView.m in Sources */, B24B551910B36F6B0014994C /* UIImage+BundleImage.m in Sources */, diff --git a/TWToolkit/TWGradientView.h b/TWToolkit/TWGradientView.h index f00ddc3..68690a0 100644 --- a/TWToolkit/TWGradientView.h +++ b/TWToolkit/TWGradientView.h @@ -19,22 +19,20 @@ // conversions are planned for the future. // -#import - @interface TWGradientView : UIView { - UIColor *topColor; - UIColor *bottomColor; - UIColor *topBorderColor; - UIColor *bottomBorderColor; - CGFloat topInsetAlpha; - CGFloat bottomInsetAlpha; - BOOL hasTopBorder; - BOOL hasBottomBorder; - BOOL showsInsets; + UIColor *_topColor; + UIColor *_bottomColor; + UIColor *_topBorderColor; + UIColor *_bottomBorderColor; + CGFloat _topInsetAlpha; + CGFloat _bottomInsetAlpha; + BOOL _hasTopBorder; + BOOL _hasBottomBorder; + BOOL _showsInsets; - BOOL hasDrawn; - CGGradientRef gradient; + BOOL _hasDrawn; + CGGradientRef _gradient; } @property (nonatomic, retain) UIColor *topColor; diff --git a/TWToolkit/TWGradientView.m b/TWToolkit/TWGradientView.m index d6643d3..663c9ea 100644 --- a/TWToolkit/TWGradientView.m +++ b/TWToolkit/TWGradientView.m @@ -17,15 +17,15 @@ - (void)_refreshGradient; @implementation TWGradientView -@synthesize topColor; -@synthesize bottomColor; -@synthesize topBorderColor; -@synthesize bottomBorderColor; -@synthesize topInsetAlpha; -@synthesize bottomInsetAlpha; -@synthesize hasTopBorder; -@synthesize hasBottomBorder; -@synthesize showsInsets; +@synthesize topColor = _topColor; +@synthesize bottomColor = _bottomColor; +@synthesize topBorderColor = _topBorderColor; +@synthesize bottomBorderColor = _bottomBorderColor; +@synthesize topInsetAlpha = _topInsetAlpha; +@synthesize bottomInsetAlpha = _bottomInsetAlpha; +@synthesize hasTopBorder = _hasTopBorder; +@synthesize hasBottomBorder = _hasBottomBorder; +@synthesize showsInsets = _showsInsets; #pragma mark - #pragma mark Class Methods @@ -66,7 +66,7 @@ + (CGFloat)defaultBottomInsetAlpha { #pragma mark - - (void)dealloc { - if (hasDrawn) { + if (_hasDrawn) { [self removeObserver:self forKeyPath:@"topColor"]; [self removeObserver:self forKeyPath:@"bottomColor"]; [self removeObserver:self forKeyPath:@"topBorderColor"]; @@ -76,7 +76,7 @@ - (void)dealloc { [self removeObserver:self forKeyPath:@"hasTopBorder"]; [self removeObserver:self forKeyPath:@"hasBottomBorder"]; [self removeObserver:self forKeyPath:@"showsInsets"]; - CGGradientRelease(gradient); + CGGradientRelease(_gradient); } self.topColor = nil; self.bottomColor = nil; @@ -105,15 +105,15 @@ - (id)initWithFrame:(CGRect)frame { self.hasBottomBorder = YES; self.showsInsets = YES; - hasDrawn = NO; - gradient = nil; + _hasDrawn = NO; + _gradient = nil; } return self; } - (void)drawRect:(CGRect)rect { - if (!hasDrawn) { + if (!_hasDrawn) { // Add observers [self addObserver:self forKeyPath:@"topColor" options:NSKeyValueObservingOptionNew context:nil]; [self addObserver:self forKeyPath:@"bottomColor" options:NSKeyValueObservingOptionNew context:nil]; @@ -128,7 +128,7 @@ - (void)drawRect:(CGRect)rect { // Draw gradient [self _refreshGradient]; - hasDrawn = YES; + _hasDrawn = YES; } CGContextRef context = UIGraphicsGetCurrentContext(); @@ -138,37 +138,37 @@ - (void)drawRect:(CGRect)rect { // Gradient CGPoint start = CGPointMake(0.0, 0.0); CGPoint end = CGPointMake(0.0, rect.size.height); - CGContextDrawLinearGradient(context, gradient, start, end, 0); + CGContextDrawLinearGradient(context, _gradient, start, end, 0); CGContextSetLineWidth(context, 2.0); - if (hasTopBorder) { + if (_hasTopBorder) { // Top inset - if (showsInsets && topInsetAlpha > 0.0) { - CGContextSetStrokeColorWithColor(context, [UIColor colorWithWhite:1.0 alpha:topInsetAlpha].CGColor); + if (_showsInsets && _topInsetAlpha > 0.0) { + CGContextSetStrokeColorWithColor(context, [UIColor colorWithWhite:1.0 alpha:_topInsetAlpha].CGColor); CGContextMoveToPoint(context, 0.0, 1.0); CGContextAddLineToPoint(context, rect.size.width, 1.0); CGContextStrokePath(context); } // Top border - CGContextSetStrokeColorWithColor(context, topBorderColor.CGColor); + CGContextSetStrokeColorWithColor(context, _topBorderColor.CGColor); CGContextMoveToPoint(context, 0.0, 0.0); CGContextAddLineToPoint(context, rect.size.width, 0.0); CGContextStrokePath(context); } - if (hasBottomBorder) { + if (_hasBottomBorder) { // Bottom inset - if (showsInsets && bottomInsetAlpha > 0.0) { - CGContextSetStrokeColorWithColor(context, [UIColor colorWithWhite:1.0 alpha:bottomInsetAlpha].CGColor); + if (_showsInsets && _bottomInsetAlpha > 0.0) { + CGContextSetStrokeColorWithColor(context, [UIColor colorWithWhite:1.0 alpha:_bottomInsetAlpha].CGColor); CGContextMoveToPoint(context, 0.0, rect.size.height - 1.0); CGContextAddLineToPoint(context, rect.size.width, rect.size.height - 1.0); CGContextStrokePath(context); } // Bottom border - CGContextSetStrokeColorWithColor(context, bottomBorderColor.CGColor); + CGContextSetStrokeColorWithColor(context, _bottomBorderColor.CGColor); CGContextMoveToPoint(context, 0.0, rect.size.height); CGContextAddLineToPoint(context, rect.size.width, rect.size.height); CGContextStrokePath(context); @@ -182,10 +182,10 @@ - (void)drawRect:(CGRect)rect { - (void)_refreshGradient { // TODO: Automatically convert colors into the same colorspace - CGColorSpaceRef colorSpace = CGColorGetColorSpace(topColor.CGColor); - NSArray *colors = [NSArray arrayWithObjects:(id)topColor.CGColor, (id)bottomColor.CGColor, nil]; - CGGradientRelease(gradient); - gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)colors, NULL); + CGColorSpaceRef colorSpace = CGColorGetColorSpace(_topColor.CGColor); + NSArray *colors = [NSArray arrayWithObjects:(id)_topColor.CGColor, (id)_bottomColor.CGColor, nil]; + CGGradientRelease(_gradient); + _gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)colors, NULL); [self setNeedsDisplay]; } diff --git a/TWToolkit/TWHUDView.h b/TWToolkit/TWHUDView.h index 8df0ab4..694f9f0 100644 --- a/TWToolkit/TWHUDView.h +++ b/TWToolkit/TWHUDView.h @@ -8,13 +8,13 @@ @interface TWHUDView : UIAlertView { - UILabel *textLabel; - UIActivityIndicatorView *activityIndicator; - BOOL loading; + UILabel *_textLabel; + UIActivityIndicatorView *_activityIndicator; + BOOL _loading; } -@property (nonatomic, retain) UILabel *textLabel; -@property (nonatomic, retain) UIActivityIndicatorView *activityIndicator; +@property (nonatomic, retain, readonly) UILabel *textLabel; +@property (nonatomic, retain, readonly) UIActivityIndicatorView *activityIndicator; @property (nonatomic, assign, getter=isLoading) BOOL loading; - (id)initWithTitle:(NSString *)aTitle; diff --git a/TWToolkit/TWHUDView.m b/TWToolkit/TWHUDView.m index a5a3ca0..8573bfc 100644 --- a/TWToolkit/TWHUDView.m +++ b/TWToolkit/TWHUDView.m @@ -10,13 +10,14 @@ #import "UIImage+BundleImage.h" #import -#define kHUDSize 172.0 +static CGFloat kHUDSize = 172.0; +static CGFloat kIndicatorSize = 40.0; @implementation TWHUDView -@synthesize textLabel; -@synthesize activityIndicator; -@synthesize loading; +@synthesize textLabel = _textLabel; +@synthesize activityIndicator = _activityIndicator; +@synthesize loading = _loading; #pragma mark - #pragma mark NSObject @@ -28,8 +29,8 @@ - (id)init { - (void)dealloc { - [activityIndicator release]; - [textLabel release]; + [_activityIndicator release]; + [_textLabel release]; [super dealloc]; } @@ -66,7 +67,7 @@ - (void)drawRect:(CGRect)rect { CGContextFillPath(context); // Checkmark - if (loading == NO) { + if (_loading == NO) { UIImage *checkmark = [UIImage imageNamed:@"images/hud-checkmark.png" bundle:@"TWToolkit.bundle"]; [checkmark drawInRect:CGRectMake(round((kHUDSize - 36.0) / 2.0), round((kHUDSize - 40.0) / 2.0), 36.0, 40.0)]; } @@ -74,10 +75,8 @@ - (void)drawRect:(CGRect)rect { - (void)layoutSubviews { - static CGFloat indicatorSize = 40.0; - - activityIndicator.frame = CGRectMake(round((kHUDSize - indicatorSize) / 2.0), round((kHUDSize - indicatorSize) / 2.0), indicatorSize, indicatorSize); - textLabel.frame = CGRectMake(0.0, round(kHUDSize - 30.0), kHUDSize, 20.0); + _activityIndicator.frame = CGRectMake(round((kHUDSize - kIndicatorSize) / 2.0), round((kHUDSize - kIndicatorSize) / 2.0), kIndicatorSize, kIndicatorSize); + _textLabel.frame = CGRectMake(0.0, round(kHUDSize - 30.0), kHUDSize, 20.0); } @@ -97,7 +96,7 @@ - (void)show { // Deprecated. Overridding UIAlertView's setTitle. - (void)setTitle:(NSString *)aTitle { - textLabel.text = aTitle; + _textLabel.text = aTitle; } #pragma mark - @@ -112,22 +111,22 @@ - (id)initWithTitle:(NSString *)aTitle { - (id)initWithTitle:(NSString *)aTitle loading:(BOOL)isLoading { if (self = [super initWithFrame:CGRectZero]) { // Indicator - activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; - activityIndicator.alpha = 0.0; - [activityIndicator startAnimating]; - [self addSubview:activityIndicator]; + _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; + _activityIndicator.alpha = 0.0; + [_activityIndicator startAnimating]; + [self addSubview:_activityIndicator]; // Text Label - textLabel = [[UILabel alloc] initWithFrame:CGRectZero]; - textLabel.font = [UIFont boldSystemFontOfSize:14]; - textLabel.backgroundColor = [UIColor clearColor]; - textLabel.textColor = [UIColor whiteColor]; - textLabel.shadowColor = [UIColor blackColor]; - textLabel.shadowOffset = CGSizeMake(0.0, 1.0); - textLabel.textAlignment = UITextAlignmentCenter; - textLabel.lineBreakMode = UILineBreakModeTailTruncation; - textLabel.text = aTitle ? aTitle : @"Loading"; - [self addSubview:textLabel]; + _textLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + _textLabel.font = [UIFont boldSystemFontOfSize:14]; + _textLabel.backgroundColor = [UIColor clearColor]; + _textLabel.textColor = [UIColor whiteColor]; + _textLabel.shadowColor = [UIColor blackColor]; + _textLabel.shadowOffset = CGSizeMake(0.0, 1.0); + _textLabel.textAlignment = UITextAlignmentCenter; + _textLabel.lineBreakMode = UILineBreakModeTailTruncation; + _textLabel.text = aTitle ? aTitle : @"Loading"; + [self addSubview:_textLabel]; // Loading self.loading = isLoading; @@ -138,7 +137,7 @@ - (id)initWithTitle:(NSString *)aTitle loading:(BOOL)isLoading { - (void)completeWithTitle:(NSString *)aTitle { self.loading = NO; - textLabel.text = aTitle; + _textLabel.text = aTitle; } @@ -163,8 +162,8 @@ - (void)dismissAnimated:(BOOL)animated { #pragma mark - - (void)setLoading:(BOOL)isLoading { - loading = isLoading; - activityIndicator.alpha = loading ? 1.0 : 0.0; + _loading = isLoading; + _activityIndicator.alpha = _loading ? 1.0 : 0.0; [self setNeedsDisplay]; } diff --git a/TWToolkit/TWLoadingView.h b/TWToolkit/TWLoadingView.h index 5619312..2af9a58 100644 --- a/TWToolkit/TWLoadingView.h +++ b/TWToolkit/TWLoadingView.h @@ -8,17 +8,17 @@ @interface TWLoadingView : UIView { - UIActivityIndicatorView *indicator; - NSString *text; - UIFont *font; - UIColor *textColor; - UIColor *shadowColor; + UIActivityIndicatorView *_activityIndicator; + NSString *_text; + UIFont *_font; + UIColor *_textColor; + UIColor *_shadowColor; } -@property (nonatomic, retain) UIActivityIndicatorView *indicator; -@property (nonatomic, retain) NSString *text; -@property (nonatomic, retain) UIFont *font; -@property (nonatomic, retain) UIColor *textColor; -@property (nonatomic, retain) UIColor *shadowColor; +@property (nonatomic, retain, readonly) UIActivityIndicatorView *activityIndicator; +@property (nonatomic, copy) NSString *text; +@property (nonatomic, copy) UIFont *font; +@property (nonatomic, copy) UIColor *textColor; +@property (nonatomic, copy) UIColor *shadowColor; @end diff --git a/TWToolkit/TWLoadingView.m b/TWToolkit/TWLoadingView.m index 39efd4d..7cb74db 100644 --- a/TWToolkit/TWLoadingView.m +++ b/TWToolkit/TWLoadingView.m @@ -14,11 +14,11 @@ @implementation TWLoadingView -@synthesize indicator; -@synthesize text; -@synthesize font; -@synthesize textColor; -@synthesize shadowColor; +@synthesize activityIndicator = _activityIndicator; +@synthesize text = _text; +@synthesize font = _font; +@synthesize textColor = _textColor; +@synthesize shadowColor = _shadowColor; #pragma mark - #pragma mark NSObject @@ -29,10 +29,11 @@ - (void)dealloc { [self removeObserver:self forKeyPath:@"font"]; [self removeObserver:self forKeyPath:@"textColor"]; [self removeObserver:self forKeyPath:@"shadowColor"]; - [font release]; - [textColor release]; - [shadowColor release]; - [indicator release]; + self.font = nil; + self.text = nil; + self.textColor = nil; + self.shadowColor = nil; + [_activityIndicator release]; [super dealloc]; } @@ -50,10 +51,10 @@ - (id)initWithFrame:(CGRect)frame { self.opaque = YES; // Setup the indicator - indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; - indicator.hidesWhenStopped = NO; - [indicator startAnimating]; - [self addSubview:indicator]; + _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; + _activityIndicator.hidesWhenStopped = NO; + [_activityIndicator startAnimating]; + [self addSubview:_activityIndicator]; // Defaults self.text = @"Loading..."; @@ -75,28 +76,30 @@ - (id)initWithFrame:(CGRect)frame { - (void)drawRect:(CGRect)rect { + CGRect frame = self.frame; + // Calculate sizes - CGSize maxSize = CGSizeMake(self.frame.size.width - (interiorPadding * 2.0) - indicatorSize - indicatorRightMargin, indicatorSize); - CGSize textSize = [text sizeWithFont:font constrainedToSize:maxSize lineBreakMode:UILineBreakModeWordWrap]; + CGSize maxSize = CGSizeMake(frame.size.width - (interiorPadding * 2.0) - indicatorSize - indicatorRightMargin, indicatorSize); + CGSize textSize = [_text sizeWithFont:_font constrainedToSize:maxSize lineBreakMode:UILineBreakModeWordWrap]; // Calculate position CGFloat totalWidth = textSize.width + indicatorSize + indicatorRightMargin; - NSInteger y = (NSInteger)((self.frame.size.height / 2.0) - (indicatorSize / 2.0)); + NSInteger y = (NSInteger)((frame.size.height / 2.0) - (indicatorSize / 2.0)); // Position the indicator - indicator.frame = CGRectMake((NSInteger)((self.frame.size.width - totalWidth) / 2.0), y, indicatorSize, indicatorSize); + _activityIndicator.frame = CGRectMake((NSInteger)((frame.size.width - totalWidth) / 2.0), y, indicatorSize, indicatorSize); // Calculate text position - CGRect textRect = CGRectMake(indicator.frame.origin.x + indicatorSize + indicatorRightMargin, y, textSize.width, textSize.height); + CGRect textRect = CGRectMake(_activityIndicator.frame.origin.x + indicatorSize + indicatorRightMargin, y, textSize.width, textSize.height); // Draw shadow. The offset is (0, 1) - [shadowColor set]; + [_shadowColor set]; CGRect shadowRect = CGRectMake(textRect.origin.x, textRect.origin.y + 1.0, textRect.size.width, textRect.size.height); - [text drawInRect:shadowRect withFont:font lineBreakMode:UILineBreakModeTailTruncation alignment:UITextAlignmentLeft]; + [_text drawInRect:shadowRect withFont:_font lineBreakMode:UILineBreakModeTailTruncation alignment:UITextAlignmentLeft]; // Draw text - [textColor set]; - [text drawInRect:textRect withFont:font lineBreakMode:UILineBreakModeTailTruncation alignment:UITextAlignmentLeft]; + [_textColor set]; + [_text drawInRect:textRect withFont:_font lineBreakMode:UILineBreakModeTailTruncation alignment:UITextAlignmentLeft]; } diff --git a/TWToolkit/TWMessageTableViewCellBubbleView.m b/TWToolkit/TWMessageTableViewCellBubbleView.m index 94b1956..22d8c9b 100644 --- a/TWToolkit/TWMessageTableViewCellBubbleView.m +++ b/TWToolkit/TWMessageTableViewCellBubbleView.m @@ -9,13 +9,13 @@ #import "TWMessageTableViewCellBubbleView.h" #import "UIImage+BundleImage.h" -#define kMaxWidth 223.0 #define kFont [UIFont systemFontOfSize:15.0] -#define kLineBreakMode UILineBreakModeWordWrap -#define kPaddingTop 6.0 -#define kPaddingBottom 8.0 -#define kMarginTop 2.0 -#define kMarginBottom 2.0 +static UILineBreakMode kLineBreakMode = UILineBreakModeWordWrap; +static CGFloat kMaxWidth = 223.0; +static CGFloat kPaddingTop = 6.0; +static CGFloat kPaddingBottom = 8.0; +static CGFloat kMarginTop = 2.0; +static CGFloat kMarginBottom = 2.0; @implementation TWMessageTableViewCellBubbleView diff --git a/TWToolkit/TWMessagesViewController.h b/TWToolkit/TWMessagesViewController.h index 35653ee..4e32041 100644 --- a/TWToolkit/TWMessagesViewController.h +++ b/TWToolkit/TWMessagesViewController.h @@ -7,6 +7,9 @@ // override the messageStyleForRowAtIndexPath: and // textForRowAtIndexPath: to customize this class. // +// This is still a work in progress and likely to change +// at any time. +// // Created by Sam Soffes on 3/10/10. // Copyright 2010 Tasteful Works. All rights reserved. // diff --git a/TWToolkit/TWMessagesViewController.m b/TWToolkit/TWMessagesViewController.m index c0d4cea..62fd094 100644 --- a/TWToolkit/TWMessagesViewController.m +++ b/TWToolkit/TWMessagesViewController.m @@ -13,7 +13,7 @@ #import "TWTextField.h" #import "UIImage+BundleImage.h" -#define kInputHeight 40.0 +CGFloat kInputHeight = 40.0; @implementation TWMessagesViewController diff --git a/TWToolkit/TWSwitchTableViewCell.h b/TWToolkit/TWSwitchTableViewCell.h deleted file mode 100644 index 1e8f6c3..0000000 --- a/TWToolkit/TWSwitchTableViewCell.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// TWSwitchTableViewCell.h -// TWToolkit -// -// Created by Sam Soffes on 9/29/09. -// Copyright 2009 Tasteful Works, Inc. All rights reserved. -// - -@interface TWSwitchTableViewCell : UITableViewCell { - - UISwitch *switchView; -} - -@property (nonatomic, retain, readonly) UISwitch *switchView; - -@end diff --git a/TWToolkit/TWSwitchTableViewCell.m b/TWToolkit/TWSwitchTableViewCell.m deleted file mode 100644 index 0d5245a..0000000 --- a/TWToolkit/TWSwitchTableViewCell.m +++ /dev/null @@ -1,62 +0,0 @@ -// -// TWSwitchTableViewCell.m -// TWToolkit -// -// Created by Sam Soffes on 9/29/09. -// Copyright 2009 Tasteful Works, Inc. All rights reserved. -// - -#import "TWSwitchTableViewCell.h" - -@implementation TWSwitchTableViewCell - -@synthesize switchView; - -#pragma mark - -#pragma mark NSObject -#pragma mark - - -- (void)dealloc { - [switchView release]; - [super dealloc]; -} - - -#pragma mark - -#pragma mark UIView -#pragma mark - - -- (void)layoutSubviews { - [super layoutSubviews]; - switchView.frame = CGRectMake(self.contentView.frame.size.width - 104.0, round((self.contentView.frame.size.height - 27.0) / 2.0), 94.0, 27.0); -} - - -#pragma mark - -#pragma mark UITableViewCell -#pragma mark - - -- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { - if (self = [super initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier]) { - - // Defaults - self.selectionStyle = UITableViewCellSelectionStyleNone; - - // Switch - switchView = [[UISwitch alloc] initWithFrame:CGRectZero]; - [self.contentView addSubview:switchView]; - } - return self; -} - - -- (void)setAccessoryType:(UITableViewCellAccessoryType)accessoryType { - [super setAccessoryType:UITableViewCellAccessoryNone]; -} - - -- (void)setSelectionStyle:(UITableViewCellSelectionStyle)style { - [super setSelectionStyle:UITableViewCellSelectionStyleNone]; -} - -@end diff --git a/TWToolkit/TWTextField.h b/TWToolkit/TWTextField.h index fae66e3..7c10aa4 100644 --- a/TWToolkit/TWTextField.h +++ b/TWToolkit/TWTextField.h @@ -8,7 +8,7 @@ @interface TWTextField : UITextField { - UIEdgeInsets textInset; + UIEdgeInsets _textInset; } @property (nonatomic, assign) UIEdgeInsets textInset; diff --git a/TWToolkit/TWTextField.m b/TWToolkit/TWTextField.m index 5327410..01c2af1 100644 --- a/TWToolkit/TWTextField.m +++ b/TWToolkit/TWTextField.m @@ -10,7 +10,7 @@ @implementation TWTextField -@synthesize textInset; +@synthesize textInset = _textInset; #pragma mark - #pragma mark UIView @@ -29,7 +29,7 @@ - (id)initWithFrame:(CGRect)frame { #pragma mark - - (CGRect)textRectForBounds:(CGRect)bounds { - return UIEdgeInsetsInsetRect(bounds, textInset); + return UIEdgeInsetsInsetRect(bounds, self.textInset); } - (CGRect)editingRectForBounds:(CGRect)bounds {