From 68befabf1b72dc03acdacc4e443b00f80495b7fe Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 1 Oct 2019 23:05:16 +0300 Subject: MessageCell styling --- Juick/Views/MessageCell.h | 1 + Juick/Views/MessageCell.m | 12 +++++++++--- Juick/Views/MessageCell.xib | 27 +++++++++++++-------------- 3 files changed, 23 insertions(+), 17 deletions(-) (limited to 'Juick/Views') diff --git a/Juick/Views/MessageCell.h b/Juick/Views/MessageCell.h index 7648c52..684a620 100644 --- a/Juick/Views/MessageCell.h +++ b/Juick/Views/MessageCell.h @@ -21,6 +21,7 @@ @property (weak, nonatomic) IBOutlet UITextView *text; @property (weak, nonatomic) IBOutlet UIImageView *attach; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *attachmentHeight; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *attachmentWidth; @property (weak, nonatomic) IBOutlet UILabel *summary; @property (nonatomic, strong) id delegate; diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m index 551a54d..4d53273 100644 --- a/Juick/Views/MessageCell.m +++ b/Juick/Views/MessageCell.m @@ -57,11 +57,14 @@ completion:nil]; }]; if ([msg.attach length] > 0) { - self.attach.image = [UIImage placeholderImageWithColor:[UIColor colorNamed:@"Muted"] size:CGSizeMake([msg.attachment.medium.width floatValue], [msg.attachment.medium.height floatValue])]; - CGFloat imageHeight = [msg.attachment.medium.height floatValue] / [[UIScreen mainScreen] scale]; + CGFloat imageHeight = [msg.attachment.small.height floatValue] / [[UIScreen mainScreen] scale]; + CGFloat imageWidth = [msg.attachment.small.width floatValue] / [[UIScreen mainScreen] scale]; + self.attach.image = [UIImage placeholderImageWithColor:[UIColor colorNamed:@"Muted"] size:CGSizeMake(imageWidth, imageHeight)]; + self.attachmentHeight.constant = imageHeight; + self.attachmentWidth.constant = imageWidth; __weak UIImageView *weakAttach = self.attach; - [[APIClient sharedClient] fetchImageWithURL:[NSURL URLWithString:msg.attachment.medium.url] callback:^(NSData *data) { + [[APIClient sharedClient] fetchImageWithURL:[NSURL URLWithString:msg.attachment.small.url] callback:^(NSData *data) { [UIView transitionWithView:weakAttach duration:0.3 options:UIViewAnimationOptionTransitionCrossDissolve @@ -89,6 +92,7 @@ } self.text.attributedText = nil; if (msg.text) { + [self.text setHidden:NO]; NSMutableAttributedString *txt = [[NSMutableAttributedString alloc] initWithString:msg.text attributes:@{NSFontAttributeName:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]}]; @@ -133,6 +137,8 @@ } [txt endEditing]; self.text.attributedText = txt; + } else { + [self.text setHidden:YES]; } } diff --git a/Juick/Views/MessageCell.xib b/Juick/Views/MessageCell.xib index f4ae806..5b5ebd3 100644 --- a/Juick/Views/MessageCell.xib +++ b/Juick/Views/MessageCell.xib @@ -1,29 +1,27 @@ - - - - + + - + - + - + - + - + @@ -33,7 +31,7 @@ - + - + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. - + - +