123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- //
- // NTESSessionListCell.m
- // NIMDemo
- //
- // Created by chris on 15/2/10.
- // Copyright (c) 2015年 Netease. All rights reserved.
- //
- #import "NIMSessionListCell.h"
- #import "NIMAvatarImageView.h"
- #import "UIView+NIM.h"
- #import "NIMKitUtil.h"
- #import "NIMBadgeView.h"
- #import "NTESSessionUtil.h"
- @implementation NIMSessionListCell
- #define AvatarWidth 52 //消息列表页面头像的大小
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- _avatarImageView = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0,52, 52)];
- _avatarImageView.cornerRadius = 26;
- _avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
- [self.contentView addSubview:_avatarImageView];
- _nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- _nameLabel.textColor = LZ273145Color;
- _nameLabel.font = [UIFont systemFontOfSize:15.f];
- [self.contentView addSubview:_nameLabel];
-
- _vipV = [[UIImageView alloc] init];
- [self.contentView addSubview:_vipV];
- [_vipV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.nameLabel.mas_right).offset(5.0f);
- make.centerY.equalTo(self.nameLabel);
- }];
-
- _anchorTagImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_anchor_vlog"]];
- _anchorTagImgV.hidden = YES;
- [self.contentView addSubview:_anchorTagImgV];
- [_anchorTagImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.avatarImageView.mas_right).offset(0.0f);
- make.bottom.equalTo(self.avatarImageView.mas_bottom).offset(0.0f);
- make.size.mas_offset(CGSizeMake(14.0f, 14.0f));
- }];
-
-
- _intimateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_intimateBtn setImage:[UIImage imageNamed:@"vqu_images_im_intimate"] forState:UIControlStateNormal];
- _intimateBtn.userInteractionEnabled = NO;
- [_intimateBtn setTitleColor:LZFE66A4Color forState:UIControlStateNormal];
- _intimateBtn.titleLabel.font = LCFont(10.0f);
- _intimateBtn.hidden = YES;
- [_intimateBtn setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
- [self.contentView addSubview:_intimateBtn];
- [_intimateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.bottom.offset(-12.0f);
- make.height.offset(15.0f);
- }];
-
- _officialImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_anchor_official"]];
- _officialImgV.hidden = YES;
- _officialImgV.nim_size = CGSizeMake(26.0f, 15.0f);
- [self.contentView addSubview:_officialImgV];
-
- _messageLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- // _messageLabel.backgroundColor = [UIColor whiteColor];
- _messageLabel.font = [UIFont systemFontOfSize:12.f];
- _messageLabel.textColor = LZA3AABEColor;
- [self.contentView addSubview:_messageLabel];
-
- _timeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- // _timeLabel.backgroundColor = [UIColor whiteColor];
- _timeLabel.font = [UIFont systemFontOfSize:11.f];
- _timeLabel.textColor = LZA3AABEColor;
- [self.contentView addSubview:_timeLabel];
-
- _badgeView = [NIMBadgeView viewWithBadgeTip:@""];
- _badgeView.CirclegroundColor = HexColorFromRGB(0xFF3B30);
- _badgeView.badgeBackgroundColor = HexColorFromRGB(0xFF3B30);
- [self.contentView addSubview:_badgeView];
-
- // 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 =HexColorFromRGB(0x28262D);
- }
- //v1.5.6 适配暗黑 云信消息列表
- [self.contentView setBackgroundColor:[UIColor whiteColor]];
- return self;
- }
- #define NameLabelMaxWidth 160.f
- #define MessageLabelMaxWidth 200.f
- - (void)refresh:(NIMRecentSession*)recent{
- BOOL isTop =[NTESSessionUtil recentSessionIsMark:recent type:NTESRecentSessionMarkTypeTop];
- if (isTop) {
- 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.nameLabel.textColor = LZ273145Color;
- // }else{
- // self.nameLabel.textColor = LZ273145Color;
- // }
- // NSLog(@"%@",[LCSaveData getServiceIdArr]);
- if ([recent.session.sessionId isEqualToString:[LCSaveData getSysId]] ||
- [recent.session.sessionId isEqualToString:@"11"] ||
- [[LCSaveData getServiceIdArr] containsObject:recent.session.sessionId]) {
- self.officialImgV.hidden = NO;
- }else{
- self.officialImgV.hidden = YES;
- }
- self.nameLabel.nim_width = self.nameLabel.nim_width > NameLabelMaxWidth ? NameLabelMaxWidth : self.nameLabel.nim_width;
- self.messageLabel.nim_width = self.messageLabel.nim_width > MessageLabelMaxWidth ? MessageLabelMaxWidth : self.messageLabel.nim_width;
-
- if (recent.unreadCount) {
- self.badgeView.hidden = NO;
- self.badgeView.badgeValue = @(recent.unreadCount).stringValue;
- }else{
- self.badgeView.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;
- _avatarImageView.nim_left = sessionListAvatarLeft;
- _avatarImageView.nim_centerY = self.nim_height * .5f;
- _nameLabel.nim_top = sessionListNameTop;
- _nameLabel.nim_left = _avatarImageView.nim_right + sessionListNameLeftToAvatar;
-
- _messageLabel.nim_bottom = self.nim_height - sessionListMessageBottom;
- _timeLabel.nim_right = self.nim_width - sessionListTimeRight;
- _timeLabel.nim_top = sessionListTimeTop;
- _badgeView.nim_right = _avatarImageView.nim_right;
- _badgeView.nim_top = _avatarImageView.nim_top;
- _officialImgV.nim_left = _avatarImageView.nim_right + sessionListMessageLeftToAvatar;
- _officialImgV.nim_bottom = self.nim_height - sessionListMessageBottom;
- if (_officialImgV.hidden) {
- _messageLabel.nim_left = _avatarImageView.nim_right + sessionListMessageLeftToAvatar;
- }else{
- _messageLabel.nim_left = _officialImgV.nim_right + 4.0f;
- }
- }
- @end
|