YOUPAILCCallContentView.m 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // YOUPAILCCallContentView.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/11/27.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCCallContentView.h"
  9. #import "YOUPAILCCallAttachment.h"
  10. @interface YOUPAILCCallContentView()
  11. @property(nonatomic,strong)UIImageView* backView;
  12. @property(nonatomic,strong)UILabel* topTitle;
  13. @property(nonatomic,strong)UIImageView* iconImgView;
  14. @property(nonatomic,strong)UILabel* contentLabel;
  15. @end
  16. @implementation YOUPAILCCallContentView
  17. - (instancetype)initSessionMessageContentView{
  18. self = [super initSessionMessageContentView];
  19. if (self) {
  20. // self.opaque = YES;
  21. UIImageView* testView = [[UIImageView alloc] initWithFrame:CGRectZero];
  22. testView.backgroundColor= [UIColor clearColor];
  23. testView.contentMode = UIViewContentModeScaleAspectFill;
  24. testView.userInteractionEnabled = YES;
  25. UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapHandel:)];
  26. [testView addGestureRecognizer:tap];
  27. self.backView = testView;
  28. [self addSubview:testView];
  29. }
  30. return self;
  31. }
  32. - (void)refresh:(NIMMessageModel *)data{
  33. [super refresh:data];
  34. NIMCustomObject *customObject = (NIMCustomObject*)data.message.messageObject;
  35. id attachment = customObject.attachment;
  36. if ([attachment isKindOfClass:[YOUPAILCCallAttachment class]]) {
  37. for (UIView* subview in self.backView.subviews) {
  38. [subview removeFromSuperview];
  39. }
  40. YOUPAILCCallAttachment* attachment = (YOUPAILCCallAttachment*)customObject.attachment;
  41. NSString* txtStr = @"";
  42. if (attachment.status==3) {
  43. txtStr = @"超时未接听";
  44. }else if (attachment.status==4){
  45. txtStr = [NSString stringWithFormat:@"通话时长:%@",[ZCUtils getMinTimeStrFromSS:attachment.call_time]];
  46. }
  47. // NSLog(@"代表是自己发的%@-----%@", [LCSaveModel getUserModel].userinfo.user_id , attachment.from_uid);
  48. if ([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id integerValue] == attachment.from_uid) {//代表是自己发的
  49. // NSLog(@"代表是自己发的%@-----%@", [LCSaveModel getUserModel].userinfo.user_id , attachment.from_uid);
  50. if (attachment.status==1) {
  51. txtStr = @"已取消";
  52. }else if (attachment.status==2){
  53. txtStr = @"对方已拒绝";
  54. }
  55. }else{
  56. if (attachment.status==1) {
  57. txtStr = @"对方已取消";
  58. }else if (attachment.status==2){
  59. txtStr = @"已拒绝";
  60. }
  61. }
  62. UIImageView* imgV = [[UIImageView alloc]initWithFrame:CGRectMake(8, 2, 24, 16)];
  63. imgV.contentMode = UIViewContentModeScaleAspectFill;
  64. imgV.image = [UIImage imageNamed:@"vqu_images_IM_call_video"];
  65. [self.backView addSubview:imgV];
  66. UILabel* nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(40, 0, 0, 20)];
  67. nameLabel.textColor = data.shouldShowLeft ? LZ273145Color : [UIColor whiteColor];
  68. nameLabel.textAlignment = NSTextAlignmentLeft;
  69. nameLabel.font = LCFont(14);
  70. nameLabel.text = txtStr;
  71. CGFloat nameWidth =[txtStr widthWithFont:LCFont(14) constrainedToHeight:20];
  72. nameLabel.frame = CGRectMake(40,0,nameWidth+2, 20);
  73. [self.backView addSubview:nameLabel];
  74. if (data.message.isOutgoingMsg) {//是自己往外发的
  75. nameLabel.frame = CGRectMake(10, 0, nameWidth+2, 20);
  76. imgV.frame = CGRectMake(nameWidth+20, 2, 24, 16);
  77. // nameLabel.textColor = [UIColor whiteColor];
  78. imgV.image = [UIImage imageNamed:@"vqu_images_IM_call_video_right"];
  79. }else{
  80. imgV.image = [UIImage imageNamed:@"vqu_images_IM_call_video_left"];
  81. }
  82. if (data.message.isOutgoingMsg) {//代表是自己发的
  83. // NSLog(@"代表是自己发的%@-----%@", [LCSaveModel getUserModel].userinfo.user_id , attachment.from_uid);
  84. if (attachment.status==1) {
  85. txtStr = @"已取消";
  86. imgV.image = [UIImage imageNamed:@"vqu_images_vqu_images_IM_call_video_NO_right"];
  87. }else if (attachment.status==2){
  88. txtStr = @"对方已拒绝";
  89. if (data.message.isOutgoingMsg) {//是自己往外发的
  90. nameLabel.frame = CGRectMake(10, 0, nameWidth+2, 20);
  91. imgV.frame = CGRectMake(nameWidth+20, 2, 21, 21);
  92. nameLabel.textColor = [UIColor whiteColor];
  93. imgV.image = [UIImage imageNamed:@"vqu_images_vqu_images_IM_call_video_NO_right"];
  94. }else{
  95. }
  96. }
  97. }else{
  98. if (attachment.status==1) {
  99. txtStr = @"对方已取消";
  100. imgV.image = [UIImage imageNamed:@"vqu_images_vqu_images_IM_call_video_NO_left"];
  101. }else if (attachment.status==2){
  102. txtStr = @"已拒绝";
  103. if (data.message.isOutgoingMsg) {//是自己往外发的
  104. nameLabel.frame = CGRectMake(10, 0, nameWidth+2, 20);
  105. imgV.frame = CGRectMake(nameWidth+20, 2, 21, 21);
  106. nameLabel.textColor = [UIColor whiteColor];
  107. imgV.image = [UIImage imageNamed:@"vqu_images_vqu_images_IM_call_video_NO_left"];
  108. }else{
  109. }
  110. }
  111. }
  112. }
  113. }
  114. - (void)tapHandel:(UITapGestureRecognizer*)tap{
  115. if (tap.state == UIGestureRecognizerStateEnded) {
  116. NIMKitEvent *event = [[NIMKitEvent alloc] init];
  117. event.eventName = NIMKitEventNameTapContent;
  118. event.messageModel = self.model;
  119. [self.delegate onCatchEvent:event];
  120. }
  121. }
  122. - (void)onTouchUpInside:(id)sender
  123. {
  124. NIMKitEvent *event = [[NIMKitEvent alloc] init];
  125. event.eventName = NIMKitEventNameTapContent;
  126. event.messageModel = self.model;
  127. [self.delegate onCatchEvent:event];
  128. }
  129. - (void)layoutSubviews{
  130. [super layoutSubviews];
  131. UIEdgeInsets contentInsets = self.model.contentViewInsets;
  132. CGSize contentSize = [self.model contentSize:KScreenWidth];
  133. CGRect imageViewFrame = CGRectMake(contentInsets.left, contentInsets.top, contentSize.width, contentSize.height);
  134. self.backView.frame = imageViewFrame;
  135. }
  136. @end