diff options
author | Vitaly Takmazov | 2017-10-15 23:47:11 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-10-15 23:47:11 +0300 |
commit | 8ae952ec8df2a713afeaef5960a88888e050c6fc (patch) | |
tree | b7b09deed573336e5d274eed790c30ba57e4a910 /Juick/Views | |
parent | 6499148cb3f62e20534b62c181125ebeacfa3438 (diff) |
WIP
Diffstat (limited to 'Juick/Views')
-rw-r--r-- | Juick/Views/MessageCell.h | 5 | ||||
-rw-r--r-- | Juick/Views/MessageCell.m | 26 |
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 |