Skip to content

Commit

Permalink
added TTTableSettingsItem& TTTableSettingsItemCell which emulate the …
Browse files Browse the repository at this point in the history
…same style of UITableViewCellStyleValue1 (settings table cell)
  • Loading branch information
Adar Porat committed Sep 11, 2011
1 parent 74e89de commit 5cdf37e
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 0 deletions.
3 changes: 3 additions & 0 deletions samples/TTCatalog/Classes/TableItemTestController.m
Expand Up @@ -34,6 +34,9 @@ - (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:
@"Generic Items",
[TTTableSettingsItem itemWithText:Three20Version caption:@"Three20 Version"
URL:@"tt://tableItemTest"],
@"Links and Buttons",
[TTTableTextItem itemWithText:@"TTTableTextItem" URL:@"tt://tableItemTest"
accessoryURL:@"http://www.google.com"],
Expand Down
22 changes: 22 additions & 0 deletions src/Three20UI/Headers/TTTableSettingsItem.h
@@ -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
24 changes: 24 additions & 0 deletions src/Three20UI/Headers/TTTableSettingsItemCell.h
@@ -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
2 changes: 2 additions & 0 deletions src/Three20UI/Headers/Three20UI.h
Expand Up @@ -115,6 +115,7 @@
#import "Three20UI/TTTableStyledTextItem.h"
#import "Three20UI/TTTableControlItem.h"
#import "Three20UI/TTTableViewItem.h"
#import "Three20UI/TTTableSettingsItem.h"

// Table Item Cells
#import "Three20UI/TTTableLinkedItemCell.h"
Expand All @@ -131,6 +132,7 @@
#import "Three20UI/TTTableActivityItemCell.h"
#import "Three20UI/TTTableControlCell.h"
#import "Three20UI/TTTableFlushViewCell.h"
#import "Three20UI/TTTableSettingsItemCell.h"

#import "Three20UI/TTErrorView.h"

Expand Down
26 changes: 26 additions & 0 deletions src/Three20UI/Sources/TTTableSettingsItem.m
@@ -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

69 changes: 69 additions & 0 deletions src/Three20UI/Sources/TTTableSettingsItemCell.m
@@ -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
5 changes: 5 additions & 0 deletions src/Three20UI/Sources/TTTableViewDataSource.m
Expand Up @@ -32,6 +32,7 @@
#import "Three20UI/TTTableTextItem.h"
#import "Three20UI/TTTableActivityItem.h"
#import "Three20UI/TTTableControlItem.h"
#import "Three20UI/TTTableSettingsItem.h"

// - Table Cells
#import "Three20UI/TTTableMoreButtonCell.h"
Expand All @@ -47,6 +48,7 @@
#import "Three20UI/TTTableTextItemCell.h"
#import "Three20UI/TTStyledTextTableCell.h"
#import "Three20UI/TTTableFlushViewCell.h"
#import "Three20UI/TTTableSettingsItemCell.h"

// Style
#import "Three20Style/TTStyledText.h"
Expand Down Expand Up @@ -252,6 +254,9 @@ - (Class)tableView:(UITableView*)tableView cellClassForObject:(id)object {
if ([object isKindOfClass:[TTTableMoreButton class]]) {
return [TTTableMoreButtonCell class];

} else if ([object isKindOfClass:[TTTableSettingsItem class]]) {
return [TTTableSettingsItemCell class];

} else if ([object isKindOfClass:[TTTableSubtextItem class]]) {
return [TTTableSubtextItemCell class];

Expand Down
16 changes: 16 additions & 0 deletions src/Three20UI/Three20UI.xcodeproj/project.pbxproj
Expand Up @@ -18,6 +18,10 @@
66F2E85F12D426DA006FB485 /* TTTableViewNetworkEnabledDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 66F2E85D12D426DA006FB485 /* TTTableViewNetworkEnabledDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
66F2E86512D426EF006FB485 /* TTTableViewNetworkEnabledDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 66F2E86312D426EF006FB485 /* TTTableViewNetworkEnabledDelegate.m */; };
6DB1E37D13CA885B00A72466 /* TTLauncherPersistenceMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DB1E37C13CA885B00A72466 /* TTLauncherPersistenceMode.h */; settings = {ATTRIBUTES = (Public, ); }; };
6DD20D35141D0C1B00916A4A /* TTTableSettingsItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DD20D34141D0C1B00916A4A /* TTTableSettingsItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
6DD20D37141D0C2800916A4A /* TTTableSettingsItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DD20D36141D0C2800916A4A /* TTTableSettingsItem.m */; };
6DD20D39141D0C3A00916A4A /* TTTableSettingsItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DD20D38141D0C3A00916A4A /* TTTableSettingsItemCell.m */; };
6DD20D3B141D0C4800916A4A /* TTTableSettingsItemCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DD20D3A141D0C4800916A4A /* TTTableSettingsItemCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
6E60820111B0C31400C93CD4 /* TTNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E6081FF11B0C31400C93CD4 /* TTNavigationController.m */; };
6E60820311B0C32600C93CD4 /* TTNavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E60820211B0C32600C93CD4 /* TTNavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; };
6E6454741184D2CD00F08CB1 /* Three20UI.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E6454731184D2CD00F08CB1 /* Three20UI.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -445,6 +449,10 @@
66F2E85D12D426DA006FB485 /* TTTableViewNetworkEnabledDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TTTableViewNetworkEnabledDelegate.h; path = Headers/TTTableViewNetworkEnabledDelegate.h; sourceTree = "<group>"; };
66F2E86312D426EF006FB485 /* TTTableViewNetworkEnabledDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TTTableViewNetworkEnabledDelegate.m; path = Sources/TTTableViewNetworkEnabledDelegate.m; sourceTree = "<group>"; };
6DB1E37C13CA885B00A72466 /* TTLauncherPersistenceMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TTLauncherPersistenceMode.h; path = Headers/TTLauncherPersistenceMode.h; sourceTree = "<group>"; };
6DD20D34141D0C1B00916A4A /* TTTableSettingsItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TTTableSettingsItem.h; path = Headers/TTTableSettingsItem.h; sourceTree = "<group>"; };
6DD20D36141D0C2800916A4A /* TTTableSettingsItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TTTableSettingsItem.m; path = Sources/TTTableSettingsItem.m; sourceTree = "<group>"; };
6DD20D38141D0C3A00916A4A /* TTTableSettingsItemCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TTTableSettingsItemCell.m; path = Sources/TTTableSettingsItemCell.m; sourceTree = "<group>"; };
6DD20D3A141D0C4800916A4A /* TTTableSettingsItemCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TTTableSettingsItemCell.h; path = Headers/TTTableSettingsItemCell.h; sourceTree = "<group>"; };
6E6081FF11B0C31400C93CD4 /* TTNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TTNavigationController.m; path = Sources/TTNavigationController.m; sourceTree = "<group>"; };
6E60820211B0C32600C93CD4 /* TTNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TTNavigationController.h; path = Headers/TTNavigationController.h; sourceTree = "<group>"; };
6E64543D1184BE1B00F08CB1 /* Project.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Project.xcconfig; path = Configurations/Project.xcconfig; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1412,6 +1420,8 @@
6E6458321184E06F00F08CB1 /* Table Items */ = {
isa = PBXGroup;
children = (
6DD20D34141D0C1B00916A4A /* TTTableSettingsItem.h */,
6DD20D36141D0C2800916A4A /* TTTableSettingsItem.m */,
6E6455061184D4C500F08CB1 /* TTTableActivityItem.h */,
6E6456361184D4DA00F08CB1 /* TTTableActivityItem.m */,
6E6455081184D4C500F08CB1 /* TTTableButton.h */,
Expand Down Expand Up @@ -1457,6 +1467,8 @@
6E6458361184E10200F08CB1 /* Table Cells */ = {
isa = PBXGroup;
children = (
6DD20D3A141D0C4800916A4A /* TTTableSettingsItemCell.h */,
6DD20D38141D0C3A00916A4A /* TTTableSettingsItemCell.m */,
6E6454FE1184D4C500F08CB1 /* TTStyledTextTableCell.h */,
6E64562F1184D4DA00F08CB1 /* TTStyledTextTableCell.m */,
6E6454FF1184D4C500F08CB1 /* TTStyledTextTableItemCell.h */,
Expand Down Expand Up @@ -1863,6 +1875,8 @@
66F2E85412D426A5006FB485 /* TTTableFooterInfiniteScrollView.h in Headers */,
66F2E85F12D426DA006FB485 /* TTTableViewNetworkEnabledDelegate.h in Headers */,
6DB1E37D13CA885B00A72466 /* TTLauncherPersistenceMode.h in Headers */,
6DD20D35141D0C1B00916A4A /* TTTableSettingsItem.h in Headers */,
6DD20D3B141D0C4800916A4A /* TTTableSettingsItemCell.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -2223,6 +2237,8 @@
666E18E912945430001C1D97 /* TTSplitViewController.m in Sources */,
66F2E85712D426AF006FB485 /* TTTableFooterInfiniteScrollView.m in Sources */,
66F2E86512D426EF006FB485 /* TTTableViewNetworkEnabledDelegate.m in Sources */,
6DD20D37141D0C2800916A4A /* TTTableSettingsItem.m in Sources */,
6DD20D39141D0C3A00916A4A /* TTTableSettingsItemCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 5cdf37e

Please sign in to comment.