summaryrefslogtreecommitdiff
path: root/Juick/Views/MessageCell.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Views/MessageCell.m')
-rw-r--r--Juick/Views/MessageCell.m15
1 files changed, 12 insertions, 3 deletions
diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m
index ceb2ac5..9b1b593 100644
--- a/Juick/Views/MessageCell.m
+++ b/Juick/Views/MessageCell.m
@@ -16,6 +16,7 @@
@property(nonatomic, readonly) UIFont *boldFont;
@property(nonatomic, readonly) UIFont *italicFont;
- (void) updateAvatarWithUrl:(NSString *)avatarUrl;
+@property(nonatomic, strong) NSString *attachment;
@end
@implementation MessageCell
@@ -72,14 +73,15 @@ const NSString *unreadMarker = @"●";
}];
}
if ([msg.attach length] > 0) {
- CGFloat imageHeight = [msg.attachment.small.height floatValue] / [[UIScreen mainScreen] scale];
- CGFloat imageWidth = [msg.attachment.small.width floatValue] / [[UIScreen mainScreen] scale];
+ self.attachment = msg.attachment.url;
+ CGFloat imageHeight = [msg.attachment.medium.height floatValue] / [[UIScreen mainScreen] scale];
+ CGFloat imageWidth = [msg.attachment.medium.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;
- [[AppDelegate shared].api fetchImageWithURL:[NSURL URLWithString:msg.attachment.small.url] callback:^(NSData *data) {
+ [[AppDelegate shared].api fetchImageWithURL:[NSURL URLWithString:msg.attachment.medium.url] callback:^(NSData *data) {
[UIView transitionWithView:weakAttach
duration:0.3
options:UIViewAnimationOptionTransitionCrossDissolve
@@ -88,6 +90,10 @@ const NSString *unreadMarker = @"●";
}
completion:nil];
}];
+ UITapGestureRecognizer *attachmentTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(linkClicked:)];
+ [attachmentTapGestureRecognizer setEnabled:YES];
+ [self.attach addGestureRecognizer:attachmentTapGestureRecognizer];
+ [self.attach setUserInteractionEnabled:YES];
} else {
self.attachmentHeight.constant = 0;
self.attach.image = nil;
@@ -174,5 +180,8 @@ const NSString *unreadMarker = @"●";
-(void) avatarClicked:(UIGestureRecognizer *)gestureRecognizer {
[self.delegate avatarClicked:self.title.text];
}
+-(void) linkClicked:(UIGestureRecognizer *)gestureRecognizer {
+ [self.delegate linkClicked:self.attachment];
+}
@end