This commit is contained in:
2026-01-28 13:55:11 +08:00
parent 7d583ceb1d
commit d8d5bdc3ae
4 changed files with 110 additions and 13 deletions

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "comment_close_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "comment_close_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -99,7 +99,7 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.headerView).offset(-16);
make.centerY.equalTo(self.headerView);
make.width.height.mas_equalTo(30);
make.width.height.mas_equalTo(25);
}];
[self.inputView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -274,11 +274,49 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
__weak typeof(self) weakSelf = self;
cell.onLikeAction = ^{
// TODO:
reply.isLiked = !reply.isLiked;
reply.likeCount += reply.isLiked ? 1 : -1;
[weakSelf.tableView reloadRowsAtIndexPaths:@[ indexPath ]
withRowAnimation:UITableViewRowAnimationNone];
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
// ID NSInteger
NSInteger commentId = [reply.replyId integerValue];
//
[strongSelf.aiVM likeCommentWithCommentId:commentId completion:^(KBCommentLikeResponse * _Nullable response, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error) {
NSLog(@"[KBAICommentView] 二级评论点赞失败:%@", error.localizedDescription);
// TODO:
return;
}
if (response && response.code == 0) {
// data = true: data = false:
BOOL isNowLiked = response.data;
//
if (isNowLiked) {
// +1
reply.isLiked = YES;
reply.likeCount = MAX(0, reply.likeCount + 1);
NSLog(@"[KBAICommentView] 二级评论点赞成功ID: %ld", (long)commentId);
} else {
// -1
reply.isLiked = NO;
reply.likeCount = MAX(0, reply.likeCount - 1);
NSLog(@"[KBAICommentView] 二级评论取消点赞成功ID: %ld", (long)commentId);
}
//
[strongSelf.tableView reloadRowsAtIndexPaths:@[ indexPath ]
withRowAnimation:UITableViewRowAnimationNone];
} else {
NSLog(@"[KBAICommentView] 二级评论点赞失败:%@", response.message ?: @"未知错误");
// TODO:
}
});
}];
};
cell.onReplyAction = ^{
@@ -300,11 +338,49 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
__weak typeof(self) weakSelf = self;
header.onLikeAction = ^{
// TODO:
comment.liked = !comment.liked;
comment.likeCount += comment.liked ? 1 : -1;
[weakSelf.tableView reloadSections:[NSIndexSet indexSetWithIndex:section]
withRowAnimation:UITableViewRowAnimationNone];
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
// ID NSInteger
NSInteger commentId = [comment.commentId integerValue];
//
[strongSelf.aiVM likeCommentWithCommentId:commentId completion:^(KBCommentLikeResponse * _Nullable response, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error) {
NSLog(@"[KBAICommentView] 一级评论点赞失败:%@", error.localizedDescription);
// TODO:
return;
}
if (response && response.code == 0) {
// data = true: data = false:
BOOL isNowLiked = response.data;
//
if (isNowLiked) {
// +1
comment.liked = YES;
comment.likeCount = MAX(0, comment.likeCount + 1);
NSLog(@"[KBAICommentView] 一级评论点赞成功ID: %ld", (long)commentId);
} else {
// -1
comment.liked = NO;
comment.likeCount = MAX(0, comment.likeCount - 1);
NSLog(@"[KBAICommentView] 一级评论取消点赞成功ID: %ld", (long)commentId);
}
// section
[strongSelf.tableView reloadSections:[NSIndexSet indexSetWithIndex:section]
withRowAnimation:UITableViewRowAnimationNone];
} else {
NSLog(@"[KBAICommentView] 一级评论点赞失败:%@", response.message ?: @"未知错误");
// TODO:
}
});
}];
};
header.onReplyAction = ^{
@@ -497,9 +573,8 @@ static NSInteger const kRepliesLoadCount = 5;
- (UIButton *)closeButton {
if (!_closeButton) {
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_closeButton setImage:[UIImage systemImageNamed:@"xmark"]
[_closeButton setImage:[UIImage imageNamed:@"comment_close_icon"]
forState:UIControlStateNormal];
_closeButton.tintColor = [UIColor labelColor];
[_closeButton addTarget:self
action:@selector(closeButtonTapped)
forControlEvents:UIControlEventTouchUpInside];