123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- //
- // TXGroupNoticeMessage.m
- // TUIChat
- //
- // Created by 王智 on 2024/8/30.
- //
- #import "TXGroupNoticeMessage.h"
- #define TXHexRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
- @implementation TXGroupNoticeMessage
- + (TUIMessageCellData *)getCellData:(V2TIMMessage *)message {
- NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data options:NSJSONReadingAllowFragments error:nil];
- TXGroupNoticeMessage *cellData = [[TXGroupNoticeMessage alloc] initWithDirection:message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming];
- cellData.innerMessage = message;
- cellData.msgID = message.msgID;
-
- cellData.noticeId = param[@"msgId"];
- cellData.msgTitle = param[@"msgTitle"];
- cellData.msgContent = param[@"msgContent"];
-
- return cellData;
- }
- + (NSString *)getDisplayString:(V2TIMMessage *)message {
- return @"[群公告]";
- }
- - (CGSize)contentSize {
- CGFloat width = ([UIScreen mainScreen].bounds.size.width > [UIScreen mainScreen].bounds.size.height ? [UIScreen mainScreen].bounds.size.height : [UIScreen mainScreen].bounds.size.width);
- if (![self isEmptyString:self.msgContent]) {
-
- CGFloat height = [self.msgContent boundingRectWithSize:CGSizeMake(225, CGFLOAT_MAX) options:(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15.0f],NSForegroundColorAttributeName:TXHexRGB(0x333333)} context:nil].size.height + 1;
- CGFloat contentHeight = height + 64 + 11;
- return CGSizeMake(width, contentHeight);
- }
- else {
- return CGSizeMake(width, 64 + 11);
- }
- }
- - (BOOL)isEmptyString:(NSString *)str {
- if (str == nil || str.length == 0) {
- return YES;
- }
- return NO;
- }
- @end
|