Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jjfreitas/three20
base: master
...
head fork: jdelStrother/three20
compare: master
Checking mergeability… Don’t worry, you can still create the pull request.
  • 11 commits
  • 37 files changed
  • 0 commit comments
  • 2 contributors
Commits on May 20, 2009
@joehewitt joehewitt * Various minor bug fixes 35ed4fd
Commits on May 21, 2009
@joehewitt joehewitt * Fix calls to bad NSDate method 87059e9
Commits on May 27, 2009
@joehewitt joehewitt * Minor fixes 57bd904
Commits on May 29, 2009
@joehewitt joehewitt * Fix the photo viewer and message composer is iPhone OS 3.0 d77ad02
@joehewitt joehewitt * One more iPhone OS 3.0 fix
* Merged code from hboon
d75eef3
Commits on Jun 02, 2009
@joehewitt joehewitt * Better way to check for OS 3.0-specific code
* Shrink font a bit for titled table cells
* Fix a crash in text view table cells
c3c8ceb
Commits on Jun 03, 2009
@joehewitt joehewitt * New table cell for displaying a search bar
* New date category method for getting a date at midnight
* Fix styles of tab grids with only one row of tabs
1a71688
Commits on Jun 04, 2009
@joehewitt joehewitt * Ability to zoom the photo view controller to fit, and detect when i…
…t is zoomed

* New badge variation with smaller font size
b789448
Commits on Jun 10, 2009
@joehewitt joehewitt * Method to create an NSURLRequest from a TTURLRequest
* Method to load a request in a TTWebController
* Bug fixes in search bars
b5e86f3
Commits on Jun 12, 2009
Jonathan del Strother Fix leak on -[TTURLRequestLoader cancel:] bf49af8
Commits on Jul 03, 2009
Jonathan del Strother SDKROOT -> 3.0, DEPLOYMENT_TARGET -> 2.2.1
Having a nightmare persuading my app to run on both 2.2.1 & 3.0 without hardcoding these settings in three20's xcodeproj
Not quite ready to move to 3.0-only yet...
83ff6e5
Showing with 373 additions and 124 deletions.
  1. +1 −1  .gitignore
  2. +1 −1  README.mdown
  3. +8 −0 samples/TTCatalog/TTCatalog.xcodeproj/project.pbxproj
  4. +16 −4 src/NSDateAdditions.m
  5. +27 −3 src/TTDefaultStyleSheet.m
  6. +20 −0 src/TTGlobal.m
  7. +5 −1 src/TTMessageController.m
  8. +31 −19 src/TTPhotoViewController.m
  9. +9 −5 src/TTScrollView.m
  10. +3 −2 src/TTSearchBar.m
  11. +12 −11 src/TTSearchTextField.m
  12. +1 −1  src/TTStyledFrame.m
  13. +2 −1  src/TTStyledTextLabel.m
  14. +32 −19 src/TTTabBar.m
  15. +1 −10 src/TTTableField.m
  16. +51 −0 src/TTTableFieldCell.m
  17. +2 −2 src/TTTableView.m
  18. +4 −1 src/TTTableViewDataSource.m
  19. +0 −1  src/TTThumbsTableViewCell.m
  20. +18 −7 src/TTThumbsViewController.m
  21. +4 −0 src/TTURLRequest.m
  22. +35 −24 src/TTURLRequestQueue.m
  23. +6 −2 src/TTWebController.m
  24. +4 −2 src/Three20.xcodeproj/project.pbxproj
  25. +3 −1 src/Three20/NSDateAdditions.h
  26. +2 −0  src/Three20/TTDefaultStyleSheet.h
  27. +10 −0 src/Three20/TTGlobal.h
  28. +10 −0 src/Three20/TTScrollView.h
  29. +6 −1 src/Three20/TTTabBar.h
  30. +0 −2  src/Three20/TTTableField.h
  31. +7 −1 src/Three20/TTTableFieldCell.h
  32. +1 −0  src/Three20/TTThumbsViewController.h
  33. +2 −0  src/Three20/TTURLRequest.h
  34. +5 −0 src/Three20/TTURLRequestQueue.h
  35. +1 −0  src/Three20/TTWebController.h
  36. +5 −2 src/Three20/UIViewAdditions.h
  37. +28 −0 src/UIViewAdditions.m
View
2  .gitignore
@@ -2,5 +2,5 @@
build
*.pbxuser
*.perspectivev3
-*.modelv3
+*.mode1v3
.DS_Store
View
2  README.mdown
@@ -46,7 +46,7 @@ Three20 is compiled as a static library, and the easiest way to add it to your p
it. Add the relative path from your project's directory to the "three20/src" directory.
8. While you are in Project Settings, go to "Other Linker Flags" under the "Linker" section, and
- add "-ObjC" to the list of flags.
+ add "-ObjC" and "-all_load" to the list of flags.
9. You're ready to go. Just #import "Three20/Three20.h" anywhere you want to use Three20 classes
in your project.
View
8 samples/TTCatalog/TTCatalog.xcodeproj/project.pbxproj
@@ -388,6 +388,10 @@
GCC_PREFIX_HEADER = TTCatalog_Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
INFOPLIST_FILE = Info.plist;
+ OTHER_LDFLAGS = (
+ "-all_load",
+ "-ObjC",
+ );
PRODUCT_NAME = TTCatalog;
};
name = Debug;
@@ -400,6 +404,10 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = TTCatalog_Prefix.pch;
INFOPLIST_FILE = Info.plist;
+ OTHER_LDFLAGS = (
+ "-all_load",
+ "-ObjC",
+ );
PRODUCT_NAME = TTCatalog;
};
name = Release;
View
20 src/NSDateAdditions.m
@@ -4,10 +4,22 @@
@implementation NSDate (TTCategory)
-+ (id)dateWithToday {
- NSString* format = @"%Y-%m-%d 00:00:00 +0700";
- NSString* time = [[NSDate date] descriptionWithCalendarFormat:format timeZone:nil locale:nil];
- return [self dateWithString:time];
++ (NSDate*)dateWithToday {
+ NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
+ formatter.dateFormat = @"yyyy-d-M";
+
+ NSString* time = [formatter stringFromDate:[NSDate date]];
+ NSDate* date = [formatter dateFromString:time];
+ return date;
+}
+
+- (NSDate*)dateAtMidnight {
+ NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
+ formatter.dateFormat = @"yyyy-d-M";
+
+ NSString* time = [formatter stringFromDate:self];
+ NSDate* date = [formatter dateFromString:time];
+ return date;
}
@end
View
30 src/TTDefaultStyleSheet.m
@@ -181,7 +181,7 @@ - (TTStyle*)whiteBezel {
[TTSolidBorderStyle styleWithColor:RGBCOLOR(178, 178, 178) width:1 next:nil]]];
}
-- (TTStyle*)badge {
+- (TTStyle*)badgeWithFontSize:(CGFloat)fontSize {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:TT_ROUNDED] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(1, 1, 1, 1) next:
@@ -189,11 +189,19 @@ - (TTStyle*)badge {
[TTReflectiveFillStyle styleWithColor:RGBCOLOR(221, 17, 27) next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(-1, -1, -1, -1) next:
[TTSolidBorderStyle styleWithColor:[UIColor whiteColor] width:2 next:
- [TTBoxStyle styleWithPadding:UIEdgeInsetsMake(1, 6, 3, 6) next:
- [TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:13]
+ [TTBoxStyle styleWithPadding:UIEdgeInsetsMake(2, 7, 2, 7) next:
+ [TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:fontSize]
color:[UIColor whiteColor] next:nil]]]]]]]];
}
+- (TTStyle*)miniBadge {
+ return [self badgeWithFontSize:12];
+}
+
+- (TTStyle*)badge {
+ return [self badgeWithFontSize:15];
+}
+
- (TTStyle*)tabBar {
UIColor* border = [TTSTYLEVAR(tabBarTintColor) multiplyHue:0 saturation:0 value:0.7];
return
@@ -238,6 +246,10 @@ - (TTStyle*)tabGridTab:(UIControlState)state corner:(short)corner {
shape = [TTRoundedRectangleShape shapeWithTopLeft:0 topRight:0 bottomRight:8 bottomLeft:0];
} else if (corner == 4) {
shape = [TTRoundedRectangleShape shapeWithTopLeft:0 topRight:0 bottomRight:0 bottomLeft:8];
+ } else if (corner == 5) {
+ shape = [TTRoundedRectangleShape shapeWithTopLeft:8 topRight:0 bottomRight:0 bottomLeft:8];
+ } else if (corner == 6) {
+ shape = [TTRoundedRectangleShape shapeWithTopLeft:0 topRight:8 bottomRight:8 bottomLeft:0];
} else {
shape = [TTRectangleShape shape];
}
@@ -283,6 +295,14 @@ - (TTStyle*)tabGridTabBottomLeft:(UIControlState)state {
return [self tabGridTab:state corner:4];
}
+- (TTStyle*)tabGridTabLeft:(UIControlState)state {
+ return [self tabGridTab:state corner:5];
+}
+
+- (TTStyle*)tabGridTabRight:(UIControlState)state {
+ return [self tabGridTab:state corner:6];
+}
+
- (TTStyle*)tabGridTabCenter:(UIControlState)state {
return [self tabGridTab:state corner:0];
}
@@ -474,6 +494,10 @@ - (UIFont*)tableTitleFont {
return [UIFont boldSystemFontOfSize:13];
}
+- (UIFont*)tableTitleValueFont {
+ return [UIFont boldSystemFontOfSize:15];
+}
+
- (UIFont*)tableButtonFont {
return [UIFont boldSystemFontOfSize:13];
}
View
20 src/TTGlobal.m
@@ -89,6 +89,26 @@ void TTNetworkRequestStopped() {
}
}
+float TTOSVersion() {
+ return [[[UIDevice currentDevice] systemVersion] floatValue];
+}
+
+BOOL TTOSVersionIsAtLeast(float version) {
+ #ifdef __IPHONE_3_0
+ return 3.0 >= version;
+ #endif
+ #ifdef __IPHONE_2_2
+ return 2.2 >= version;
+ #endif
+ #ifdef __IPHONE_2_1
+ return 2.1 >= version;
+ #endif
+ #ifdef __IPHONE_2_0
+ return 2.0 >= version;
+ #endif
+ return NO;
+}
+
NSLocale* TTCurrentLocale() {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defaults objectForKey:@"AppleLanguages"];
View
6 src/TTMessageController.m
@@ -326,7 +326,11 @@ - (void)loadView {
CGRect innerFrame = CGRectMake(0, TOOLBAR_HEIGHT,
appFrame.size.width, appFrame.size.height - (TOOLBAR_HEIGHT+KEYBOARD_HEIGHT));
- _scrollView = [[TTComposeInnerScrollView alloc] initWithFrame:innerFrame];
+ if (TTOSVersionIsAtLeast(3.0)) {
+ _scrollView = [[[UIScrollView class] alloc] initWithFrame:innerFrame];
+ } else {
+ _scrollView = [[[TTComposeInnerScrollView class] alloc] initWithFrame:innerFrame];
+ }
_scrollView.backgroundColor = TTSTYLEVAR(backgroundColor);
_scrollView.canCancelContentTouches = NO;
_scrollView.showsVerticalScrollIndicator = NO;
View
50 src/TTPhotoViewController.m
@@ -3,6 +3,7 @@
#import "Three20/TTURLRequest.h"
#import "Three20/TTUnclippedView.h"
#import "Three20/TTPhotoView.h"
+#import "Three20/TTURLRequestQueue.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -42,11 +43,16 @@ - (id)init {
self.navigationBarStyle = UIBarStyleBlackTranslucent;
self.navigationBarTintColor = nil;
self.statusBarStyle = UIStatusBarStyleBlackTranslucent;
+
+ if ([self respondsToSelector:@selector(setWantsFullScreenLayout:)]) {
+ [self setWantsFullScreenLayout:YES];
+ }
}
return self;
}
- (void)dealloc {
+ [[TTURLRequestQueue mainQueue] cancelRequestsWithDelegate:self];
[_thumbsController release];
[_slideshowTimer invalidate];
_slideshowTimer = nil;
@@ -294,18 +300,20 @@ - (void)previousAction {
}
- (void)showBarsAnimationDidStop {
- _innerView.top = -CHROME_HEIGHT;
- self.view.top = TOOLBAR_HEIGHT;
- self.view.height -= TOOLBAR_HEIGHT;
-
+ if (!TTOSVersionIsAtLeast(3.0)) {
+ _innerView.top = -CHROME_HEIGHT;
+ self.view.top = TOOLBAR_HEIGHT;
+ self.view.height -= TOOLBAR_HEIGHT;
+ }
self.navigationController.navigationBarHidden = NO;
}
- (void)hideBarsAnimationDidStop {
- _innerView.top = -STATUS_HEIGHT;
- self.view.top = 0;
- self.view.height += TOOLBAR_HEIGHT;
-
+ if (!TTOSVersionIsAtLeast(3.0)) {
+ _innerView.top = -STATUS_HEIGHT;
+ self.view.top = 0;
+ self.view.height += TOOLBAR_HEIGHT;
+ }
self.navigationController.navigationBarHidden = YES;
}
@@ -316,7 +324,8 @@ - (void)loadView {
CGRect screenFrame = [UIScreen mainScreen].bounds;
self.view = [[[TTUnclippedView alloc] initWithFrame:screenFrame] autorelease];
- CGRect innerFrame = CGRectMake(0, -CHROME_HEIGHT,
+ CGFloat y = TTOSVersionIsAtLeast(3.0) ? 0 : -CHROME_HEIGHT;
+ CGRect innerFrame = CGRectMake(0, y,
screenFrame.size.width, screenFrame.size.height + CHROME_HEIGHT);
_innerView = [[UIView alloc] initWithFrame:innerFrame];
[self.view addSubview:_innerView];
@@ -352,14 +361,16 @@ - (void)loadView {
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
- if (!self.nextViewController) {
- self.view.superview.frame = CGRectOffset(self.view.superview.frame, 0, TOOLBAR_HEIGHT);
- }
-
- [self hideBarsAnimationDidStop];
- [self showBarsAnimationDidStop];
- if (!_toolbar.alpha) {
+ if (!TTOSVersionIsAtLeast(3.0)) {
+ if (!self.nextViewController) {
+ self.view.superview.frame = CGRectOffset(self.view.superview.frame, 0, TOOLBAR_HEIGHT);
+ }
+
[self hideBarsAnimationDidStop];
+ [self showBarsAnimationDidStop];
+ if (!_toolbar.alpha) {
+ [self hideBarsAnimationDidStop];
+ }
}
}
@@ -368,9 +379,10 @@ - (void)viewWillDisappear:(BOOL)animated {
[self pauseAction];
- self.view.superview.frame = CGRectOffset(self.view.superview.frame, 0, TOOLBAR_HEIGHT);
- self.view.frame = CGRectOffset(self.view.frame, 0, -TOOLBAR_HEIGHT);
-
+ if (!TTOSVersionIsAtLeast(3.0)) {
+ self.view.superview.frame = CGRectOffset(self.view.superview.frame, 0, TOOLBAR_HEIGHT);
+ self.view.frame = CGRectOffset(self.view.frame, 0, -TOOLBAR_HEIGHT);
+ }
if (self.nextViewController) {
[self showBars:YES animated:NO];
}
View
14 src/TTScrollView.m
@@ -102,10 +102,6 @@ - (BOOL)pulled {
return _pageEdges.left > 0 || _pageEdges.top > 0 || _pageEdges.right < 0 || _pageEdges.bottom < 0;
}
-- (BOOL)zoomed {
- return _pageEdges.left != _pageEdges.right || _pageEdges.top != _pageEdges.bottom;
-}
-
- (BOOL)flicked {
if (!self.flipped) {
if (_pageEdges.left > kFlickThreshold && ![self isFirstPage]) {
@@ -996,7 +992,7 @@ - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
} else if (touch.tapCount == 2 && self.canZoom) {
CGPoint pt = [self touchLocation:touch];
if (self.zoomed) {
- [self startAnimationTo:[self reversePageEdges] duration:kFlickDuration];
+ [self zoomToFit];
} else {
[self startAnimationTo:[self zoomPageEdgesTo:pt] duration:kFlickDuration];
}
@@ -1029,6 +1025,10 @@ - (void)deviceOrientationDidChange:(void*)object {
///////////////////////////////////////////////////////////////////////////////////////////////////
+- (BOOL)zoomed {
+ return _pageEdges.left != _pageEdges.right || _pageEdges.top != _pageEdges.bottom;
+}
+
- (void)setDataSource:(id<TTScrollViewDataSource>)dataSource {
_dataSource = dataSource;
[self reloadData];
@@ -1132,4 +1132,8 @@ - (UIView*)pageAtIndex:(NSInteger)pageIndex {
return [self pageAtIndex:pageIndex create:NO];
}
+- (void)zoomToFit {
+ [self startAnimationTo:[self reversePageEdges] duration:kFlickDuration];
+}
+
@end
View
5 src/TTSearchBar.m
@@ -70,8 +70,9 @@ - (void)scrollToTop {
UIScrollView* scrollView = (UIScrollView*)[self firstParentOfClass:[UIScrollView class]];
if (scrollView) {
CGPoint offset = scrollView.contentOffset;
- if (offset.y != self.top) {
- [scrollView setContentOffset:CGPointMake(offset.x, self.top) animated:YES];
+ CGPoint myOffset = [self offsetFromView:scrollView];
+ if (offset.y != myOffset.y) {
+ [scrollView setContentOffset:CGPointMake(offset.x, myOffset.y) animated:YES];
}
}
}
View
23 src/TTSearchTextField.m
@@ -2,6 +2,7 @@
#import "Three20/TTNavigationCenter.h"
#import "Three20/TTView.h"
#import "Three20/TTDefaultStyleSheet.h"
+#import "Three20/TTTableView.h"
#import "Three20/TTTableFieldCell.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -62,10 +63,6 @@ - (void)textFieldDidEndEditing:(UITextField *)textField {
if ([_delegate respondsToSelector:@selector(textFieldDidEndEditing:)]) {
[_delegate textFieldDidEndEditing:textField];
}
-
- if (_textField.dataSource) {
- textField.text = @"";
- }
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range
@@ -103,7 +100,7 @@ - (BOOL)textFieldShouldReturn:(UITextField *)textField {
if (!_textField.searchesAutomatically) {
[_textField search];
} else {
- [_textField resignFirstResponder];
+ [_textField performSelector:@selector(doneAction)];
}
}
return shouldReturn;
@@ -221,6 +218,7 @@ - (void)autoSearch {
[self search];
}
}
+
- (void)dispatchUpdate:(NSTimer*)timer {
_searchTimer = nil;
[self autoSearch];
@@ -252,6 +250,10 @@ - (void)screenAnimationDidStop {
- (void)doneAction {
[self resignFirstResponder];
+
+ if (self.dataSource) {
+ self.text = @"";
+ }
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -363,7 +365,7 @@ - (void)setDataSource:(id<TTTableViewDataSource>)dataSource {
- (UITableView*)tableView {
if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
+ _tableView = [[TTTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.backgroundColor = TTSTYLEVAR(searchTableBackgroundColor);
_tableView.separatorColor = TTSTYLEVAR(searchTableSeparatorColor);
_tableView.rowHeight = _rowHeight;
@@ -420,12 +422,11 @@ - (void)showSearchResults:(BOOL)show {
[superview addSubview:_shadowView];
}
}
+
+ [_tableView deselectRowAtIndexPath:_tableView.indexPathForSelectedRow animated:NO];
} else {
- UIView* parent = self.superview;
- if (parent) {
- [_tableView removeFromSuperview];
- [_shadowView removeFromSuperview];
- }
+ [_tableView removeFromSuperview];
+ [_shadowView removeFromSuperview];
}
}
View
2  src/TTStyledFrame.m
@@ -158,7 +158,7 @@ - (void)drawInRect:(CGRect)rect {
}
- (TTStyledBoxFrame*)hitTest:(CGPoint)point {
- if (CGRectContainsPoint(CGRectInset(_bounds, 0, -5), point)) {
+ if (CGRectContainsPoint(_bounds, point)) {
TTStyledBoxFrame* frame = [_firstChildFrame hitTest:point];
return frame ? frame : self;
} else if (_nextFrame) {
View
3  src/TTStyledTextLabel.m
@@ -163,7 +163,8 @@ - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
[_highlightedNode performDefaultAction];
[self setHighlightedFrame:nil];
}
-
+ }
+ if (!tableView || TTOSVersionIsAtLeast(3.0)) {
// We definitely don't want to call this if the label is inside a TTTableView, because
// it winds up calling touchesEnded on the table twice, triggering the link twice
[super touchesEnded:touches withEvent:event];
View
51 src/TTTabBar.m
@@ -302,15 +302,13 @@ - (void)setTabItems:(NSArray*)tabItems {
@implementation TTTabGrid
+@synthesize columnCount = _columnCount;
+
///////////////////////////////////////////////////////////////////////////////////////////////////
// private
-- (NSInteger)columnCount {
- return 3;
-}
-
- (NSInteger)rowCount {
- return ceil((float)self.tabViews.count / [self columnCount]);
+ return ceil((float)self.tabViews.count / self.columnCount);
}
- (void)updateTabStyles {
@@ -318,20 +316,34 @@ - (void)updateTabStyles {
int rowCount = [self rowCount];
int cellCount = rowCount * columnCount;
- int column = 0;
- for (TTTab* tab in self.tabViews) {
- if (column == 0) {
- [tab setStylesWithSelector:@"tabGridTabTopLeft:"];
- } else if (column == columnCount-1) {
- [tab setStylesWithSelector:@"tabGridTabTopRight:"];
- } else if (column == cellCount - columnCount) {
- [tab setStylesWithSelector:@"tabGridTabBottomLeft:"];
- } else if (column == cellCount - 1) {
- [tab setStylesWithSelector:@"tabGridTabBottomRight:"];
- } else {
- [tab setStylesWithSelector:@"tabGridTabCenter:"];
+ if (self.tabViews.count > columnCount) {
+ int column = 0;
+ for (TTTab* tab in self.tabViews) {
+ if (column == 0) {
+ [tab setStylesWithSelector:@"tabGridTabTopLeft:"];
+ } else if (column == columnCount-1) {
+ [tab setStylesWithSelector:@"tabGridTabTopRight:"];
+ } else if (column == cellCount - columnCount) {
+ [tab setStylesWithSelector:@"tabGridTabBottomLeft:"];
+ } else if (column == cellCount - 1) {
+ [tab setStylesWithSelector:@"tabGridTabBottomRight:"];
+ } else {
+ [tab setStylesWithSelector:@"tabGridTabCenter:"];
+ }
+ ++column;
+ }
+ } else {
+ int column = 0;
+ for (TTTab* tab in self.tabViews) {
+ if (column == 0) {
+ [tab setStylesWithSelector:@"tabGridTabLeft:"];
+ } else if (column == columnCount-1) {
+ [tab setStylesWithSelector:@"tabGridTabRight:"];
+ } else {
+ [tab setStylesWithSelector:@"tabGridTabCenter:"];
+ }
+ ++column;
}
- ++column;
}
}
@@ -352,6 +364,7 @@ - (CGSize)layoutTabs {
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.style = TTSTYLE(tabGrid);
+ _columnCount = 3;
}
return self;
}
@@ -386,7 +399,7 @@ @implementation TTTab
- (id)initWithItem:(TTTabItem*)tabItem tabBar:(TTTabBar*)tabBar {
if (self = [self initWithFrame:CGRectZero]) {
_badge = nil;
-
+
self.tabItem = tabItem;
}
return self;
View
11 src/TTTableField.m
@@ -306,26 +306,17 @@ - (void)dealloc {
@implementation TTTextViewTableField
-@synthesize delegate = _delegate, placeholder = _placeholder, text = _text;
-
-- (id)initWithText:(NSString*)text {
- if (self = [self init]) {
- self.text = text;
- }
- return self;
-}
+@synthesize delegate = _delegate, placeholder = _placeholder;
- (id)init {
if (self = [super init]) {
_delegate = nil;
_placeholder = nil;
- _text = nil;
}
return self;
}
- (void)dealloc {
- [_text release];
[_placeholder release];
[super dealloc];
}
View
51 src/TTTableFieldCell.m
@@ -9,6 +9,7 @@
#import "Three20/TTNavigationCenter.h"
#import "Three20/TTURLCache.h"
#import "Three20/TTDefaultStyleSheet.h"
+#import "Three20/TTSearchBar.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -267,6 +268,10 @@ - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString*)identifier {
_titleLabel.highlightedTextColor = TTSTYLEVAR(highlightedTextColor);
_titleLabel.textAlignment = UITextAlignmentRight;
[self.contentView addSubview:_titleLabel];
+
+ _label.font = TTSTYLEVAR(tableTitleValueFont);
+ _label.adjustsFontSizeToFitWidth = YES;
+ _label.minimumFontSize = 8;
}
return self;
}
@@ -1139,3 +1144,49 @@ - (void)valueChanged {
}
@end
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+@implementation TTSearchBarTableFieldCell
+
++ (CGFloat)tableView:(UITableView*)tableView rowHeightForItem:(id)item {
+ return TOOLBAR_HEIGHT;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString*)identifier {
+ if (self = [super initWithFrame:frame reuseIdentifier:identifier]) {
+ _searchBar = nil;
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [_searchBar release];
+ [super dealloc];
+}
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ _searchBar.frame = self.contentView.bounds;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// TTTableViewCell
+
+- (id)object {
+ return _searchBar;
+}
+
+- (void)setObject:(id)object {
+ if (_searchBar != object) {
+ [_searchBar removeFromSuperview];
+ [_searchBar release];
+ _searchBar = [object retain];
+ [self.contentView addSubview:_searchBar];
+ }
+}
+
+@end
+
View
4 src/TTTableView.m
@@ -152,7 +152,7 @@ - (void)showMenu:(UIView*)view forCell:(UITableViewCell*)cell animated:(BOOL)ani
// Move each content subview down, revealing the menu
for (UIView* view in _menuCell.contentView.subviews) {
if (view != _menuView) {
- view.top += _menuCell.contentView.height;
+ view.left -= _menuCell.contentView.width;
}
}
@@ -172,7 +172,7 @@ - (void)hideMenu:(BOOL)animated {
for (UIView* view in _menuCell.contentView.subviews) {
if (view != _menuView) {
- view.top -= _menuCell.contentView.height;
+ view.left += _menuCell.contentView.width;
}
}
View
5 src/TTTableViewDataSource.m
@@ -2,6 +2,7 @@
#import "Three20/TTTableField.h"
#import "Three20/TTTableFieldCell.h"
#import "Three20/TTURLCache.h"
+#import "Three20/TTSearchBar.h"
#import <objc/runtime.h>
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -138,6 +139,8 @@ - (Class)tableView:(UITableView*)tableView cellClassForObject:(id)object {
} else {
return [TTTextTableFieldCell class];
}
+ } else if ([object isKindOfClass:[TTSearchBar class]]) {
+ return [TTSearchBarTableFieldCell class];
}
// This will display an empty white table cell - probably not what you want, but it
@@ -369,7 +372,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- if (_sections) {
+ if (_sections.count) {
NSArray* items = [_items objectAtIndex:section];
return items.count;
} else {
View
1  src/TTThumbsTableViewCell.m
@@ -151,7 +151,6 @@ - (void)setPhoto:(id<TTPhoto>)photo {
_thumbView1.thumbURL = [_photo urlForVersion:TTPhotoVersionThumbnail];
[self assignPhotoAtIndex:_photo.index+1 toView:_thumbView2];
- [self assignPhotoAtIndex:_photo.index+1 toView:_thumbView2];
[self assignPhotoAtIndex:_photo.index+2 toView:_thumbView3];
[self assignPhotoAtIndex:_photo.index+3 toView:_thumbView4];
}
View
25 src/TTThumbsViewController.m
@@ -29,13 +29,15 @@ - (BOOL)hasMoreToLoad {
- (id)initWithController:(TTThumbsViewController*)controller {
if (self = [super init]) {
_controller = controller;
- [_controller.photoSource.delegates addObject:self];
+ _photoSource = [_controller.photoSource retain];
+ [_photoSource.delegates addObject:self];
}
return self;
}
- (void)dealloc {
- [_controller.photoSource.delegates removeObject:self];
+ [_photoSource.delegates removeObject:self];
+ [_photoSource release];
[super dealloc];
}
@@ -192,6 +194,10 @@ - (id)init {
self.navigationBarStyle = UIBarStyleBlackTranslucent;
self.navigationBarTintColor = nil;
self.statusBarStyle = UIStatusBarStyleBlackTranslucent;
+
+ if ([self respondsToSelector:@selector(setWantsFullScreenLayout:)]) {
+ [self setWantsFullScreenLayout:YES];
+ }
}
return self;
@@ -212,9 +218,10 @@ - (void)loadView {
self.view.autoresizesSubviews = YES;
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- CGRect innerFrame = CGRectMake(0, -CHROME_HEIGHT,
+ CGFloat y = TTOSVersionIsAtLeast(3.0) ? 0 : -CHROME_HEIGHT;
+ CGRect innerFrame = CGRectMake(0, y,
screenFrame.size.width, screenFrame.size.height + CHROME_HEIGHT);
- UIView* innerView = [[UIView alloc] initWithFrame:innerFrame];
+ UIView* innerView = [[[UIView alloc] initWithFrame:innerFrame] autorelease];
innerView.backgroundColor = TTSTYLEVAR(backgroundColor);
[self.view addSubview:innerView];
@@ -236,15 +243,19 @@ - (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self suspendLoadingThumbnails:NO];
- if (!self.nextViewController) {
- self.view.superview.frame = CGRectOffset(self.view.superview.frame, 0, TOOLBAR_HEIGHT);
+ if (!TTOSVersionIsAtLeast(3.0)) {
+ if (!self.nextViewController) {
+ self.view.superview.frame = CGRectOffset(self.view.superview.frame, 0, TOOLBAR_HEIGHT);
+ }
}
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
- self.view.superview.frame = CGRectOffset(self.view.superview.frame, 0, TOOLBAR_HEIGHT);
+ if (!TTOSVersionIsAtLeast(3.0)) {
+ self.view.superview.frame = CGRectOffset(self.view.superview.frame, 0, TOOLBAR_HEIGHT);
+ }
}
- (void)viewDidDisappear:(BOOL)animated {
View
4 src/TTURLRequest.m
@@ -206,6 +206,10 @@ - (void)cancel {
[[TTURLRequestQueue mainQueue] cancelRequest:self];
}
+- (NSURLRequest*)createNSURLRequest {
+ return [[TTURLRequestQueue mainQueue] createNSURLRequest:self url:nil];
+}
+
@end
//////////////////////////////////////////////////////////////////////////////////////////////////
View
59 src/TTURLRequestQueue.m
@@ -87,31 +87,9 @@ - (void)connectToURL:(NSURL*)url {
TTLOG(@"Connecting to %@", _url);
TTNetworkRequestStarted();
- NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url
- cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
- timeoutInterval:kTimeout];
- [urlRequest setValue:_queue.userAgent forHTTPHeaderField:@"User-Agent"];
+ TTURLRequest* request = _requests.count == 1 ? [_requests objectAtIndex:0] : nil;
+ NSURLRequest *urlRequest = [_queue createNSURLRequest:request url:url];
- if (_requests.count == 1) {
- TTURLRequest* request = [_requests objectAtIndex:0];
- [urlRequest setHTTPShouldHandleCookies:request.shouldHandleCookies];
-
- NSString* method = request.httpMethod;
- if (method) {
- [urlRequest setHTTPMethod:method];
- }
-
- NSString* contentType = request.contentType;
- if (contentType) {
- [urlRequest setValue:contentType forHTTPHeaderField:@"Content-Type"];
- }
-
- NSData* body = request.httpBody;
- if (body) {
- [urlRequest setHTTPBody:body];
- }
- }
-
_connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
}
@@ -263,6 +241,7 @@ - (BOOL)cancel:(TTURLRequest*)request {
if (_connection) {
TTNetworkRequestStopped();
[_connection cancel];
+ [_connection release];
_connection = nil;
}
return NO;
@@ -611,4 +590,36 @@ - (void)cancelAllRequests {
}
}
+- (NSURLRequest*)createNSURLRequest:(TTURLRequest*)request url:(NSURL*)url {
+ if (!url) {
+ url = [NSURL URLWithString:request.url];
+ }
+
+ NSMutableURLRequest* urlRequest = [NSMutableURLRequest requestWithURL:url
+ cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
+ timeoutInterval:kTimeout];
+ [urlRequest setValue:self.userAgent forHTTPHeaderField:@"User-Agent"];
+
+ if (request) {
+ [urlRequest setHTTPShouldHandleCookies:request.shouldHandleCookies];
+
+ NSString* method = request.httpMethod;
+ if (method) {
+ [urlRequest setHTTPMethod:method];
+ }
+
+ NSString* contentType = request.contentType;
+ if (contentType) {
+ [urlRequest setValue:contentType forHTTPHeaderField:@"Content-Type"];
+ }
+
+ NSData* body = request.httpBody;
+ if (body) {
+ [urlRequest setHTTPBody:body];
+ }
+ }
+
+ return urlRequest;
+}
+
@end
View
8 src/TTWebController.m
@@ -169,6 +169,11 @@ - (NSURL*)url {
return _webView.request.URL;
}
+- (void)openRequest:(NSURLRequest*)request {
+ self.view;
+ [_webView loadRequest:request];
+}
+
- (void)setHeaderView:(UIView*)headerView {
if (headerView != _headerView) {
BOOL addingHeader = !_headerView && headerView;
@@ -195,9 +200,8 @@ - (void)setHeaderView:(UIView*)headerView {
}
- (void)openURL:(NSURL*)url {
- self.view;
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
- [_webView loadRequest:request];
+ [self openRequest:request];
}
@end
View
6 src/Three20.xcodeproj/project.pbxproj
@@ -775,10 +775,11 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = .;
+ IPHONEOS_DEPLOYMENT_TARGET = 2.2.1;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ObjC";
PREBINDING = NO;
- SDKROOT = iphonesimulator2.2;
+ SDKROOT = iphoneos3.0;
};
name = Debug;
};
@@ -790,9 +791,10 @@
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 2.2.1;
OTHER_LDFLAGS = "-ObjC";
PREBINDING = NO;
- SDKROOT = iphonesimulator2.2;
+ SDKROOT = iphoneos3.0;
};
name = Release;
};
View
4 src/Three20/NSDateAdditions.h
@@ -3,6 +3,8 @@
@interface NSDate (TTCategory)
-+ (id)dateWithToday;
++ (NSDate*)dateWithToday;
+
+- (NSDate*)dateAtMidnight;
@end
View
2  src/Three20/TTDefaultStyleSheet.h
@@ -41,6 +41,7 @@
@property(nonatomic,readonly) UIFont* tableFont;
@property(nonatomic,readonly) UIFont* tableSmallFont;
@property(nonatomic,readonly) UIFont* tableTitleFont;
+@property(nonatomic,readonly) UIFont* tableTitleValueFont;
@property(nonatomic,readonly) UIFont* tableButtonFont;
@property(nonatomic,readonly) UIFont* tableSummaryFont;
@property(nonatomic,readonly) UIFont* photoCaptionFont;
@@ -54,4 +55,5 @@
- (TTStyle*)selectionFillStyle:(TTStyle*)next;
+
@end
View
10 src/Three20/TTGlobal.h
@@ -187,6 +187,16 @@ void TTNetworkRequestStarted();
void TTNetworkRequestStopped();
/**
+ * Gets the current runtime version of iPhone OS.
+ */
+float TTOSVersion();
+
+/**
+ * Checks if the link-time version of the OS is at least a certain version.
+ */
+BOOL TTOSVersionIsAtLeast(float version);
+
+/**
* Gets the current system locale chosen by the user.
*
* This is necessary because [NSLocale currentLocale] always returns en_US.
View
10 src/Three20/TTScrollView.h
@@ -53,6 +53,11 @@
/**
*
*/
+@property(nonatomic,readonly) BOOL zoomed;
+
+/**
+ *
+ */
@property(nonatomic) BOOL scrollEnabled;
/**
@@ -107,6 +112,11 @@
*/
- (UIView*)pageAtIndex:(NSInteger)pageIndex;
+/**
+ *
+ */
+- (void)zoomToFit;
+
@end
///////////////////////////////////////////////////////////////////////////////////////////////////
View
7 src/Three20/TTTabBar.h
@@ -40,7 +40,12 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
-@interface TTTabGrid : TTTabBar
+@interface TTTabGrid : TTTabBar {
+ NSInteger _columnCount;
+}
+
+@property(nonatomic) NSInteger columnCount;
+
@end
///////////////////////////////////////////////////////////////////////////////////////////////////
View
2  src/Three20/TTTableField.h
@@ -156,8 +156,6 @@
@property(nonatomic,assign) id<UITextViewDelegate> delegate;
@property(nonatomic,copy) NSString* placeholder;
-- (id)initWithText:(NSString*)text;
-
@end
@interface TTSwitchTableField : TTTableField {
View
8 src/Three20/TTTableFieldCell.h
@@ -1,6 +1,6 @@
#import "Three20/TTTableViewCell.h"
-@class TTTableField, TTImageView, TTErrorView, TTActivityLabel, TTStyledTextLabel;
+@class TTTableField, TTImageView, TTErrorView, TTActivityLabel, TTStyledTextLabel, TTSearchBar;
@interface TTTableFieldCell : TTTableViewCell {
TTTableField* _field;
@@ -80,3 +80,9 @@
}
@end
+
+@interface TTSearchBarTableFieldCell : TTTableViewCell {
+ TTSearchBar* _searchBar;
+}
+
+@end
View
1  src/Three20/TTThumbsViewController.h
@@ -22,6 +22,7 @@
@interface TTThumbsDataSource : TTDataSource
<TTPhotoSourceDelegate, TTThumbsTableViewCellDelegate> {
TTThumbsViewController* _controller;
+ id<TTPhotoSource> _photoSource;
}
- (id)initWithController:(TTThumbsViewController*)controller;
View
2  src/Three20/TTURLRequest.h
@@ -101,6 +101,8 @@
*/
- (void)cancel;
+- (NSURLRequest*)createNSURLRequest;
+
@end
///////////////////////////////////////////////////////////////////////////////////////////////////
View
5 src/Three20/TTURLRequestQueue.h
@@ -76,4 +76,9 @@
*/
- (void)cancelAllRequests;
+/**
+ * Creates a Cocoa URL request from a Three20 URL request.
+ */
+- (NSURLRequest*)createNSURLRequest:(TTURLRequest*)request url:(NSURL*)url;
+
@end
View
1  src/Three20/TTWebController.h
@@ -19,6 +19,7 @@
@property(nonatomic,retain) UIView* headerView;
- (void)openURL:(NSURL*)url;
+- (void)openRequest:(NSURLRequest*)request;
@end
View
7 src/Three20/UIViewAdditions.h
@@ -5,12 +5,15 @@
@property(nonatomic) CGFloat left;
@property(nonatomic) CGFloat top;
-@property(nonatomic,readonly) CGFloat right;
-@property(nonatomic,readonly) CGFloat bottom;
+@property(nonatomic) CGFloat right;
+@property(nonatomic) CGFloat bottom;
@property(nonatomic) CGFloat width;
@property(nonatomic) CGFloat height;
+@property(nonatomic) CGFloat centerX;
+@property(nonatomic) CGFloat centerY;
+
@property(nonatomic,readonly) CGFloat screenX;
@property(nonatomic,readonly) CGFloat screenY;
@property(nonatomic,readonly) CGFloat screenViewX;
View
28 src/UIViewAdditions.m
@@ -112,10 +112,38 @@ - (CGFloat)right {
return self.frame.origin.x + self.frame.size.width;
}
+- (void)setRight:(CGFloat)right {
+ CGRect frame = self.frame;
+ frame.origin.x = right - frame.size.width;
+ self.frame = frame;
+}
+
- (CGFloat)bottom {
return self.frame.origin.y + self.frame.size.height;
}
+- (void)setBottom:(CGFloat)bottom {
+ CGRect frame = self.frame;
+ frame.origin.y = bottom - frame.size.height;
+ self.frame = frame;
+}
+
+- (CGFloat)centerX {
+ return self.center.x;
+}
+
+- (void)setCenterX:(CGFloat)centerX {
+ self.center = CGPointMake(centerX, self.center.y);
+}
+
+- (CGFloat)centerY {
+ return self.center.y;
+}
+
+- (void)setCenterY:(CGFloat)centerY {
+ self.center = CGPointMake(self.center.x, centerY);
+}
+
- (CGFloat)width {
return self.frame.size.width;
}

No commit comments for this range

Something went wrong with that request. Please try again.