-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMEIncomingMessageCollectionViewCell.m
More file actions
executable file
·46 lines (35 loc) · 2.05 KB
/
Copy pathMEIncomingMessageCollectionViewCell.m
File metadata and controls
executable file
·46 lines (35 loc) · 2.05 KB
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
37
38
39
40
41
42
43
44
45
46
//
// MEIncomingMessageCollectionViewCell.m
// Atlas Messenger
//
// Created by steve on 3/7/16.
// Copyright © 2016 Layer, Inc. All rights reserved.
//
#import "MEIncomingMessageCollectionViewCell.h"
#import "METextInputView.h"
@implementation MEIncomingMessageCollectionViewCell
- (void)presentMessage:(LYRMessage *)message {
self.bubbleView.backgroundColor = [[ATLIncomingMessageCollectionViewCell appearance] bubbleViewColor];
LYRMessagePart *part = message.parts[0];
if ([part.MIMEType isEqualToString:@"text/plain"]) {
NSString * messageString = [[NSString alloc] initWithData:part.data encoding:NSUTF8StringEncoding];
NSString * messageHTML = [METextInputView convertSubstituedToHTML:messageString];
UIColor * messageTextColor = [[ATLIncomingMessageCollectionViewCell appearance] messageTextColor];
NSString * fontSize = [NSString stringWithFormat:@"font-size:%ipx;", 16];
NSString * fontColor = [NSString stringWithFormat:@"color:%@;", [self hexStringFromColor:messageTextColor]];
messageHTML = [messageHTML stringByReplacingOccurrencesOfString:@"font-size:16px;" withString:fontSize];
messageHTML = [messageHTML stringByReplacingOccurrencesOfString:@"color:#000000;" withString:fontColor];
[self setHTMLString:messageHTML];
messageString = nil;
}
}
-(void)layoutSubviews {
[super layoutSubviews];
self.avatarImageView.frame = CGRectMake(ATLMessageBubbleLabelHorizontalPadding, ATLMessageBubbleLabelVerticalPadding, 27, 27);
if (!self.superview) { return; }
if (self.shouldDisplayAvatar == NO) { self.avatarImageView.frame = CGRectZero; }
CGFloat leadIn = ATLMessageCellHorizontalMargin+self.avatarImageView.frame.size.width;
self.bubbleView.frame = CGRectMake(leadIn, 0, self.bubbleView.frame.size.width, self.bubbleView.frame.size.height);
self.messageView.frame = CGRectMake(leadIn+ATLMessageBubbleLabelHorizontalPadding, ATLMessageBubbleLabelVerticalPadding, self.messageView.frame.size.width, self.messageView.frame.size.height);
}
@end