From 8ae952ec8df2a713afeaef5960a88888e050c6fc Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 15 Oct 2017 23:47:11 +0300 Subject: WIP --- Juick/Views/MessageCell.m | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'Juick/Views/MessageCell.m') 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 -- cgit v1.2.3