summaryrefslogtreecommitdiff
path: root/Juick/Views
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Views')
-rw-r--r--Juick/Views/MessageCell.h5
-rw-r--r--Juick/Views/MessageCell.m26
2 files changed, 23 insertions, 8 deletions
diff --git a/Juick/Views/MessageCell.h b/Juick/Views/MessageCell.h
index 124ed83..92345d6 100644
--- a/Juick/Views/MessageCell.h
+++ b/Juick/Views/MessageCell.h
@@ -13,13 +13,14 @@
@interface MessageCell : UITableViewCell<TTTAttributedLabelDelegate>
@property (weak, nonatomic) IBOutlet UIImageView *avatar;
-@property (weak, nonatomic) IBOutlet UILabel *timestamp;
@property (weak, nonatomic) IBOutlet UILabel *title;
+@property (weak, nonatomic) IBOutlet UILabel *timestamp;
@property (weak, nonatomic) IBOutlet TagListView *tags;
@property (weak, nonatomic) IBOutlet TTTAttributedLabel *text;
@property (weak, nonatomic) IBOutlet UIImageView *attach;
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *attachmentHeight;
@property (weak, nonatomic) IBOutlet UILabel *summary;
-@property (strong, nonatomic) Message * message;
+- (void) configureWithMessage:(Message *)msg;
@end
diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m
index cc35446..1cfe304 100644
--- a/Juick/Views/MessageCell.m
+++ b/Juick/Views/MessageCell.m
@@ -6,11 +6,14 @@
// Copyright © 2016 com.juick. All rights reserved.
//
+
#import "MessageCell.h"
-@import YYWebImage;
+#import "ColorScheme.h"
+#import "UIImage+Utils.h"
+
@import DateTools;
@import MWFeedParser;
-#import "ColorScheme.h"
+@import YYWebImage;
@implementation MessageCell
@@ -20,11 +23,22 @@
self.text.delegate = self;
self.text.linkAttributes = @{ (id)kCTForegroundColorAttributeName: [ColorScheme linkColor],
(id)kCTUnderlineStyleAttributeName : [NSNumber numberWithInt:NSUnderlineStyleSingle] };
+ self.title.textColor = [ColorScheme linkColor];
+ self.timestamp.textColor = [UIColor grayColor];
+ self.summary.textColor = [UIColor grayColor];
+ self.tags.textFont = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
}
-- (void) setMessage:(Message *)msg {
- _message = msg;
- self.avatar.yy_imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://i.juick.com/a/%d.png", [msg.user.uid intValue]]];
+- (void) configureWithMessage:(Message *)msg {
+ [self.avatar setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://i.juick.com/a/%d.png", [msg.user.uid intValue]]]];
+ if ([msg.attach length] > 0) {
+ CGFloat imageHeight = [msg.attachment.small.height floatValue] / [[UIScreen mainScreen] scale];
+ self.attachmentHeight.constant = imageHeight;
+ [self.attach yy_setImageWithURL:[NSURL URLWithString:msg.attach] options:YYWebImageOptionProgressiveBlur|YYWebImageOptionSetImageWithFadeAnimation];
+ } else {
+ self.attachmentHeight.constant = 0;
+ self.attach.image = nil;
+ }
self.title.text = msg.user.uname;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
@@ -51,7 +65,7 @@
}
-(void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url {
- [[UIApplication sharedApplication] openURL:url];
+ [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
}
@end