37 lines
1.4 KiB
Objective-C
Executable File
37 lines
1.4 KiB
Objective-C
Executable File
//
|
|
// TXGiftRecordCellData.m
|
|
// romantic
|
|
//
|
|
// Created by bj_szd on 2022/9/6.
|
|
// Copyright © 2022 romantic. All rights reserved.
|
|
//
|
|
|
|
#import "TXGiftRecordCellData.h"
|
|
|
|
@implementation TXGiftRecordCellData
|
|
|
|
+ (TUIMessageCellData *)getCellData:(V2TIMMessage *)message{
|
|
NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data options:NSJSONReadingAllowFragments error:nil];
|
|
TXGiftRecordCellData *cellData = [[TXGiftRecordCellData alloc] initWithDirection:message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming];
|
|
cellData.msgID = message.msgID;
|
|
cellData.text = param[@"text"];
|
|
cellData.avatarUrl = [NSURL URLWithString:message.faceURL];
|
|
return cellData;
|
|
}
|
|
|
|
+ (NSString *)getDisplayString:(V2TIMMessage *)message {
|
|
NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data options:NSJSONReadingAllowFragments error:nil];
|
|
return param[@"text"];
|
|
}
|
|
|
|
- (CGSize)contentSize {
|
|
CGFloat textMaxWidth = 240.f;
|
|
CGRect rect = [self.text boundingRectWithSize:CGSizeMake(textMaxWidth, MAXFLOAT)
|
|
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
|
|
attributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:15 weight:UIFontWeightMedium] }
|
|
context:nil];
|
|
return CGSizeMake(rect.size.width+20, rect.size.height+20);
|
|
}
|
|
|
|
@end
|