cdts/xdts-ios 3/TreeHole/Code/Chat(消息&聊天)/MessageCellData/THGiveVipMessageCellData.m

50 lines
1.9 KiB
Mathematica
Raw Permalink Normal View History

2023-07-27 09:20:00 +08:00
//
// 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