2012-07-21 18:25:56 -07:00
|
|
|
//
|
|
|
|
// SmallActivityCell.m
|
|
|
|
// NewsBlur
|
|
|
|
//
|
|
|
|
// Created by Roy Yang on 7/21/12.
|
|
|
|
// Copyright (c) 2012 NewsBlur. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "SmallActivityCell.h"
|
2012-07-22 14:23:50 -07:00
|
|
|
#import "UIImageView+AFNetworking.h"
|
|
|
|
#import <QuartzCore/QuartzCore.h>
|
|
|
|
|
2012-07-21 18:25:56 -07:00
|
|
|
@implementation SmallActivityCell
|
|
|
|
|
2012-07-28 23:43:50 -07:00
|
|
|
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
|
|
|
|
|
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
|
|
activityLabel = nil;
|
|
|
|
faviconView = nil;
|
2013-09-25 10:47:35 -07:00
|
|
|
self.separatorInset = UIEdgeInsetsMake(0, 52, 0, 0);
|
2012-07-28 23:43:50 -07:00
|
|
|
|
|
|
|
// create favicon and label in view
|
|
|
|
UIImageView *favicon = [[UIImageView alloc] initWithFrame:CGRectZero];
|
|
|
|
self.faviconView = favicon;
|
|
|
|
[self.contentView addSubview:favicon];
|
|
|
|
|
2013-06-19 18:55:23 -07:00
|
|
|
UILabel *activity = [[UILabel alloc] initWithFrame:CGRectZero];
|
2012-07-28 23:43:50 -07:00
|
|
|
activity.backgroundColor = [UIColor whiteColor];
|
|
|
|
self.activityLabel = activity;
|
|
|
|
[self.contentView addSubview:activity];
|
|
|
|
|
|
|
|
topMargin = 10;
|
|
|
|
bottomMargin = 10;
|
|
|
|
leftMargin = 10;
|
|
|
|
rightMargin = 10;
|
|
|
|
avatarSize = 32;
|
2012-07-21 18:25:56 -07:00
|
|
|
}
|
2012-07-28 23:43:50 -07:00
|
|
|
|
2012-07-21 18:25:56 -07:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)layoutSubviews {
|
|
|
|
[super layoutSubviews];
|
|
|
|
|
|
|
|
// determine outer bounds
|
2013-10-09 16:23:58 -07:00
|
|
|
[self.activityLabel sizeToFit];
|
|
|
|
CGRect contentRect = self.frame;
|
|
|
|
CGRect labelFrame = self.activityLabel.frame;
|
2012-07-21 18:25:56 -07:00
|
|
|
|
|
|
|
// position avatar to bounds
|
|
|
|
self.faviconView.frame = CGRectMake(leftMargin, topMargin, avatarSize, avatarSize);
|
|
|
|
|
|
|
|
// position label to bounds
|
2013-10-09 16:23:58 -07:00
|
|
|
labelFrame.origin.x = leftMargin*2 + avatarSize;
|
|
|
|
labelFrame.origin.y = topMargin - 1;
|
|
|
|
labelFrame.size.width = contentRect.size.width - leftMargin - avatarSize - leftMargin - rightMargin - 20;
|
|
|
|
labelFrame.size.height = contentRect.size.height - topMargin - bottomMargin;
|
|
|
|
self.activityLabel.frame = labelFrame;
|
|
|
|
|
2012-07-22 14:23:50 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
self.activityLabel.backgroundColor = UIColorFromRGB(0xd7dadf);
|
|
|
|
} else {
|
|
|
|
self.activityLabel.backgroundColor = UIColorFromRGB(0xf6f6f6);
|
|
|
|
}
|
|
|
|
self.activityLabel.backgroundColor = [UIColor clearColor];
|
|
|
|
}
|
|
|
|
|
2012-07-21 18:25:56 -07:00
|
|
|
@end
|