123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- //
- // YOUPAILCCallContentView.m
- // LiveChat
- //
- // Created by 张灿 on 2018/11/27.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCCallContentView.h"
- #import "YOUPAILCCallAttachment.h"
- @interface YOUPAILCCallContentView()
- @property(nonatomic,strong)UIImageView* backView;
- @property(nonatomic,strong)UILabel* topTitle;
- @property(nonatomic,strong)UIImageView* iconImgView;
- @property(nonatomic,strong)UILabel* contentLabel;
- @end
- @implementation YOUPAILCCallContentView
- - (instancetype)initSessionMessageContentView{
- self = [super initSessionMessageContentView];
- if (self) {
- // self.opaque = YES;
- UIImageView* testView = [[UIImageView alloc] initWithFrame:CGRectZero];
- testView.backgroundColor= [UIColor clearColor];
- testView.contentMode = UIViewContentModeScaleAspectFill;
- testView.userInteractionEnabled = YES;
- UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapHandel:)];
- [testView addGestureRecognizer:tap];
- self.backView = testView;
- [self addSubview:testView];
- }
- return self;
- }
- - (void)refresh:(NIMMessageModel *)data{
- [super refresh:data];
- NIMCustomObject *customObject = (NIMCustomObject*)data.message.messageObject;
- id attachment = customObject.attachment;
- if ([attachment isKindOfClass:[YOUPAILCCallAttachment class]]) {
- for (UIView* subview in self.backView.subviews) {
- [subview removeFromSuperview];
- }
- YOUPAILCCallAttachment* attachment = (YOUPAILCCallAttachment*)customObject.attachment;
- NSString* txtStr = @"";
- if (attachment.status==3) {
- txtStr = @"超时未接听";
- }else if (attachment.status==4){
- txtStr = [NSString stringWithFormat:@"通话时长:%@",[ZCUtils getMinTimeStrFromSS:attachment.call_time]];
- }
- // NSLog(@"代表是自己发的%@-----%@", [LCSaveModel getUserModel].userinfo.user_id , attachment.from_uid);
- if ([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id integerValue] == attachment.from_uid) {//代表是自己发的
-
- // NSLog(@"代表是自己发的%@-----%@", [LCSaveModel getUserModel].userinfo.user_id , attachment.from_uid);
- if (attachment.status==1) {
- txtStr = @"已取消";
-
-
- }else if (attachment.status==2){
- txtStr = @"对方已拒绝";
-
- }
- }else{
- if (attachment.status==1) {
- txtStr = @"对方已取消";
-
- }else if (attachment.status==2){
- txtStr = @"已拒绝";
-
- }
- }
-
-
- UIImageView* imgV = [[UIImageView alloc]initWithFrame:CGRectMake(8, 2, 24, 16)];
- imgV.contentMode = UIViewContentModeScaleAspectFill;
- imgV.image = [UIImage imageNamed:@"vqu_images_IM_call_video"];
- [self.backView addSubview:imgV];
-
- UILabel* nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(40, 0, 0, 20)];
- nameLabel.textColor = data.shouldShowLeft ? LZ273145Color : [UIColor whiteColor];
- nameLabel.textAlignment = NSTextAlignmentLeft;
- nameLabel.font = LCFont(14);
- nameLabel.text = txtStr;
- CGFloat nameWidth =[txtStr widthWithFont:LCFont(14) constrainedToHeight:20];
- nameLabel.frame = CGRectMake(40,0,nameWidth+2, 20);
- [self.backView addSubview:nameLabel];
-
- if (data.message.isOutgoingMsg) {//是自己往外发的
- nameLabel.frame = CGRectMake(10, 0, nameWidth+2, 20);
- imgV.frame = CGRectMake(nameWidth+20, 2, 24, 16);
- // nameLabel.textColor = [UIColor whiteColor];
- imgV.image = [UIImage imageNamed:@"vqu_images_IM_call_video_right"];
- }else{
- imgV.image = [UIImage imageNamed:@"vqu_images_IM_call_video_left"];
- }
- if (data.message.isOutgoingMsg) {//代表是自己发的
-
- // NSLog(@"代表是自己发的%@-----%@", [LCSaveModel getUserModel].userinfo.user_id , attachment.from_uid);
- if (attachment.status==1) {
- txtStr = @"已取消";
- imgV.image = [UIImage imageNamed:@"vqu_images_vqu_images_IM_call_video_NO_right"];
-
- }else if (attachment.status==2){
- txtStr = @"对方已拒绝";
- if (data.message.isOutgoingMsg) {//是自己往外发的
- nameLabel.frame = CGRectMake(10, 0, nameWidth+2, 20);
- imgV.frame = CGRectMake(nameWidth+20, 2, 21, 21);
- nameLabel.textColor = [UIColor whiteColor];
- imgV.image = [UIImage imageNamed:@"vqu_images_vqu_images_IM_call_video_NO_right"];
- }else{
-
- }
- }
- }else{
- if (attachment.status==1) {
- txtStr = @"对方已取消";
- imgV.image = [UIImage imageNamed:@"vqu_images_vqu_images_IM_call_video_NO_left"];
- }else if (attachment.status==2){
- txtStr = @"已拒绝";
- if (data.message.isOutgoingMsg) {//是自己往外发的
- nameLabel.frame = CGRectMake(10, 0, nameWidth+2, 20);
- imgV.frame = CGRectMake(nameWidth+20, 2, 21, 21);
- nameLabel.textColor = [UIColor whiteColor];
- imgV.image = [UIImage imageNamed:@"vqu_images_vqu_images_IM_call_video_NO_left"];
- }else{
-
- }
- }
- }
- }
- }
- - (void)tapHandel:(UITapGestureRecognizer*)tap{
- if (tap.state == UIGestureRecognizerStateEnded) {
- NIMKitEvent *event = [[NIMKitEvent alloc] init];
- event.eventName = NIMKitEventNameTapContent;
- event.messageModel = self.model;
- [self.delegate onCatchEvent:event];
- }
- }
- - (void)onTouchUpInside:(id)sender
- {
- NIMKitEvent *event = [[NIMKitEvent alloc] init];
- event.eventName = NIMKitEventNameTapContent;
- event.messageModel = self.model;
- [self.delegate onCatchEvent:event];
- }
- - (void)layoutSubviews{
- [super layoutSubviews];
- UIEdgeInsets contentInsets = self.model.contentViewInsets;
- CGSize contentSize = [self.model contentSize:KScreenWidth];
- CGRect imageViewFrame = CGRectMake(contentInsets.left, contentInsets.top, contentSize.width, contentSize.height);
- self.backView.frame = imageViewFrame;
-
- }
- @end
|