summaryrefslogtreecommitdiff
path: root/Juick/Views/ConversationCell.m
blob: 4a0be13299b15710b91ca19dd12c9e868ce5392f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
//  ConversationCell.m
//  Juick
//
//  Created by Vitaly Takmazov on 04/03/2018.
//  Copyright © 2018 com.juick. All rights reserved.
//

#import "ConversationCell.h"
#import "ColorScheme.h"

@implementation ConversationCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void) configureWithChat:(Chat *)chat {
    self.chatName.textColor = [ColorScheme linkColor];
    self.chatName.text = chat.uname;
    self.lastMessage.text = chat.lastMessageText;
    self.unreadMarker.hidden = chat.unreadCount > 0;
    __weak UIImageView *weakAvatar = self.avatar;
    [self.avatar setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:chat.avatar]] placeholderImage:nil success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
        [UIView transitionWithView:weakAvatar
                          duration:0.3
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        animations:^{
                            weakAvatar.image = image;
                        }
                        completion:nil];
    } failure:nil];
}

@end