This commit is contained in:
启星
2025-10-25 19:38:29 +08:00
parent 3a5cf56099
commit 90709a94c4
144 changed files with 890 additions and 821 deletions

View File

@@ -7,6 +7,7 @@
#import "QXRoomChatListView.h"
#import "UIImage+WebP.h"
#define messageNoticeColor RGB16(0xCCA882)
#define messageNameColor RGB16(0x00C8FF)
#define messageGiftColor RGB16(0xFFE309)
#define messageBubbleColor RGB16A(0x000000, 0.3)
@@ -66,7 +67,7 @@ NSInteger maxMessageCount = 20;
[self addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self);
make.top.equalTo(self).offset(0);
make.top.equalTo(self).offset(10);
make.bottom.equalTo(self).offset(-10);
}];
@@ -169,7 +170,7 @@ NSInteger maxMessageCount = 20;
}
-(void)insertNoitce{
QXRoomChatListModel *model = [QXRoomChatListModel new];
model.messageType = QXRoomChatMessageTypeSystem;
model.messageType = QXRoomChatMessageTypeNotice;
model.text = @"羽声语音严禁未成年人进行直播或打赏官方将24小时在线巡查。我们提倡绿色直播直播间严禁出现涉政、涉恐、涉黄、涉赌等违法违规内容严禁宣传封建迷信、宗教极端思想、出现低俗色情、吸烟酗酒等内容严禁违反社会主义核心价值观、践踏社会道德底线、诱导打赏、低俗 PK 、买卖金币等行为,请大家共同遵守、监督并及时举报。请勿相信各类刷钻、购买礼包、游戏币及电商贩卖等非官方广告信息,谨防网络诈骗。";
[self.dataArray addObject:model];
[self.tableView reloadData];
@@ -315,13 +316,13 @@ NSInteger maxMessageCount = 20;
height = 28+19+13+8 + height;
}
}else if (model.messageType == QXRoomChatMessageTypeGift) {
if ([model.FromUserInfo.chat_bubble isExist]) {
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-60-18];
height = 28+19+13+16 + height;
}else{
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-60-18-16];
height = 28+19+13+8 + height;
}
// if ([model.FromUserInfo.chat_bubble isExist]) {
// height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-16*2-8];
// height = 16*2 + height+1;
// }else{
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-16*2-8];
height = 8*2+messageBubbleMargin*2 + height+1;
// }
}else if(model.messageType == QXRoomChatMessageTypeEmoji){
if ([model.FromUserInfo.chat_bubble isExist]) {
height = 28+19+13+16 + 40;
@@ -689,26 +690,26 @@ NSInteger maxMessageCount = 20;
}
}
self.titleLabel.attributedText = attr;
self.nameLabel.text = message.FromUserInfo.nickname;
[self.headerImageView sd_setImageWithURL:[NSURL URLWithString:message.FromUserInfo.avatar]];
self.iconBgView.hidden = YES;
for (int i = 0;i < message.FromUserInfo.icon.count;i++) {
if (i < 3) {
self.iconBgView.hidden = NO;
UIImageView *iconImageView = self.iconViewArray[i];
iconImageView.hidden = NO;
[iconImageView sd_setImageWithURL:[NSURL URLWithString:message.FromUserInfo.icon[i]]];
}else{
self.iconBgView.hidden = YES;
}
}
// self.nameLabel.text = message.FromUserInfo.nickname;
// [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:message.FromUserInfo.avatar]];
// self.iconBgView.hidden = YES;
// for (int i = 0;i < message.FromUserInfo.icon.count;i++) {
// if (i < 3) {
// self.iconBgView.hidden = NO;
// UIImageView *iconImageView = self.iconViewArray[i];
// iconImageView.hidden = NO;
// [iconImageView sd_setImageWithURL:[NSURL URLWithString:message.FromUserInfo.icon[i]]];
// }else{
// self.iconBgView.hidden = YES;
// }
// }
}
-(void)initSubviews{
self.bgView = [[UIView alloc] init];
[self.contentView addSubview:self.bgView];
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(16);
make.right.mas_equalTo(0);
make.right.mas_lessThanOrEqualTo(-8);
make.top.mas_equalTo(messageBubbleMargin);
make.bottom.mas_equalTo(-messageBubbleMargin);
}];
@@ -723,36 +724,36 @@ NSInteger maxMessageCount = 20;
make.edges.equalTo(self.bgView);
}];
self.headerImageView = [[UIImageView alloc] init];
self.headerImageView.contentMode = UIViewContentModeScaleAspectFill;
self.headerImageView.backgroundColor = [UIColor whiteColor];
[self.headerImageView addRoundedCornersWithRadius:14];
[self.bgView addSubview:self.headerImageView];
[self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(16);
make.top.mas_equalTo(19);
make.size.mas_equalTo(CGSizeMake(28, 28));
}];
UIButton *headerBtn = [[UIButton alloc] init];
[headerBtn addTarget:self action:@selector(headerAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:headerBtn];
[headerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(self.headerImageView).offset(-2);
make.bottom.right.equalTo(self.headerImageView).offset(2);
}];
self.nameLabel = [[UILabel alloc] init];
self.nameLabel.textColor = RGB16(0xDED6ED);
self.nameLabel.font = [UIFont systemFontOfSize:14];
[self.bgView addSubview:self.nameLabel];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.headerImageView).offset(-3);
make.left.equalTo(self.headerImageView.mas_right).offset(8);
make.height.mas_equalTo(18);
}];
// self.headerImageView = [[UIImageView alloc] init];
// self.headerImageView.contentMode = UIViewContentModeScaleAspectFill;
// self.headerImageView.backgroundColor = [UIColor whiteColor];
// [self.headerImageView addRoundedCornersWithRadius:14];
// [self.bgView addSubview:self.headerImageView];
//
// [self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.mas_equalTo(16);
// make.top.mas_equalTo(19);
// make.size.mas_equalTo(CGSizeMake(28, 28));
// }];
//
// UIButton *headerBtn = [[UIButton alloc] init];
// [headerBtn addTarget:self action:@selector(headerAction) forControlEvents:(UIControlEventTouchUpInside)];
// [self.bgView addSubview:headerBtn];
// [headerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.top.equalTo(self.headerImageView).offset(-2);
// make.bottom.right.equalTo(self.headerImageView).offset(2);
// }];
//
// self.nameLabel = [[UILabel alloc] init];
// self.nameLabel.textColor = RGB16(0xDED6ED);
// self.nameLabel.font = [UIFont systemFontOfSize:14];
// [self.bgView addSubview:self.nameLabel];
// [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
// make.top.equalTo(self.headerImageView).offset(-3);
// make.left.equalTo(self.headerImageView.mas_right).offset(8);
// make.height.mas_equalTo(18);
// }];
//
self.titleLabel = [[UILabel alloc] init];
@@ -760,85 +761,95 @@ NSInteger maxMessageCount = 20;
self.titleLabel.font = [UIFont systemFontOfSize:14];
self.titleLabel.numberOfLines = 0;
[self.bgView addSubview:self.titleLabel];
// [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.equalTo(self.nameLabel).offset(0);
// make.top.equalTo(self.headerImageView.mas_bottom).offset(13);
// make.right.mas_lessThanOrEqualTo(-18);
// }];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.nameLabel).offset(0);
make.top.equalTo(self.headerImageView.mas_bottom).offset(13);
make.right.mas_lessThanOrEqualTo(-18);
make.left.equalTo(self.bgView).offset(8);
make.top.mas_equalTo(8);
make.bottom.mas_equalTo(-8);
make.right.mas_equalTo(-8);
}];
self.nameLabel.text = @"张三站撒旦撒大萨达撒";
// self.nameLabel.text = @"张三站撒旦撒大萨达撒";
[self.contentView bringSubviewToFront:self.titleLabel];
self.iconBgView = [[UIView alloc] init];
[self.bgView addSubview:self.iconBgView];
[self.iconBgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.nameLabel);
make.width.mas_equalTo(UserIconWidth*2+6);
make.height.mas_equalTo(16);
make.top.equalTo(self.nameLabel.mas_bottom).offset(2);
}];
CGFloat iconWidth = UserIconWidth;
CGFloat iconHeight = UserIconHeight;
CGFloat margin = 6;
for (int i = 0; i < 3; i++) {
UIImageView *iconImageView = [[UIImageView alloc] init];
iconImageView.hidden = YES;
iconImageView.contentMode = UIViewContentModeScaleAspectFit;
[self.iconBgView addSubview:iconImageView];
[iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(i*(iconWidth+margin));
make.width.mas_equalTo(iconWidth);
make.height.mas_equalTo(iconHeight);
make.centerY.equalTo(self.iconBgView);
}];
[self.iconViewArray addObject:iconImageView];
}
// self.iconBgView = [[UIView alloc] init];
// [self.bgView addSubview:self.iconBgView];
// [self.iconBgView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.equalTo(self.nameLabel);
// make.width.mas_equalTo(UserIconWidth*2+6);
// make.height.mas_equalTo(16);
// make.top.equalTo(self.nameLabel.mas_bottom).offset(2);
// }];
//
// CGFloat iconWidth = UserIconWidth;
// CGFloat iconHeight = UserIconHeight;
// CGFloat margin = 6;
// for (int i = 0; i < 3; i++) {
// UIImageView *iconImageView = [[UIImageView alloc] init];
// iconImageView.hidden = YES;
// iconImageView.contentMode = UIViewContentModeScaleAspectFit;
// [self.iconBgView addSubview:iconImageView];
// [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.mas_equalTo(i*(iconWidth+margin));
// make.width.mas_equalTo(iconWidth);
// make.height.mas_equalTo(iconHeight);
// make.centerY.equalTo(self.iconBgView);
// }];
// [self.iconViewArray addObject:iconImageView];
// }
}
-(void)loadBubble{
if ([self.message.FromUserInfo.chat_bubble isExist]) {
self.bubbleImageView.backgroundColor = UIColor.clearColor;
// self.bubbleImageView.image = [[UIImage imageNamed:@"chat_bubble2"] resizableImageWithCapInsets:UIEdgeInsetsMake(30, 40, 40, 40) resizingMode:(UIImageResizingModeStretch)];;
[self.bubbleImageView sd_setImageWithURL:[NSURL URLWithString:self.message.FromUserInfo.chat_bubble] placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(40, 40, 40, 40) resizingMode:(UIImageResizingModeStretch)];
self.bubbleImageView.image = image;
}];
[self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(8);
make.right.mas_equalTo(0);
make.top.mas_equalTo(0);
make.bottom.mas_equalTo(0);
}];
[self.headerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(16);
make.top.mas_equalTo(19);
}];
}else{
[self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(16);
make.right.mas_equalTo(-8);
make.top.mas_equalTo(messageBubbleMargin);
make.bottom.mas_equalTo(-messageBubbleMargin);
}];
[self.headerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(9);
make.top.mas_equalTo(11);
}];
self.bubbleImageView.image = nil;
self.bubbleImageView.backgroundColor = messageBubbleColor;
}
}
-(NSMutableArray *)iconViewArray{
if (!_iconViewArray) {
_iconViewArray = [NSMutableArray array];
}
return _iconViewArray;
// if ([self.message.FromUserInfo.chat_bubble isExist]) {
// self.bubbleImageView.backgroundColor = UIColor.clearColor;
//// self.bubbleImageView.image = [[UIImage imageNamed:@"chat_bubble2"] resizableImageWithCapInsets:UIEdgeInsetsMake(30, 40, 40, 40) resizingMode:(UIImageResizingModeStretch)];;
// [self.bubbleImageView sd_setImageWithURL:[NSURL URLWithString:self.message.FromUserInfo.chat_bubble] placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
// image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(40, 40, 40, 40) resizingMode:(UIImageResizingModeStretch)];
// self.bubbleImageView.image = image;
// }];
// [self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
// make.left.mas_equalTo(8);
// make.right.mas_equalTo(0);
// make.top.mas_equalTo(0);
// make.bottom.mas_equalTo(0);
// }];
// [self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
// make.left.mas_equalTo(16);
// make.top.mas_equalTo(16);
// make.bottom.mas_equalTo(-16);
// make.right.mas_equalTo(-16);
// }];
// }else{
// [self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
// make.left.mas_equalTo(16);
// make.right.mas_equalTo(-8);
// make.top.mas_equalTo(messageBubbleMargin);
// make.bottom.mas_equalTo(-messageBubbleMargin);
// }];
// [self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
// make.left.mas_equalTo(8);
// make.top.mas_equalTo(8);
// make.bottom.mas_equalTo(-8);
// make.right.mas_equalTo(-8);
// }];
// self.bubbleImageView.image = nil;
// self.bubbleImageView.backgroundColor = messageBubbleColor;
// }
}
//-(NSMutableArray *)iconViewArray{
// if (!_iconViewArray) {
// _iconViewArray = [NSMutableArray array];
// }
// return _iconViewArray;
//}
@end
@@ -1103,6 +1114,9 @@ NSInteger maxMessageCount = 20;
}
}
}
if (message.messageType == QXRoomChatMessageTypeNotice) {
[attr yy_setColor:messageNameColor range:NSMakeRange(0, attr.length)];
}
self.titleLabel.attributedText = attr;
}