50 lines
1.9 KiB
Objective-C
50 lines
1.9 KiB
Objective-C
//
|
|
// THGiveVipMessageCellData.m
|
|
// TreeHole
|
|
//
|
|
// Created by iOS on 2023/2/9.
|
|
// Copyright © 2023 CYH. All rights reserved.
|
|
//
|
|
|
|
#import "THGiveVipMessageCellData.h"
|
|
|
|
@implementation THGiveVipMessageCellData
|
|
|
|
///重写父类的 getCellData: 方法。用于把 V2TIMMessage 转换成消息列表 Cell 的绘制数据
|
|
+ (TUIMessageCellData *)getCellData:(V2TIMMessage *)message{
|
|
NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data options:NSJSONReadingAllowFragments error:nil];
|
|
THGiveVipMessageCellData *cellData = [[THGiveVipMessageCellData alloc] initWithDirection:message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming];
|
|
cellData.innerMessage = message;
|
|
cellData.msgID = message.msgID;
|
|
cellData.vipTypeStr = param[@"title_name"];
|
|
// cellData.vipImg = UIImageMake(@"TH_giveVipMessageIcon");
|
|
cellData.avatarUrl = [NSURL URLWithString:message.faceURL];
|
|
return cellData;
|
|
}
|
|
|
|
+ (NSString *)getDisplayString:(V2TIMMessage *)message {
|
|
NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data options:NSJSONReadingAllowFragments error:nil];
|
|
NSString *vipTypeStr = param[@"title_name"];
|
|
NSString *displayStr;
|
|
if (message.isSelf) {
|
|
//自己发送的
|
|
displayStr = [NSString stringWithFormat:@"您送出了%@", vipTypeStr];
|
|
} else {
|
|
//接收
|
|
displayStr = [NSString stringWithFormat:@"%@赠送%@给您", message.nickName, vipTypeStr];
|
|
}
|
|
return displayStr;
|
|
}
|
|
|
|
- (CGSize)contentSize {
|
|
// CGRect rect = [self.text boundingRectWithSize:CGSizeMake(300, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:15] } context:nil];
|
|
// CGSize size = CGSizeMake(ceilf(rect.size.width)+1, ceilf(rect.size.height));
|
|
CGSize size = CGSizeMake(177, 50);
|
|
// 加上气泡边距
|
|
size.height += 30;
|
|
size.width += 30;
|
|
return size;
|
|
}
|
|
|
|
@end
|