1
This commit is contained in:
22
keyBoard/Assets.xcassets/AI/comment_close_icon.imageset/Contents.json
vendored
Normal file
22
keyBoard/Assets.xcassets/AI/comment_close_icon.imageset/Contents.json
vendored
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
keyBoard/Assets.xcassets/AI/comment_close_icon.imageset/comment_close_icon@2x.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/AI/comment_close_icon.imageset/comment_close_icon@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
keyBoard/Assets.xcassets/AI/comment_close_icon.imageset/comment_close_icon@3x.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/AI/comment_close_icon.imageset/comment_close_icon@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
@@ -99,7 +99,7 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
|
|||||||
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.right.equalTo(self.headerView).offset(-16);
|
make.right.equalTo(self.headerView).offset(-16);
|
||||||
make.centerY.equalTo(self.headerView);
|
make.centerY.equalTo(self.headerView);
|
||||||
make.width.height.mas_equalTo(30);
|
make.width.height.mas_equalTo(25);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self.inputView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.inputView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
@@ -274,11 +274,49 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
|
|||||||
|
|
||||||
__weak typeof(self) weakSelf = self;
|
__weak typeof(self) weakSelf = self;
|
||||||
cell.onLikeAction = ^{
|
cell.onLikeAction = ^{
|
||||||
// TODO: 处理点赞逻辑
|
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||||
reply.isLiked = !reply.isLiked;
|
if (!strongSelf) {
|
||||||
reply.likeCount += reply.isLiked ? 1 : -1;
|
return;
|
||||||
[weakSelf.tableView reloadRowsAtIndexPaths:@[ indexPath ]
|
}
|
||||||
|
|
||||||
|
// 获取评论 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];
|
withRowAnimation:UITableViewRowAnimationNone];
|
||||||
|
} else {
|
||||||
|
NSLog(@"[KBAICommentView] 二级评论点赞失败:%@", response.message ?: @"未知错误");
|
||||||
|
// TODO: 显示错误提示
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}];
|
||||||
};
|
};
|
||||||
|
|
||||||
cell.onReplyAction = ^{
|
cell.onReplyAction = ^{
|
||||||
@@ -300,11 +338,49 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
|
|||||||
|
|
||||||
__weak typeof(self) weakSelf = self;
|
__weak typeof(self) weakSelf = self;
|
||||||
header.onLikeAction = ^{
|
header.onLikeAction = ^{
|
||||||
// TODO: 处理点赞逻辑
|
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||||
comment.liked = !comment.liked;
|
if (!strongSelf) {
|
||||||
comment.likeCount += comment.liked ? 1 : -1;
|
return;
|
||||||
[weakSelf.tableView reloadSections:[NSIndexSet indexSetWithIndex:section]
|
}
|
||||||
|
|
||||||
|
// 获取评论 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];
|
withRowAnimation:UITableViewRowAnimationNone];
|
||||||
|
} else {
|
||||||
|
NSLog(@"[KBAICommentView] 一级评论点赞失败:%@", response.message ?: @"未知错误");
|
||||||
|
// TODO: 显示错误提示
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}];
|
||||||
};
|
};
|
||||||
|
|
||||||
header.onReplyAction = ^{
|
header.onReplyAction = ^{
|
||||||
@@ -497,9 +573,8 @@ static NSInteger const kRepliesLoadCount = 5;
|
|||||||
- (UIButton *)closeButton {
|
- (UIButton *)closeButton {
|
||||||
if (!_closeButton) {
|
if (!_closeButton) {
|
||||||
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||||
[_closeButton setImage:[UIImage systemImageNamed:@"xmark"]
|
[_closeButton setImage:[UIImage imageNamed:@"comment_close_icon"]
|
||||||
forState:UIControlStateNormal];
|
forState:UIControlStateNormal];
|
||||||
_closeButton.tintColor = [UIColor labelColor];
|
|
||||||
[_closeButton addTarget:self
|
[_closeButton addTarget:self
|
||||||
action:@selector(closeButtonTapped)
|
action:@selector(closeButtonTapped)
|
||||||
forControlEvents:UIControlEventTouchUpInside];
|
forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
|||||||
Reference in New Issue
Block a user