Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

167 lines (120 sloc) 5.679 kb
//
// 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/TTTableMoreButtonCell.h"
// UI
#import "Three20UI/TTTableMoreButton.h"
#import "Three20UI/UIViewAdditions.h"
// UICommon
#import "Three20UICommon/TTGlobalUICommon.h"
// Style
#import "Three20Style/TTGlobalStyle.h"
#import "Three20Style/TTDefaultStyleSheet.h"
// Core
#import "Three20Core/TTCorePreprocessorMacros.h"
static const CGFloat kMoreButtonMargin = 40.0f;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
@implementation TTTableMoreButtonCell
@synthesize animating = _animating;
///////////////////////////////////////////////////////////////////////////////////////////////////
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)identifier {
self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
if (self) {
self.textLabel.font = TTSTYLEVAR(tableSmallFont);
self.textLabel.backgroundColor = TTSTYLEVAR(backgroundTextColor);
}
return self;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)dealloc {
TT_RELEASE_SAFELY(_activityIndicatorView);
[super dealloc];
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark TTTableViewCell class public
///////////////////////////////////////////////////////////////////////////////////////////////////
+ (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(id)object {
CGFloat height = [super tableView:tableView rowHeightForObject:object];
CGFloat minHeight = TT_ROW_HEIGHT * 1.5;
if (height < minHeight) {
return minHeight;
} else {
return height;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark UIView
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)layoutSubviews {
[super layoutSubviews];
_activityIndicatorView.left = kMoreButtonMargin - (_activityIndicatorView.width
+ kTableCellSmallMargin);
_activityIndicatorView.top = floor(self.contentView.height/2 - _activityIndicatorView.height/2);
self.textLabel.frame = CGRectMake(kMoreButtonMargin, self.textLabel.top,
self.contentView.width - (kMoreButtonMargin
+ kTableCellSmallMargin),
self.textLabel.height);
self.detailTextLabel.frame = CGRectMake(kMoreButtonMargin, self.detailTextLabel.top,
self.contentView.width - (kMoreButtonMargin
+ kTableCellSmallMargin),
self.detailTextLabel.height);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark TTTableViewCell
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)setObject:(id)object {
if (_item != object) {
[super setObject:object];
TTTableMoreButton* item = object;
self.animating = item.isLoading;
self.textLabel.textColor = TTSTYLEVAR(moreLinkTextColor);
self.selectionStyle = TTSTYLEVAR(tableSelectionStyle);
self.accessoryType = UITableViewCellAccessoryNone;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark Public
///////////////////////////////////////////////////////////////////////////////////////////////////
- (UIActivityIndicatorView*)activityIndicatorView {
if (!_activityIndicatorView) {
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:
UIActivityIndicatorViewStyleGray];
[self.contentView addSubview:_activityIndicatorView];
}
return _activityIndicatorView;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)setAnimating:(BOOL)animating {
if (_animating != animating) {
_animating = animating;
if (_animating) {
[self.activityIndicatorView startAnimating];
} else {
[_activityIndicatorView stopAnimating];
}
[self setNeedsLayout];
}
}
@end
Jump to Line
Something went wrong with that request. Please try again.