| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | 
							- //
 
- //  TXGroupNoticeMessageCell.m
 
- //  TUIChat
 
- //
 
- //  Created by 王智 on 2024/8/30.
 
- //
 
- #import "TXGroupNoticeMessageCell.h"
 
- #import "TXGroupNoticeMessageContentView.h"
 
- #import "Masonry.h"
 
- @interface TXGroupNoticeMessageCell ()
 
- @property (nonatomic, strong) TXGroupNoticeMessageContentView *noticeContentView;
 
- @end
 
- @implementation TXGroupNoticeMessageCell
 
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
 
-     self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
 
-     
 
-     if (self) {
 
-         [self configUI];
 
-     }
 
-     return self;
 
- }
 
- - (void)configUI {
 
-     [self.container addSubview:self.noticeContentView];
 
-     [self.noticeContentView mas_remakeConstraints:^(MASConstraintMaker *make) {
 
-         make.left.mas_equalTo(self.avatarView.mas_right).offset(10);
 
-         make.top.mas_equalTo(self.avatarView.mas_top);
 
-         make.width.mas_equalTo(245);
 
-         make.bottom.mas_equalTo(self.container.mas_bottom).offset(-10);
 
-     }];
 
- }
 
- - (void)fillWithData:(TXGroupNoticeMessage *)data {
 
-     [super fillWithData:data];
 
-     [self.noticeContentView configCellWithMsgTitle:data.msgTitle content:data.msgContent];
 
-     CGFloat height = [self getContentViewHeight:data];
 
-     if (data.direction == MsgDirectionIncoming) {
 
-         [self.noticeContentView mas_remakeConstraints:^(MASConstraintMaker *make) {
 
-             make.left.mas_equalTo(self.avatarView.mas_right).offset(10);
 
-             make.top.mas_equalTo(self.avatarView.mas_top);
 
-             make.width.mas_equalTo(245);
 
-             make.height.mas_equalTo(height);
 
-         }];
 
-     }
 
-     else {
 
-         [self.noticeContentView mas_remakeConstraints:^(MASConstraintMaker *make) {
 
-             make.right.mas_equalTo(self.avatarView.mas_left).offset(-10);
 
-             make.top.mas_equalTo(self.avatarView.mas_top);
 
-             make.width.mas_equalTo(245);
 
-             make.height.mas_equalTo(height);
 
-         }];
 
-     }
 
- }
 
- - (CGFloat)getContentViewHeight:(TUIMessageCellData *)data {
 
-     TXGroupNoticeMessage *noticeMsg = (TXGroupNoticeMessage *)data;
 
-     if (![TXGroupNoticeMessageCell isEmptyString:noticeMsg.msgContent]) {
 
-         NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
 
-         paragraphStyle.maximumLineHeight = 21;
 
-         paragraphStyle.minimumLineHeight = 21;
 
-         UIFont *font = [UIFont systemFontOfSize:16.0f];
 
-         CGFloat height = [noticeMsg.msgContent boundingRectWithSize:CGSizeMake(221, CGFLOAT_MAX) options:(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading) attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:font} context:nil].size.height + 1;
 
-         CGFloat contentHeight = height + 64 + 11;
 
-         return contentHeight;
 
-     }
 
-     else {
 
-         return 64 + 11;
 
-     }
 
- }
 
- - (TXGroupNoticeMessageContentView *)noticeContentView {
 
-     if (!_noticeContentView) {
 
-         _noticeContentView = [TXGroupNoticeMessageContentView shareIntance];
 
-     }
 
-     return _noticeContentView;
 
- }
 
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
 
-     [super setSelected:selected animated:animated];
 
-     // Configure the view for the selected state
 
- }
 
- #pragma mark - TUIMessageCellProtocol
 
- + (CGSize)getContentSize:(TUIMessageCellData *)data {
 
-     TXGroupNoticeMessage *noticeMsg = (TXGroupNoticeMessage *)data;
 
-     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:noticeMsg.msgContent]) {
 
-         NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
 
-         paragraphStyle.maximumLineHeight = 21;
 
-         paragraphStyle.minimumLineHeight = 21;
 
-         UIFont *font = [UIFont systemFontOfSize:16.0f];
 
-         CGFloat height = [noticeMsg.msgContent boundingRectWithSize:CGSizeMake(221, CGFLOAT_MAX) options:(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading) attributes:@{NSFontAttributeName:font,NSParagraphStyleAttributeName:paragraphStyle} context:nil].size.height + 6;
 
-         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
 
 
  |