summaryrefslogtreecommitdiff
path: root/Juick/MessageCell.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/MessageCell.m')
-rw-r--r--Juick/MessageCell.m38
1 files changed, 36 insertions, 2 deletions
diff --git a/Juick/MessageCell.m b/Juick/MessageCell.m
index cf2e134..ad3a849 100644
--- a/Juick/MessageCell.m
+++ b/Juick/MessageCell.m
@@ -22,6 +22,8 @@
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
+ [self setBackgroundColor:[UIColor whiteColor]];
+
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.avatar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
[self.avatar setBackgroundColor:[UIColor clearColor]];
@@ -31,7 +33,7 @@
[self.titleLabel setLineBreakMode:NSLineBreakByTruncatingTail];
[self.titleLabel setNumberOfLines:1];
[self.titleLabel setTextAlignment:NSTextAlignmentLeft];
- [self.titleLabel setTextColor:[UIColor blackColor]];
+ [self.titleLabel setTextColor:[ColorsAndButtons linkColor]];
[self.titleLabel setBackgroundColor:[UIColor clearColor]];
self.timestampLabel = [[UILabel alloc] initWithFrame:CGRectZero];
@@ -61,11 +63,15 @@
[self.summaryLabel setTextAlignment:NSTextAlignmentLeft];
[self.summaryLabel setTextColor:[UIColor grayColor]];
[self.summaryLabel setBackgroundColor:[UIColor clearColor]];
+ self.attach = [[UIImageView alloc] initWithFrame:CGRectZero];
+ [self.attach setBackgroundColor:[UIColor clearColor]];
+ self.attach.contentMode = UIViewContentModeScaleAspectFit;
[self.contentView addSubview:self.avatar];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.timestampLabel];
[self.contentView addSubview:self.bodyLabel];
+ [self.contentView addSubview:self.attach];
[self.contentView addSubview:self.summaryLabel];
[self updateFonts];
@@ -110,14 +116,20 @@
make.leading.equalTo(self.contentView.leading).with.offset(padding.left);
make.top.equalTo(self.timestampLabel.bottom).with.offset(padding.top);
make.trailing.equalTo(self.contentView.trailing).with.offset(-padding.right);
+ make.bottom.equalTo(self.attach.top).with.offset(-padding.bottom);
+ }];
+
+ [self.attach makeConstraints:^(MASConstraintMaker *make) {
+ make.leading.equalTo(self.contentView.leading).with.offset(padding.left);
make.bottom.equalTo(self.summaryLabel.top).with.offset(-padding.bottom);
+ make.trailing.equalTo(self.contentView.trailing).with.offset(-padding.right);
+ make.top.equalTo(self.bodyLabel.bottom).with.offset(padding.top);
}];
[self.summaryLabel makeConstraints:^(MASConstraintMaker *make) {
make.leading.equalTo(self.contentView.leading).with.offset(padding.left);
make.bottom.equalTo(self.contentView.bottom).with.offset(-padding.bottom);
make.trailing.equalTo(self.contentView.trailing).with.offset(-padding.right);
-
}];
@@ -136,6 +148,28 @@
}
}
+- (void) bind:(Message *)msg {
+ [self.avatar setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://i.juick.com/as/%@.png", msg.userID]]];
+
+ self.titleLabel.text = msg.user;
+ self.timestampLabel.text = msg.timestamp;
+ if (msg.repliesCount > 0) {
+ self.summaryLabel.text = [NSString stringWithFormat:@"%@ replies by %@", msg.repliesCount, msg.repliesBy];
+ } else {
+ self.summaryLabel.text = nil;
+ }
+ self.bodyLabel.text = [msg.text stringByDecodingHTMLEntities];
+ if ([msg.tags count] > 0) {
+ self.bodyLabel.text = [[NSString alloc] initWithFormat:@"%@\n%@", [msg.tags componentsJoinedByString:@", "],
+ [msg.text stringByDecodingHTMLEntities]];
+ }
+ if ([msg.attach length] > 0) {
+ [self.attach setImageWithURL:[NSURL URLWithString:msg.attach]];
+ } else {
+ self.attach.image = nil;
+ }
+}
+
- (void) attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url {
[[UIApplication sharedApplication] openURL:url];
}