YOUPAIBBNIMSessionListCell.m 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // YOUPAIBBNIMSessionListCell.m
  3. // VQU
  4. //
  5. // Created by Elaine on 2021/10/22.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIBBNIMSessionListCell.h"
  9. #import "NIMAvatarImageView.h"
  10. #import "UIView+NIM.h"
  11. #import "NIMKitUtil.h"
  12. #import "NIMBadgeView.h"
  13. #import "NTESSessionUtil.h"
  14. @implementation YOUPAIBBNIMSessionListCell
  15. #define AvatarWidth 58 //消息列表页面头像的大小
  16. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  17. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  18. if (self) {
  19. _youpaipavatarImageView = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0,58, 58)];
  20. _youpaipavatarImageView.contentMode = UIViewContentModeScaleAspectFill;
  21. [self.contentView addSubview:_youpaipavatarImageView];
  22. _youpaipnameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  23. _youpaipnameLabel.textColor = LZ273145Color;
  24. _youpaipnameLabel.font = [UIFont systemFontOfSize:15.f];
  25. [self.contentView addSubview:_youpaipnameLabel];
  26. // _youpaipvipV = [[UIImageView alloc] init];
  27. // [self.contentView addSubview:_youpaipvipV];
  28. // [_youpaipvipV mas_makeConstraints:^(MASConstraintMaker *make) {
  29. // make.left.equalTo(self.youpaipnameLabel.mas_right).offset(5.0f);
  30. // make.centerY.equalTo(self.youpaipnameLabel);
  31. // }];
  32. // _youpaipanchorTagImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_anchor_vlog"]];
  33. // _youpaipanchorTagImgV.hidden = YES;
  34. // [self.contentView addSubview:_youpaipanchorTagImgV];
  35. // [_youpaipanchorTagImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  36. // make.right.equalTo(self.youpaipavatarImageView.mas_right).offset(0.0f);
  37. // make.bottom.equalTo(self.youpaipavatarImageView.mas_bottom).offset(0.0f);
  38. // make.size.mas_offset(CGSizeMake(14.0f, 14.0f));
  39. // }];
  40. _youpaipmessageLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  41. // _messageLabel.backgroundColor = [UIColor whiteColor];
  42. _youpaipmessageLabel.font = [UIFont systemFontOfSize:12.f];
  43. _youpaipmessageLabel.textColor = LZA3AABEColor;
  44. [self.contentView addSubview:_youpaipmessageLabel];
  45. _youpaiptimeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  46. // _youpaiptimeLabel.backgroundColor = [UIColor whiteColor];
  47. _youpaiptimeLabel.font = [UIFont systemFontOfSize:11.f];
  48. _youpaiptimeLabel.textColor = LZA3AABEColor;
  49. [self.contentView addSubview:_youpaiptimeLabel];
  50. _youpaipbadgeView = [NIMBadgeView viewWithBadgeTip:@""];
  51. _youpaipbadgeView.CirclegroundColor = [UIColor whiteColor];
  52. _youpaipbadgeView.badgeBackgroundColor = HexColorFromRGB(0xFF3B30);
  53. [self.contentView addSubview:_youpaipbadgeView];
  54. UIView *viewLine =[UIView new];
  55. [self.contentView addSubview:viewLine];
  56. [viewLine mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.right.mas_equalTo(0);
  58. make.left.mas_equalTo(20);
  59. make.bottom.mas_equalTo(0);
  60. make.height.mas_equalTo(1);
  61. }];
  62. viewLine.backgroundColor = LZF5F4F7Color;
  63. }
  64. //v1.5.6 适配暗黑 云信消息列表
  65. [self.contentView setBackgroundColor:[UIColor whiteColor]];
  66. return self;
  67. }
  68. #define NameLabelMaxWidth 160.f
  69. #define MessageLabelMaxWidth 200.f
  70. - (void)youpaifrefresh:(NIMRecentSession*)recent{
  71. BOOL youpaipisTop =[NTESSessionUtil recentSessionIsMark:recent type:NTESRecentSessionMarkTypeTop];
  72. if (youpaipisTop) {
  73. self.contentView.backgroundColor = [UIColor whiteColor];
  74. }else{
  75. self.contentView.backgroundColor = [UIColor whiteColor];
  76. }
  77. if ([recent.session.sessionId isEqualToString:[LCSaveData getSysId]] || [recent.session.sessionId isEqualToString:[LCSaveData getServerId]] ) {
  78. self.youpaipnameLabel.textColor = LZ273145Color;
  79. }else{
  80. self.youpaipnameLabel.textColor = LZ273145Color;
  81. }
  82. self.youpaipnameLabel.nim_width = self.youpaipnameLabel.nim_width > NameLabelMaxWidth ? NameLabelMaxWidth : self.youpaipnameLabel.nim_width;
  83. self.youpaipmessageLabel.nim_width = self.youpaipmessageLabel.nim_width > MessageLabelMaxWidth ? MessageLabelMaxWidth : self.youpaipmessageLabel.nim_width;
  84. if (recent.unreadCount) {
  85. self.youpaipbadgeView.hidden = NO;
  86. self.youpaipbadgeView.badgeValue = @(recent.unreadCount).stringValue;
  87. }else{
  88. self.youpaipbadgeView.hidden = YES;
  89. }
  90. }
  91. - (void)layoutSubviews{
  92. [super layoutSubviews];
  93. //Session List
  94. NSInteger sessionListAvatarLeft = 15;
  95. NSInteger sessionListNameTop = 15;
  96. NSInteger sessionListNameLeftToAvatar = 15;
  97. NSInteger sessionListMessageLeftToAvatar = 15;
  98. NSInteger sessionListMessageBottom = 15;
  99. NSInteger sessionListTimeRight = 15;
  100. NSInteger sessionListTimeTop = 15;
  101. NSInteger sessionBadgeTimeBottom = 15;
  102. NSInteger sessionBadgeTimeRight = 15;
  103. _youpaipavatarImageView.nim_left = sessionListAvatarLeft;
  104. _youpaipavatarImageView.nim_centerY = self.nim_height * .5f;
  105. _youpaipnameLabel.nim_top = sessionListNameTop;
  106. _youpaipnameLabel.nim_left = _youpaipavatarImageView.nim_right + sessionListNameLeftToAvatar;
  107. _youpaipmessageLabel.nim_left = _youpaipavatarImageView.nim_right + sessionListMessageLeftToAvatar;
  108. _youpaipmessageLabel.nim_bottom = self.nim_height - sessionListMessageBottom;
  109. _youpaiptimeLabel.nim_right = self.nim_width - sessionListTimeRight;
  110. _youpaiptimeLabel.nim_top = sessionListTimeTop;
  111. _youpaipbadgeView.nim_right = self.nim_width - sessionBadgeTimeRight;
  112. _youpaipbadgeView.nim_bottom = self.nim_height - sessionBadgeTimeBottom;
  113. }
  114. @end