JXAVCallCell.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // JXAVCallCell.m
  3. // shiku_im
  4. //
  5. // Created by p on 2017/8/7.
  6. // Copyright © 2017年 Reese. All rights reserved.
  7. //
  8. #import "JXAVCallCell.h"
  9. @interface JXAVCallCell ()
  10. @property (nonatomic, strong) UILabel *avLabel;
  11. @property (nonatomic, strong) UIImageView *avImageView;
  12. @end
  13. @implementation JXAVCallCell
  14. -(void)creatUI{
  15. _avLabel = [[UILabel alloc] init];
  16. _avLabel.textColor = [UIColor blackColor];
  17. _avLabel.font = [UIFont systemFontOfSize:g_constant.chatFont];
  18. [self.bubbleBg addSubview:_avLabel];
  19. _avImageView = [[UIImageView alloc] init];
  20. [self.bubbleBg addSubview:_avImageView];
  21. }
  22. -(void)setCellData{
  23. [super setCellData];
  24. _avLabel.text = self.msg.content;
  25. int type = 0;
  26. switch ([self.msg.type intValue]) {
  27. case kWCMessageTypeAudioChatCancel:
  28. case kWCMessageTypeAudioChatEnd:
  29. case kWCMessageTypeAudioMeetingInvite:
  30. type = 1;
  31. break;
  32. case kWCMessageTypeVideoMeetingInvite:
  33. case kWCMessageTypeVideoChatCancel:
  34. case kWCMessageTypeVideoChatEnd:
  35. type = 2;
  36. break;
  37. case kWCMessageTypeAVBusy:{
  38. if ([self.msg.objectId isEqualToString:@"1"]) {
  39. type = 2;
  40. }else {
  41. type = 1;
  42. }
  43. }
  44. break;
  45. default:
  46. break;
  47. }
  48. if (type == 1) {
  49. _avImageView.image = [UIImage imageNamed:@"end_of_voice_call_icon"];
  50. }else {
  51. _avImageView.image = [UIImage imageNamed:@"video_call_closed_icon"];
  52. }
  53. [self creatBubbleBg];
  54. }
  55. -(void)creatBubbleBg{
  56. CGSize textSize = [self.msg.content boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:_avLabel.font} context:nil].size;
  57. int n = textSize.width;
  58. if(self.msg.isMySend){
  59. self.bubbleBg.frame=CGRectMake(CGRectGetMinX(self.headImage.frame)-INSETS*2-n - 30-CHAT_WIDTH_ICON, INSETS, n+INSETS*2 + 30, textSize.height+INSETS*2);
  60. [_avLabel setFrame:CGRectMake(INSETS*0.4 + 3, INSETS, n + 5, textSize.height)];
  61. [_avImageView setFrame:CGRectMake(CGRectGetMaxX(_avLabel.frame) + 3, (self.bubbleBg.frame.size.height - 21) / 2, 21, 21)];
  62. }else
  63. {
  64. self.bubbleBg.frame=CGRectMake(CGRectGetMaxX(self.headImage.frame) + CHAT_WIDTH_ICON, INSETS2(self.msg.isGroup), n+INSETS*2 + 25, textSize.height+INSETS*2);
  65. [_avImageView setFrame:CGRectMake(INSETS + 3, (self.bubbleBg.frame.size.height - 21) / 2, 21, 21)];
  66. [_avLabel setFrame:CGRectMake(CGRectGetMaxX(_avImageView.frame) + 5, INSETS, n + 5, textSize.height)];
  67. }
  68. if (self.msg.isShowTime) {
  69. CGRect frame = self.bubbleBg.frame;
  70. frame.origin.y = self.bubbleBg.frame.origin.y + 40;
  71. self.bubbleBg.frame = frame;
  72. }
  73. }
  74. + (float)getChatCellHeight:(JXMessageObject *)msg {
  75. if ([msg.chatMsgHeight floatValue] > 1) {
  76. return [msg.chatMsgHeight floatValue];
  77. }
  78. float n;
  79. if (msg.isShowTime) {
  80. n = 95;
  81. }else {
  82. n = 55;
  83. }
  84. msg.chatMsgHeight = [NSString stringWithFormat:@"%f",n];
  85. if (!msg.isNotUpdateHeight) {
  86. [msg updateChatMsgHeight];
  87. }
  88. return n;
  89. }
  90. -(void)didTouch:(UIButton*)button{
  91. [g_notify postNotificationName:kCellSystemAVCallNotifaction object:self.msg];
  92. }
  93. @end