2013-02-21 17:57:32 -08:00
|
|
|
//
|
|
|
|
// SmallInteractionCell.m
|
|
|
|
// NewsBlur
|
|
|
|
//
|
|
|
|
// Created by Samuel Clay on 2/21/13.
|
|
|
|
// Copyright (c) 2013 NewsBlur. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "SmallInteractionCell.h"
|
|
|
|
#import "UIImageView+AFNetworking.h"
|
|
|
|
#import <QuartzCore/QuartzCore.h>
|
|
|
|
|
|
|
|
@implementation SmallInteractionCell
|
|
|
|
|
|
|
|
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
|
|
|
|
|
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
|
|
interactionLabel = nil;
|
|
|
|
avatarView = nil;
|
2013-09-25 10:47:35 -07:00
|
|
|
self.separatorInset = UIEdgeInsetsMake(0, 52, 0, 0);
|
2016-11-27 16:30:57 -05:00
|
|
|
self.backgroundColor = UIColorFromRGB(0xffffff);
|
|
|
|
|
2013-02-21 17:57:32 -08:00
|
|
|
// create favicon and label in view
|
|
|
|
UIImageView *favicon = [[UIImageView alloc] initWithFrame:CGRectZero];
|
|
|
|
self.avatarView = favicon;
|
|
|
|
[self.contentView addSubview:favicon];
|
|
|
|
|
2013-06-19 18:55:23 -07:00
|
|
|
UILabel *interaction = [[UILabel alloc] initWithFrame:CGRectZero];
|
2015-12-07 16:09:49 -08:00
|
|
|
interaction.backgroundColor = UIColorFromRGB(NEWSBLUR_WHITE_COLOR);
|
2013-02-21 17:57:32 -08:00
|
|
|
self.interactionLabel = interaction;
|
|
|
|
[self.contentView addSubview:interaction];
|
|
|
|
|
|
|
|
topMargin = 10;
|
2013-09-11 17:05:47 -07:00
|
|
|
bottomMargin = 10;
|
2013-02-21 17:57:32 -08:00
|
|
|
leftMargin = 10;
|
|
|
|
rightMargin = 10;
|
|
|
|
avatarSize = 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)layoutSubviews {
|
|
|
|
[super layoutSubviews];
|
|
|
|
|
|
|
|
// determine outer bounds
|
2013-10-09 16:23:58 -07:00
|
|
|
[self.interactionLabel sizeToFit];
|
|
|
|
CGRect contentRect = self.frame;
|
|
|
|
CGRect labelFrame = self.interactionLabel.frame;
|
2013-02-21 17:57:32 -08:00
|
|
|
|
|
|
|
// position avatar to bounds
|
|
|
|
self.avatarView.frame = CGRectMake(leftMargin, topMargin, avatarSize, avatarSize);
|
|
|
|
|
|
|
|
// position label to bounds
|
2013-10-09 16:23:58 -07:00
|
|
|
labelFrame.origin.x = leftMargin*2 + avatarSize;
|
2014-12-16 14:24:55 -08:00
|
|
|
labelFrame.origin.y = 0;
|
2013-10-09 16:23:58 -07:00
|
|
|
labelFrame.size.width = contentRect.size.width - leftMargin - avatarSize - leftMargin - rightMargin - 20;
|
2014-12-16 14:24:55 -08:00
|
|
|
labelFrame.size.height = contentRect.size.height;
|
2013-10-09 16:23:58 -07:00
|
|
|
self.interactionLabel.frame = labelFrame;
|
|
|
|
|
2013-02-21 17:57:32 -08:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
self.interactionLabel.backgroundColor = UIColorFromRGB(0xd7dadf);
|
|
|
|
} else {
|
|
|
|
self.interactionLabel.backgroundColor = UIColorFromRGB(0xf6f6f6);
|
|
|
|
}
|
|
|
|
self.interactionLabel.backgroundColor = [UIColor clearColor];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|