优化长按聊天记录 如果是自己 不要显示举报

This commit is contained in:
2026-02-04 18:39:25 +08:00
parent 3ed120106e
commit db9f07d199
3 changed files with 47 additions and 2 deletions

View File

@@ -22,10 +22,20 @@ static CGFloat const kKBChatActionRowHeight = 52.0;
@implementation KBChatMessageActionPopView
+ (CGFloat)preferredHeightWithShowsReportAction:(BOOL)showsReportAction {
// 2 Copy + Delete
// 3 Copy + Delete + Report
NSInteger rows = showsReportAction ? 3 : 2;
NSInteger lines = showsReportAction ? 2 : 1;
return kKBChatActionRowHeight * rows + 0.5 * lines;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_showsReportAction = YES;
[self setupUI];
[self applyReportVisibility];
}
return self;
}
@@ -73,6 +83,32 @@ static CGFloat const kKBChatActionRowHeight = 52.0;
}];
}
- (void)setShowsReportAction:(BOOL)showsReportAction {
if (_showsReportAction == showsReportAction) {
return;
}
_showsReportAction = showsReportAction;
[self applyReportVisibility];
}
- (void)applyReportVisibility {
BOOL show = self.showsReportAction;
self.reportRow.hidden = !show;
self.reportRow.userInteractionEnabled = show;
self.line2.hidden = !show;
// frame
[self.line2 mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(show ? 0.5 : 0.0);
}];
[self.reportRow mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(show ? kKBChatActionRowHeight : 0.0);
}];
[self setNeedsLayout];
[self layoutIfNeeded];
}
- (UIControl *)buildRowWithTitle:(NSString *)title
iconName:(NSString *)iconName
action:(KBChatMessageActionType)action {