优化长按聊天记录 如果是自己 不要显示举报
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user