// // MessageHeadlinesModel.m // YuMi // // Created by duoban on 2024/5/9. // #import "MessageHeadlinesModel.h" #import "AttachmentModel.h" @implementation MessageHeadlinesModel - (instancetype)initWithMessage:(NIMMessage *)message { if (self = [super initWithMessage:message]) { self.messageType = SessionMessageType_Custom; NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; AttachmentModel * attach = (AttachmentModel *)obj.attachment; MSSessionPublicChatHallTopModel * info = [MSSessionPublicChatHallTopModel modelWithJSON:attach.data]; self.info = info; self.contentSize = CGSizeMake(KScreenWidth, 20); if (info.nick != nil){ NSString *text = [NSString stringWithFormat:YMLocalizedString(@"MSSessionContextHeadlinesView0"),info.nick]; self.textAtt = [[NSMutableAttributedString alloc]initWithString:text attributes:@{NSFontAttributeName:kFontMedium(9),NSForegroundColorAttributeName:UIColorFromRGB(0x333333)}]; [self.textAtt addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xDE3446)} range:[text rangeOfString:info.nick]]; } self.height = (20 + CONTENT_PADDING_V_TOTAL); self.isHiddenAvatar = YES; } return self; } - (NSString *)cellContent:(MessageBaseModel *)model { return @"MSSessionContextHeadlinesView"; } @end