1.房间背景,2.修复bug

This commit is contained in:
liyuhua
2024-05-22 12:06:48 +08:00
parent a3235abdf0
commit 415b7e2bbb
89 changed files with 541 additions and 387 deletions

View File

@@ -111,48 +111,53 @@
}
- (void)render:(MessageGuildModel *)model {
self.message = model.message;
NIMCustomObject *obj = (NIMCustomObject *)model.message.messageObject;
AttachmentModel * attach = obj.attachment;
self.attachment = attach;
GuildMessageModel * info;
if (model.message.localExt) {
info = [GuildMessageModel modelWithDictionary:model.message.localExt];
} else {
info = [GuildMessageModel modelWithDictionary:attach.data];
}
self.messageInfo = info;
self.titleLabel.text = info.layout.title.content;
self.titleLabel.font = [UIFont systemFontOfSize:info.layout.title.fontSize weight:info.layout.title.fontBold?UIFontWeightBold:UIFontWeightRegular];
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]init];
GuildMessageLayoutModel *layout = info.layout;
for (GuildMessageLayoutInfoModel *params in layout.contents) {
if (params.content.length > 0) {
if ([params.content containsString:@"/r/n"]) {
params.content = @"\r\n";
}
NSMutableAttributedString *subAttr = [[NSMutableAttributedString alloc]initWithString:params.content];
if (params.fontSize > 0) {
[subAttr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:params.fontSize weight:params.fontBold?UIFontWeightBold:UIFontWeightRegular] range:NSMakeRange(0, subAttr.length)];
}
if (params.fontColor.length > 0) {
[subAttr addAttribute:NSForegroundColorAttributeName value:[DJDKMIMOMColor colorWithHexString:params.fontColor] range:NSMakeRange(0, subAttr.length)];
}
[attr appendAttributedString:subAttr];
}
}
attr.yy_lineSpacing = 5;
self.contentLabel.attributedText = attr;
self.contentLabel.textAlignment = NSTextAlignmentCenter;
CGSize maxSize = CGSizeMake(MESSAGE_MAX_WIDTH - MESSAGE_TEXT_PADDING * 2, CGFLOAT_MAX);
YYTextLayout * contentLayout = [YYTextLayout layoutWithContainerSize:maxSize text:attr];
CGFloat contentHeight = contentLayout.textBoundingSize.height + 5;
/// 20 title15 titlecontent15
[self.contentView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(contentHeight + 20+ 15 + 15);
}];
BOOL isCommonNotice = (attach.second == Custom_Message_Sub_Hall_Notice || attach.second == Custom_Message_Sub_Hall_Become_Hall);
self.message = model.message;
NIMCustomObject *obj = (NIMCustomObject *)model.message.messageObject;
AttachmentModel * attach = (AttachmentModel *)obj.attachment;
self.attachment = attach;
GuildMessageModel * info;
if (model.message.localExt) {
info = [GuildMessageModel modelWithDictionary:model.message.localExt];
} else {
info = [GuildMessageModel modelWithDictionary:attach.data];
}
self.messageInfo = info;
self.titleLabel.text = info.layout.title.content;
self.titleLabel.font = [UIFont systemFontOfSize:info.layout.title.fontSize weight:info.layout.title.fontBold?UIFontWeightBold:UIFontWeightRegular];
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]init];
GuildMessageLayoutModel *layout = info.layout;
for (GuildMessageLayoutInfoModel *params in layout.contents) {
if (params.content.length > 0) {
if ([params.content containsString:@"/r/n"]) {
params.content = @"\r\n";
}
NSMutableAttributedString *subAttr = [[NSMutableAttributedString alloc]initWithString:params.content];
if (params.fontSize > 0) {
[subAttr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:params.fontSize weight:params.fontBold?UIFontWeightBold:UIFontWeightRegular] range:NSMakeRange(0, subAttr.length)];
}
if (params.fontColor.length > 0) {
[subAttr addAttribute:NSForegroundColorAttributeName value:[DJDKMIMOMColor colorWithHexString:params.fontColor] range:NSMakeRange(0, subAttr.length)];
}
[attr appendAttributedString:subAttr];
}
}
attr.yy_lineSpacing = 5;
self.contentLabel.attributedText = attr;
self.contentLabel.textAlignment = NSTextAlignmentCenter;
CGSize maxSize = CGSizeMake(MESSAGE_MAX_WIDTH - MESSAGE_TEXT_PADDING * 2, CGFLOAT_MAX);
YYTextLayout * contentLayout = [YYTextLayout layoutWithContainerSize:maxSize text:attr];
CGFloat contentHeight = contentLayout.textBoundingSize.height + 5;
/// 20 title15 titlecontent15
[self.contentView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(contentHeight + 20+ 15 + 15);
}];
BOOL isCommonNotice ;
if(attach.first == CustomMessageType_Hall){
isCommonNotice = (attach.second == Custom_Message_Sub_Hall_Notice || attach.second == Custom_Message_Sub_Hall_Become_Hall);
}else{
isCommonNotice = !(attach.second == Custom_Message_Sub_New_Hall_Invite || attach.second == Custom_Message_Sub_New_Hall_Apply);
}
if (!isCommonNotice) {
self.controlStackView.hidden = NO;
if (info.msgStatus == 0) {
@@ -235,7 +240,7 @@
[params safeSetObject:[AccountInfoStorage instance].getUid forKey:@"uid"];
///0 1
NSString * type = sender.tag == 1000? @"0" : @"1";
if (self.attachment.second == Custom_Message_Sub_Hall_Apply_Join || self.attachment.second == Custom_Message_Sub_Hall_Manager_Invite || self.attachment.second == Custom_Message_Sub_Hall_Apply_Exit) {
if (self.attachment.second == Custom_Message_Sub_Hall_Apply_Join || self.attachment.second == Custom_Message_Sub_Hall_Manager_Invite || self.attachment.second == Custom_Message_Sub_Hall_Apply_Exit || self.attachment.second == Custom_Message_Sub_New_Hall_Invite || self.attachment.second == Custom_Message_Sub_New_Hall_Apply) {
if (self.attachment.second != Custom_Message_Sub_Hall_Apply_Exit) {
[params setObject:type forKey:@"type"];
}