Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. // MEIncomingMessageCollectionViewCell.m
  2.  
  3. #import "MEIncomingMessageCollectionViewCell.h"
  4. #import "METextInputView.h"
  5.  
  6. #import "UIFont+Fonts.h"
  7.  
  8. @implementation MEIncomingMessageCollectionViewCell
  9.  
  10. + (NSString *)reuseIdentifier {
  11. return NSStringFromClass([self class]);
  12. }
  13.  
  14. - (void)presentMessage:(LYRMessage *)message {
  15. self.bubbleView.backgroundColor = [[ATLIncomingMessageCollectionViewCell appearance] bubbleViewColor];
  16. LYRMessagePart *part = message.parts[0];
  17.  
  18. if ([part.MIMEType isEqualToString:ATLMIMETypeTextPlain]) {
  19. NSString *messageString = [[NSString alloc] initWithData:part.data encoding:NSUTF8StringEncoding];
  20. UIColor *messageTextColor = [[ATLIncomingMessageCollectionViewCell appearance] messageTextColor];
  21. #warning use Gotham-Book 14 once ME-SDK can access the custom font
  22. NSString *messageHTML = [METextInputView convertSubstituedToHTML:messageString withFont:[UIFont fontWithName:@"Helvetica" size:14] textColor:messageTextColor];
  23. [self setHTMLString:messageHTML];
  24. messageString = nil;
  25. }
  26. }
  27.  
  28. - (void)layoutSubviews {
  29. [super layoutSubviews];
  30.  
  31. CGFloat avatarImageViewDiameter = [[ATLAvatarImageView appearance] avatarImageViewDiameter];
  32. self.avatarImageView.frame = CGRectMake(ATLMessageBubbleLabelHorizontalPadding, ATLMessageBubbleLabelVerticalPadding, avatarImageViewDiameter, avatarImageViewDiameter);
  33.  
  34. if (!self.superview) {
  35. return;
  36. }
  37.  
  38. if (self.shouldDisplayAvatar == NO) { self.avatarImageView.frame = CGRectZero; }
  39.  
  40. CGFloat leadIn = ATLMessageCellHorizontalMargin + self.avatarImageView.frame.size.width;
  41.  
  42. self.bubbleView.frame = CGRectMake(leadIn, 0, self.bubbleView.frame.size.width, self.bubbleView.frame.size.height);
  43. self.messageView.frame = CGRectMake(leadIn + ATLMessageBubbleLabelHorizontalPadding, ATLMessageBubbleLabelVerticalPadding, self.messageView.frame.size.width, self.messageView.frame.size.height);
  44. }
  45.  
  46. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement