Navigation Menu

Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
* Replace TTAppearance with TTStyleSheet
Browse files Browse the repository at this point in the history
* Centralize all styles in TTDefaultStyleSheet

Signed-off-by: Joakim Bodin <joakim.bodin@gmail.com>
  • Loading branch information
joehewitt authored and Joakim Bodin committed Apr 9, 2009
1 parent 7c67def commit 8da4a01
Show file tree
Hide file tree
Showing 32 changed files with 586 additions and 674 deletions.
73 changes: 43 additions & 30 deletions samples/TTCatalog/Classes/ButtonTestController.m
@@ -1,11 +1,27 @@
#import "ButtonTestController.h"

@interface ButtonTestStyleSheet : NSObject
@interface ButtonTestStyleSheet : TTDefaultStyleSheet
@end

@implementation ButtonTestStyleSheet

+ (TTStyle*)embossedButton:(UIControlState)state {
- (TTStyle*)blackForwardButton:(UIControlState)state {
TTShape* shape = [TTRoundedRightArrowShape shapeWithRadius:4.5];
UIColor* tintColor = RGBCOLOR(0, 0, 0);
UIFont* font = TTSTYLEVAR(toolbarButtonFont);

return [TTSTYLESHEET toolbarButtonForState:state shape:shape tintColor:tintColor font:font];
}

- (TTStyle*)blueToolbarButton:(UIControlState)state {
TTShape* shape = [TTRoundedRectangleShape shapeWithRadius:4.5];
UIColor* tintColor = RGBCOLOR(0, 120, 240);
UIFont* font = TTSTYLEVAR(toolbarButtonFont);

return [TTSTYLESHEET toolbarButtonForState:state shape:shape tintColor:tintColor font:font];
}

- (TTStyle*)embossedButton:(UIControlState)state {
if (state == UIControlStateNormal) {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:8] next:
Expand All @@ -16,7 +32,7 @@ + (TTStyle*)embossedButton:(UIControlState)state {
[TTSolidBorderStyle styleWithColor:RGBCOLOR(161, 167, 178) width:1 next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(0, 0, -1, 0) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:13]
color:[TTAppearance appearance].linkTextColor
color:TTSTYLEVAR(linkTextColor)
shadowColor:[UIColor colorWithWhite:255 alpha:0.4]
shadowOffset:CGSizeMake(0, -1) next:nil]]]]]]];
} else if (state == UIControlStateHighlighted) {
Expand All @@ -36,21 +52,21 @@ + (TTStyle*)embossedButton:(UIControlState)state {
}
}

+ (TTStyle*)dropButton:(UIControlState)state {
- (TTStyle*)dropButton:(UIControlState)state {
if (state == UIControlStateNormal) {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:8] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(0, 0, 5, 5) next:
[TTShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.7) blur:3 offset:CGSizeMake(2, 2) next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(0.25, 0.25, 0.25, 0.25) next:
[TTSolidFillStyle styleWithColor:[UIColor whiteColor] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(-0.25, -0.25, -0.25, -0.25) next:
[TTSolidBorderStyle styleWithColor:RGBCOLOR(161, 167, 178) width:1 next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(2, 0, 0, 0) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:13]
color:[TTAppearance appearance].linkTextColor
shadowColor:[UIColor colorWithWhite:255 alpha:0.4]
shadowOffset:CGSizeMake(0, -1) next:nil]]]]]]]]];
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:8] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(0, 0, 5, 5) next:
[TTShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.7) blur:3 offset:CGSizeMake(2, 2) next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(0.25, 0.25, 0.25, 0.25) next:
[TTSolidFillStyle styleWithColor:[UIColor whiteColor] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(-0.25, -0.25, -0.25, -0.25) next:
[TTSolidBorderStyle styleWithColor:RGBCOLOR(161, 167, 178) width:1 next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(2, 0, 0, 0) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:13]
color:TTSTYLEVAR(linkTextColor)
shadowColor:[UIColor colorWithWhite:255 alpha:0.4]
shadowOffset:CGSizeMake(0, -1) next:nil]]]]]]]]];
} else if (state == UIControlStateHighlighted) {
return
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(3, 3, 2, 2) next:
Expand All @@ -59,7 +75,7 @@ + (TTStyle*)dropButton:(UIControlState)state {
[TTSolidBorderStyle styleWithColor:RGBCOLOR(161, 167, 178) width:1 next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(2, 0, 0, 0) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:13]
color:[TTAppearance appearance].linkTextColor
color:TTSTYLEVAR(linkTextColor)
shadowColor:[UIColor colorWithWhite:255 alpha:0.4]
shadowOffset:CGSizeMake(0, -1) next:nil]]]]]];
} else {
Expand Down Expand Up @@ -104,13 +120,13 @@ - (id)init {
if (self = [super init]) {
_fontSize = 12;

[[TTAppearance appearance] addStyleSheet:[ButtonTestStyleSheet class]];
[TTStyleSheet setGlobalStyleSheet:[[[ButtonTestStyleSheet alloc] init] autorelease]];
}
return self;
}

- (void)dealloc {
[[TTAppearance appearance] removeStyleSheet:[ButtonTestStyleSheet class]];
[TTStyleSheet setGlobalStyleSheet:nil];
[super dealloc];
}

Expand All @@ -132,16 +148,13 @@ - (void)loadView {
self.view = scrollView;

NSArray* buttons = [NSArray arrayWithObjects:
[TTButton buttonWithType:TTButtonTypeToolbar title:@"Toolbar Button"
color:RGBCOLOR(119, 140, 168)],
[TTButton buttonWithType:TTButtonTypeToolbarBack title:@"Back Button"
color:RGBCOLOR(119, 140, 168)],
[TTButton buttonWithType:TTButtonTypeToolbarForward title:@"Forward Button"
color:RGBCOLOR(119, 140, 168)],
[TTButton buttonWithType:TTButtonTypeToolbarForward title:@"Black Button"
color:RGBCOLOR(0, 0, 0)],
[TTButton buttonWithType:TTButtonTypeToolbar title:@"Blue Button"
color:RGBCOLOR(0, 120, 240)],
[TTButton buttonWithStyle:@"toolbarButton:" title:@"Toolbar Button"],
[TTButton buttonWithStyle:@"toolbarRoundButton:" title:@"Round Button"],
[TTButton buttonWithStyle:@"toolbarBackButton:" title:@"Back Button"],
[TTButton buttonWithStyle:@"toolbarForwardButton:" title:@"Forward Button"],

[TTButton buttonWithStyle:@"blackForwardButton:" title:@"Black Button"],
[TTButton buttonWithStyle:@"blueToolbarButton:" title:@"Blue Button"],
[TTButton buttonWithStyle:@"embossedButton:" title:@"Embossed Button"],
[TTButton buttonWithStyle:@"dropButton:" title:@"Shadow Button"],
nil];
Expand Down
6 changes: 3 additions & 3 deletions samples/TTCatalog/Classes/RootViewController.m
Expand Up @@ -55,9 +55,9 @@ - (void)viewDidLoad {
[nav addView:@"imageTest2" controller:[TableImageTestController class]];
[nav addView:@"scrollViewTest" controller:[ScrollViewTestController class]];

// [self validateView];
// NSIndexPath* indexPath = [NSIndexPath indexPathForRow:0 inSection:3];
// [self.tableView touchRowAtIndexPath:indexPath animated:NO];
[self validateView];
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:0 inSection:3];
[self.tableView touchRowAtIndexPath:indexPath animated:NO];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 5 additions & 5 deletions samples/TTCatalog/Classes/StyledTextTestController.m
@@ -1,15 +1,15 @@
#import "StyledTextTestController.h"

@interface TextTestStyleSheet : NSObject
@interface TextTestStyleSheet : TTDefaultStyleSheet
@end

@implementation TextTestStyleSheet

+ (TTStyle*)blueText {
- (TTStyle*)blueText {
return [TTTextStyle styleWithColor:[UIColor blueColor] next:nil];
}

+ (TTStyle*)blueBox {
- (TTStyle*)blueBox {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:TT_ROUNDED] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(1, -3, 1, -3) next:
Expand All @@ -27,13 +27,13 @@ @implementation StyledTextTestController

- (id)init {
if (self = [super init]) {
[[TTAppearance appearance] addStyleSheet:[TextTestStyleSheet class]];
[TTStyleSheet setGlobalStyleSheet:[[[TextTestStyleSheet alloc] init] autorelease]];
}
return self;
}

- (void)dealloc {
[[TTAppearance appearance] removeStyleSheet:[TextTestStyleSheet class]];
[TTStyleSheet setGlobalStyleSheet:nil];
[super dealloc];
}

Expand Down
10 changes: 7 additions & 3 deletions samples/TTCatalog/Classes/TTCatalogAppDelegate.m
Expand Up @@ -3,14 +3,18 @@

@implementation TTCatalogAppDelegate

@synthesize window;
@synthesize navigationController;
@synthesize window, navigationController;

- (void)applicationDidFinishLaunching:(UIApplication *)application {
- (void)applicationDidFinishLaunching:(UIApplication*)application {
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}

- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application {
[[TTStyleSheet globalStyleSheet] freeMemory];
[[TTURLCache sharedCache] removeAll:NO];
}

- (void)dealloc {
[navigationController release];
[window release];
Expand Down
13 changes: 6 additions & 7 deletions src/TTActivityLabel.m
@@ -1,6 +1,6 @@
#import "Three20/TTActivityLabel.h"
#import "Three20/TTStyledView.h"
#import "Three20/TTAppearance.h"
#import "Three20/TTDefaultStyleSheet.h"
#import "Three20/TTButton.h"

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -48,10 +48,10 @@ - (id)initWithFrame:(CGRect)frame style:(TTActivityLabelStyle)style text:(NSStri
_bezelView = [[TTStyledView alloc] initWithFrame:CGRectZero];
if (_style == TTActivityLabelStyleBlackBezel || _style == TTActivityLabelStyleBlackThinBezel) {
_bezelView.opaque = NO;
_bezelView.style = [TTAppearance appearance].blackBezelStyle;
_bezelView.style = TTSTYLE(blackBezel);
} else if (_style == TTActivityLabelStyleWhiteBezel) {
_bezelView.opaque = NO;
_bezelView.style = [TTAppearance appearance].whiteBezelStyle;
_bezelView.style = TTSTYLE(whiteBezel);
} else if (_style == TTActivityLabelStyleWhiteBox) {
_bezelView.backgroundColor = [UIColor whiteColor];
self.backgroundColor = [UIColor whiteColor];
Expand Down Expand Up @@ -81,7 +81,7 @@ - (id)initWithFrame:(CGRect)frame style:(TTActivityLabelStyle)style text:(NSStri
_spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:
UIActivityIndicatorViewStyleGray];
_textView.font = [UIFont systemFontOfSize:17];
_textView.textColor = [TTAppearance appearance].tableActivityTextColor;
_textView.textColor = TTSTYLEVAR(tableActivityTextColor);
} else if (_style == TTActivityLabelStyleBlackBezel || _style == TTActivityLabelStyleBlackBox) {
_spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:
UIActivityIndicatorViewStyleWhiteLarge];
Expand Down Expand Up @@ -206,9 +206,8 @@ - (void)setShowsStopButton:(BOOL)showsStopButton {
_showsStopButton = showsStopButton;

if (_showsStopButton) {
_stopButton = [[TTButton buttonWithType:TTButtonTypeToolbar
title:TTLocalizedString(@"Stop", @"")
color:RGBCOLOR(0, 0, 0)] retain];
_stopButton = [[TTButton buttonWithStyle:@"blackToolbarButton:"
title:TTLocalizedString(@"Stop", @"")] retain];
[_stopButton addTarget:self action:@selector(touchedStopButton)
forControlEvents:UIControlEventTouchUpInside];
[_bezelView addSubview:_stopButton];
Expand Down

0 comments on commit 8da4a01

Please sign in to comment.