This commit is contained in:
2026-01-28 13:43:36 +08:00
parent 51b744ecd7
commit 7d583ceb1d
14 changed files with 152 additions and 36 deletions

View File

@@ -23,6 +23,7 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
@interface KBAICommentView () <UITableViewDataSource, UITableViewDelegate>
@property(nonatomic, strong) UIVisualEffectView *blurBackgroundView;
@property(nonatomic, strong) UIView *headerView;
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UIButton *closeButton;
@@ -68,11 +69,18 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
#pragma mark - UI Setup
- (void)setupUI {
self.backgroundColor = [UIColor whiteColor];
//
self.backgroundColor = [UIColor clearColor];
self.layer.cornerRadius = 12;
self.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
self.clipsToBounds = YES;
//
[self addSubview:self.blurBackgroundView];
[self.blurBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self addSubview:self.headerView];
[self.headerView addSubview:self.titleLabel];
[self.headerView addSubview:self.closeButton];
@@ -293,8 +301,8 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
__weak typeof(self) weakSelf = self;
header.onLikeAction = ^{
// TODO:
comment.isLiked = !comment.isLiked;
comment.likeCount += comment.isLiked ? 1 : -1;
comment.liked = !comment.liked;
comment.likeCount += comment.liked ? 1 : -1;
[weakSelf.tableView reloadSections:[NSIndexSet indexSetWithIndex:section]
withRowAnimation:UITableViewRowAnimationNone];
};
@@ -449,10 +457,29 @@ static NSInteger const kRepliesLoadCount = 5;
#pragma mark - Lazy Loading
- (UIVisualEffectView *)blurBackgroundView {
if (!_blurBackgroundView) {
// 43pt
// iOS UIBlurEffect API使 dark
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
_blurBackgroundView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
//
// #0000000.31
UIView *darkOverlay = [[UIView alloc] init];
darkOverlay.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.31];
[_blurBackgroundView.contentView addSubview:darkOverlay];
[darkOverlay mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(_blurBackgroundView);
}];
}
return _blurBackgroundView;
}
- (UIView *)headerView {
if (!_headerView) {
_headerView = [[UIView alloc] init];
_headerView.backgroundColor = [UIColor whiteColor];
_headerView.backgroundColor = [UIColor clearColor];
}
return _headerView;
}
@@ -461,7 +488,7 @@ static NSInteger const kRepliesLoadCount = 5;
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
_titleLabel.textColor = [UIColor labelColor];
_titleLabel.textColor = [UIColor whiteColor];
_titleLabel.text = @"0条评论";
}
return _titleLabel;
@@ -486,7 +513,7 @@ static NSInteger const kRepliesLoadCount = 5;
style:UITableViewStyleGrouped];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.backgroundColor = [UIColor whiteColor];
_tableView.backgroundColor = [UIColor clearColor];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;