// // YOUPAIBBNIMSessionListCell.m // VQU // // Created by Elaine on 2021/10/22. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAIBBNIMSessionListCell.h" #import "NIMAvatarImageView.h" #import "UIView+NIM.h" #import "NIMKitUtil.h" #import "NIMBadgeView.h" #import "NTESSessionUtil.h" @implementation YOUPAIBBNIMSessionListCell #define AvatarWidth 58 //消息列表页面头像的大小 - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { _youpaipavatarImageView = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0,58, 58)]; _youpaipavatarImageView.contentMode = UIViewContentModeScaleAspectFill; [self.contentView addSubview:_youpaipavatarImageView]; _youpaipnameLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _youpaipnameLabel.textColor = LZ273145Color; _youpaipnameLabel.font = [UIFont systemFontOfSize:15.f]; [self.contentView addSubview:_youpaipnameLabel]; // _youpaipvipV = [[UIImageView alloc] init]; // [self.contentView addSubview:_youpaipvipV]; // [_youpaipvipV mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.youpaipnameLabel.mas_right).offset(5.0f); // make.centerY.equalTo(self.youpaipnameLabel); // }]; // _youpaipanchorTagImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_anchor_vlog"]]; // _youpaipanchorTagImgV.hidden = YES; // [self.contentView addSubview:_youpaipanchorTagImgV]; // [_youpaipanchorTagImgV mas_makeConstraints:^(MASConstraintMaker *make) { // make.right.equalTo(self.youpaipavatarImageView.mas_right).offset(0.0f); // make.bottom.equalTo(self.youpaipavatarImageView.mas_bottom).offset(0.0f); // make.size.mas_offset(CGSizeMake(14.0f, 14.0f)); // }]; _youpaipmessageLabel = [[UILabel alloc] initWithFrame:CGRectZero]; // _messageLabel.backgroundColor = [UIColor whiteColor]; _youpaipmessageLabel.font = [UIFont systemFontOfSize:12.f]; _youpaipmessageLabel.textColor = LZA3AABEColor; [self.contentView addSubview:_youpaipmessageLabel]; _youpaiptimeLabel = [[UILabel alloc] initWithFrame:CGRectZero]; // _youpaiptimeLabel.backgroundColor = [UIColor whiteColor]; _youpaiptimeLabel.font = [UIFont systemFontOfSize:11.f]; _youpaiptimeLabel.textColor = LZA3AABEColor; [self.contentView addSubview:_youpaiptimeLabel]; _youpaipbadgeView = [NIMBadgeView viewWithBadgeTip:@""]; _youpaipbadgeView.CirclegroundColor = [UIColor whiteColor]; _youpaipbadgeView.badgeBackgroundColor = HexColorFromRGB(0xFF3B30); [self.contentView addSubview:_youpaipbadgeView]; UIView *viewLine =[UIView new]; [self.contentView addSubview:viewLine]; [viewLine mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(0); make.left.mas_equalTo(20); make.bottom.mas_equalTo(0); make.height.mas_equalTo(1); }]; viewLine.backgroundColor = LZF5F4F7Color; } //v1.5.6 适配暗黑 云信消息列表 [self.contentView setBackgroundColor:[UIColor whiteColor]]; return self; } #define NameLabelMaxWidth 160.f #define MessageLabelMaxWidth 200.f - (void)youpaifrefresh:(NIMRecentSession*)recent{ BOOL youpaipisTop =[NTESSessionUtil recentSessionIsMark:recent type:NTESRecentSessionMarkTypeTop]; if (youpaipisTop) { self.contentView.backgroundColor = [UIColor whiteColor]; }else{ self.contentView.backgroundColor = [UIColor whiteColor]; } if ([recent.session.sessionId isEqualToString:[LCSaveData getSysId]] || [recent.session.sessionId isEqualToString:[LCSaveData getServerId]] ) { self.youpaipnameLabel.textColor = LZ273145Color; }else{ self.youpaipnameLabel.textColor = LZ273145Color; } self.youpaipnameLabel.nim_width = self.youpaipnameLabel.nim_width > NameLabelMaxWidth ? NameLabelMaxWidth : self.youpaipnameLabel.nim_width; self.youpaipmessageLabel.nim_width = self.youpaipmessageLabel.nim_width > MessageLabelMaxWidth ? MessageLabelMaxWidth : self.youpaipmessageLabel.nim_width; if (recent.unreadCount) { self.youpaipbadgeView.hidden = NO; self.youpaipbadgeView.badgeValue = @(recent.unreadCount).stringValue; }else{ self.youpaipbadgeView.hidden = YES; } } - (void)layoutSubviews{ [super layoutSubviews]; //Session List NSInteger sessionListAvatarLeft = 15; NSInteger sessionListNameTop = 15; NSInteger sessionListNameLeftToAvatar = 15; NSInteger sessionListMessageLeftToAvatar = 15; NSInteger sessionListMessageBottom = 15; NSInteger sessionListTimeRight = 15; NSInteger sessionListTimeTop = 15; NSInteger sessionBadgeTimeBottom = 15; NSInteger sessionBadgeTimeRight = 15; _youpaipavatarImageView.nim_left = sessionListAvatarLeft; _youpaipavatarImageView.nim_centerY = self.nim_height * .5f; _youpaipnameLabel.nim_top = sessionListNameTop; _youpaipnameLabel.nim_left = _youpaipavatarImageView.nim_right + sessionListNameLeftToAvatar; _youpaipmessageLabel.nim_left = _youpaipavatarImageView.nim_right + sessionListMessageLeftToAvatar; _youpaipmessageLabel.nim_bottom = self.nim_height - sessionListMessageBottom; _youpaiptimeLabel.nim_right = self.nim_width - sessionListTimeRight; _youpaiptimeLabel.nim_top = sessionListTimeTop; _youpaipbadgeView.nim_right = self.nim_width - sessionBadgeTimeRight; _youpaipbadgeView.nim_bottom = self.nim_height - sessionBadgeTimeBottom; } @end