Permalink
Browse files

Merge pull request #739 from facebook/development

[Release] Three20 1.0.10
  • Loading branch information...
2 parents f4f9bc6 + 26b455e commit 9eb3580488538b4e33312e476a801d9722e53250 @diederich diederich committed Jan 5, 2012
@@ -21,8 +21,8 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self.title = @"Table Items";
self.variableHeightRows = YES;
- // Uncomment this to see how the table looks with the grouped style
- //self.tableViewStyle = UITableViewStyleGrouped;
+ // comment this to see how the table looks with the standard style
+ self.tableViewStyle = UITableViewStyleGrouped;
// Uncomment this to see how the table cells look against a custom background color
//self.tableView.backgroundColor = [UIColor yellowColor];
@@ -34,9 +34,12 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
// This demonstrates how to create a table with standard table "fields". Many of these
// fields with URLs that will be visited when the row is selected
self.dataSource = [TTSectionedDataSource dataSourceWithObjects:
- @"Links and Buttons",
+ @"Generic Items",
+ [TTTableSettingsItem itemWithText:Three20Version caption:@"Three20 Version"
+ URL:@"tt://tableItemTest"],
[TTTableTextItem itemWithText:@"TTTableTextItem" URL:@"tt://tableItemTest"
accessoryURL:@"http://www.google.com"],
+ [TTTableSection sectionWithHeaderTitle:@"Links & Buttons" footerTitle:nil],
[TTTableLink itemWithText:@"TTTableLink" URL:@"tt://tableItemTest"],
[TTTableButton itemWithText:@"TTTableButton"],
[TTTableCaptionItem itemWithText:@"TTTableCaptionItem" caption:@"caption"
@@ -47,7 +50,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
text:kLoremIpsum timestamp:[NSDate date] URL:@"tt://tableItemTest"],
[TTTableMoreButton itemWithText:@"TTTableMoreButton"],
- @"Images",
+ [TTTableSection sectionWithHeaderTitle:@"Images" footerTitle:@"Usage of images inside TTTableView"],
[TTTableImageItem itemWithText:@"TTTableImageItem" imageURL:localImage
URL:@"tt://tableItemTest"],
[TTTableRightImageItem itemWithText:@"TTTableRightImageItem" imageURL:localImage
Binary file not shown.
Binary file not shown.
@@ -22,8 +22,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
NSLocale* TTCurrentLocale() {
- NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
- NSArray* languages = [defaults objectForKey:@"AppleLanguages"];
+ NSArray* languages = [NSLocale preferredLanguages];
if (languages.count > 0) {
NSString* currentLanguage = [languages objectAtIndex:0];
return [[[NSLocale alloc] initWithLocaleIdentifier:currentLanguage] autorelease];
@@ -18,6 +18,6 @@
/*! \mainpage Three20 API Documentation
*
- * Generated from Three20 Release <a href="http://three20.info/roadmap/1.0.9">1.0.9</a>.
+ * Generated from Three20 Release <a href="http://three20.info/roadmap/1.0.10">1.0.10</a>.
*/
-NSString* const Three20Version = @"1.0.9";
+NSString* const Three20Version = @"1.0.10";
@@ -120,6 +120,13 @@ - (void)connectToURL:(NSURL*)URL {
TTNetworkRequestStarted();
TTURLRequest* request = _requests.count == 1 ? [_requests objectAtIndex:0] : nil;
+
+ // there are situations where urlPath is somehow nil (therefore crashing in
+ // createNSURLRequest:URL:, even if we checked for non-blank values before
+ // adding the request to the queue.
+ if (!request.urlPath.length)
+ [self cancel:request];
+
NSURLRequest* URLRequest = [_queue createNSURLRequest:request URL:URL];
_connection = [[NSURLConnection alloc] initWithRequest:URLRequest delegate:self];
@@ -0,0 +1,31 @@
+//
+// Copyright 2009-2011 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface TTTableSection : NSObject {
+ NSString* _headerTitle;
+ NSString* _footerTitle;
+}
+
+@property (nonatomic, copy) NSString* headerTitle;
+@property (nonatomic, copy) NSString* footerTitle;
+
+
++ (id)sectionWithHeaderTitle:(NSString*)headerTitle footerTitle:(NSString*)footerTitle;
+
+@end
@@ -0,0 +1,22 @@
+//
+// Copyright 2009-2011 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// UI
+#import "Three20UI/TTTableCaptionItem.h"
+
+@interface TTTableSettingsItem : TTTableCaptionItem
+
+@end
@@ -0,0 +1,24 @@
+//
+// Copyright 2009-2011 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// UI
+#import "Three20UI/TTTableLinkedItemCell.h"
+
+@interface TTTableSettingsItemCell : TTTableLinkedItemCell
+
+@property (nonatomic, readonly) UILabel* captionLabel;
+
+@end
@@ -90,6 +90,7 @@
#import "Three20UI/TTListDataSource.h"
#import "Three20UI/TTSectionedDataSource.h"
#import "Three20UI/TTTableHeaderView.h"
+#import "Three20UI/TTTableSection.h"
#import "Three20UI/TTTableFooterInfiniteScrollView.h"
#import "Three20UI/TTTableHeaderDragRefreshView.h"
#import "Three20UI/TTTableViewCell.h"
@@ -115,6 +116,7 @@
#import "Three20UI/TTTableStyledTextItem.h"
#import "Three20UI/TTTableControlItem.h"
#import "Three20UI/TTTableViewItem.h"
+#import "Three20UI/TTTableSettingsItem.h"
// Table Item Cells
#import "Three20UI/TTTableLinkedItemCell.h"
@@ -131,6 +133,7 @@
#import "Three20UI/TTTableActivityItemCell.h"
#import "Three20UI/TTTableControlCell.h"
#import "Three20UI/TTTableFlushViewCell.h"
+#import "Three20UI/TTTableSettingsItemCell.h"
#import "Three20UI/TTErrorView.h"
@@ -147,6 +147,7 @@ - (void)createFieldViews {
label.text = field.title;
label.font = TTSTYLEVAR(messageFont);
label.textColor = TTSTYLEVAR(messageFieldTextColor);
+ label.backgroundColor = TTSTYLEVAR(backgroundColor);
[label sizeToFit];
label.frame = CGRectInset(label.frame, -2, 0);
textField.leftView = label;
@@ -18,6 +18,7 @@
// UI
#import "Three20UI/TTTableItem.h"
+#import "Three20UI/TTTableSection.h"
// Core
#import "Three20Core/TTCorePreprocessorMacros.h"
@@ -67,7 +68,8 @@ + (TTSectionedDataSource*)dataSourceWithObjects:(id)object,... {
va_list ap;
va_start(ap, object);
while (object) {
- if ([object isKindOfClass:[NSString class]]) {
+ if ([object isKindOfClass:[NSString class]] ||
+ [object isKindOfClass:[TTTableSection class]]) {
[sections addObject:object];
section = [NSMutableArray array];
[items addObject:section];
@@ -90,7 +92,8 @@ + (TTSectionedDataSource*)dataSourceWithArrays:(id)object,... {
va_list ap;
va_start(ap, object);
while (object) {
- if ([object isKindOfClass:[NSString class]]) {
+ if ([object isKindOfClass:[NSString class]] ||
+ [object isKindOfClass:[TTTableSection class]]) {
[sections addObject:object];
} else {
@@ -137,7 +140,26 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
///////////////////////////////////////////////////////////////////////////////////////////////////
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if (_sections.count) {
- return [_sections objectAtIndex:section];
+ if ([[_sections objectAtIndex:section] isKindOfClass:[TTTableSection class]]) {
+ TTTableSection* sectionInfo = [_sections objectAtIndex:section];
+ return sectionInfo.headerTitle;
+
+ } else {
+ return [_sections objectAtIndex:section];
+ }
+
+ } else {
+ return nil;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
+ if (tableView.style==UITableViewStyleGrouped &&
+ _sections.count &&
+ [[_sections objectAtIndex:section] isKindOfClass:[TTTableSection class]]) {
+ TTTableSection* sectionInfo = [_sections objectAtIndex:section];
+ return sectionInfo.footerTitle;
} else {
return nil;
@@ -0,0 +1,51 @@
+//
+// Copyright 2009-2011 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#import "Three20UI/TTTableSection.h"
+
+// Core
+#import "Three20Core/TTCorePreprocessorMacros.h"
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+@implementation TTTableSection
+
+@synthesize headerTitle = _headerTitle;
+@synthesize footerTitle = _footerTitle;
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
++ (id)sectionWithHeaderTitle:(NSString*)headerTitle footerTitle:(NSString*)footerTitle {
+ TTTableSection* item = [[[self alloc] init] autorelease];
+ item.headerTitle = headerTitle;
+ item.footerTitle = footerTitle;
+ return item;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (void)dealloc {
+ TT_RELEASE_SAFELY(_headerTitle);
+ TT_RELEASE_SAFELY(_footerTitle);
+
+ [super dealloc];
+}
+
+
+@end
+
@@ -0,0 +1,26 @@
+//
+// Copyright 2009-2011 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#import "Three20UI/TTTableSettingsItem.h"
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+@implementation TTTableSettingsItem
+
+@end
+
@@ -0,0 +1,69 @@
+//
+// Copyright 2009-2011 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#import "Three20UI/TTTableSettingsItemCell.h"
+
+// UI
+#import "Three20UI/TTTableSettingsItem.h"
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+@implementation TTTableSettingsItemCell
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)identifier {
+ self = [super initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
+ if (self) {
+
+ }
+
+ return self;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark -
+#pragma mark TTTableViewCell
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (void)setObject:(id)object {
+ if (_item != object) {
+ [super setObject:object];
+
+ TTTableSettingsItem* item = object;
+ self.textLabel.text = item.caption;
+ self.detailTextLabel.text = item.text;
+ }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark -
+#pragma mark Public
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (UILabel*)captionLabel {
+ return self.textLabel;
+}
+
+
+@end
Oops, something went wrong.

0 comments on commit 9eb3580

Please sign in to comment.