Files
peko-ios/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageMonentsModel.m
2024-07-17 17:49:33 +08:00

50 lines
1.4 KiB
Objective-C

//
// MessageMonentsModel.m
// YUMI
//
// Created by YUMI on 2023/1/30.
//
#import "MessageMonentsModel.h"
#import "AttachmentModel.h"
#import "MomentsInfoModel.h"
#import "NSObject+MJExtension.h"
@implementation MessageMonentsModel
- (instancetype)initWithMessage:(NIMMessage *)message {
if (self = [super initWithMessage:message]) {
self.messageType = SessionMessageType_Custom;
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
AttachmentModel * attach = obj.attachment;
NSDictionary * dic = attach.data;
self.monentsInfo = [MomentsInfoModel modelWithDictionary:dic];
self.imageUrl = dic[@"imageUrl"];
NSString * nick = self.monentsInfo.nick;
if (nick.length > 6) {
nick = [nick substringToIndex:6];
}
NSString * title = [NSString stringWithFormat:@"%@%@",nick, YMLocalizedString(@"MessageMonentsModel0")];
self.title = dic[@"title"] ? dic[@"title"] : title;
self.contentSize = CGSizeMake(250, 60);
self.height = (CONTENT_PADDING_V_TOTAL + 60);;
}
return self;
}
- (NSDictionary<NSAttributedStringKey, id> *)messageTextAttibutes {
UIFont *font = [UIFont systemFontOfSize:13.f];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:2.5];
return @{
NSFontAttributeName:font,
NSParagraphStyleAttributeName: paragraphStyle
};
}
- (NSString *)cellContent:(MessageBaseModel *)model {
return @"MessageContentMonentsView";
}
@end