1
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#import "KBAiChatMessage.h"
|
||||
#import "KBChatHistoryPageModel.h"
|
||||
#import "AiVM.h"
|
||||
#import "KBImagePositionButton.h"
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
|
||||
@@ -48,6 +49,12 @@
|
||||
/// AiVM 实例
|
||||
@property (nonatomic, strong) AiVM *aiVM;
|
||||
|
||||
/// 评论按钮
|
||||
@property (nonatomic, strong) KBImagePositionButton *commentButton;
|
||||
|
||||
/// 喜欢按钮
|
||||
@property (nonatomic, strong) KBImagePositionButton *likeButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation KBPersonaChatCell
|
||||
@@ -113,6 +120,24 @@
|
||||
make.centerY.equalTo(self.avatarImageView);
|
||||
}];
|
||||
|
||||
// 评论按钮(最右侧)
|
||||
[self.contentView addSubview:self.commentButton];
|
||||
[self.commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.contentView).offset(-20);
|
||||
make.centerY.equalTo(self.avatarImageView);
|
||||
make.width.mas_equalTo(40);
|
||||
make.height.mas_equalTo(50);
|
||||
}];
|
||||
|
||||
// 喜欢按钮(评论按钮左侧,间距20px)
|
||||
[self.contentView addSubview:self.likeButton];
|
||||
[self.likeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.commentButton.mas_left).offset(-20);
|
||||
make.centerY.equalTo(self.avatarImageView);
|
||||
make.width.mas_equalTo(40);
|
||||
make.height.mas_equalTo(50);
|
||||
}];
|
||||
|
||||
// 聊天列表
|
||||
[self.contentView addSubview:self.chatView];
|
||||
[self.chatView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -147,6 +172,10 @@
|
||||
// 关键修复:清空消息时停止音频播放,避免状态混乱
|
||||
[self.chatView stopPlayingAudio];
|
||||
[self.chatView clearMessages];
|
||||
[self.commentButton setTitle:persona.commentCount forState:UIControlStateNormal];
|
||||
[self.likeButton setTitle:persona.likeCount forState:UIControlStateNormal];
|
||||
self.likeButton.selected = persona.liked;
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 2:数据加载
|
||||
@@ -350,7 +379,7 @@
|
||||
- (UILabel *)nameLabel {
|
||||
if (!_nameLabel) {
|
||||
_nameLabel = [[UILabel alloc] init];
|
||||
_nameLabel.font = [UIFont boldSystemFontOfSize:20];
|
||||
_nameLabel.font = [UIFont boldSystemFontOfSize:12];
|
||||
_nameLabel.textColor = [UIColor whiteColor];
|
||||
_nameLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
@@ -377,4 +406,63 @@
|
||||
return _chatView;
|
||||
}
|
||||
|
||||
- (KBImagePositionButton *)commentButton {
|
||||
if (!_commentButton) {
|
||||
// 创建上图下文的按钮
|
||||
_commentButton = [[KBImagePositionButton alloc] initWithImagePosition:KBImagePositionTop spacing:4];
|
||||
|
||||
// 关键修复:先设置字体,再设置文字,避免循环调用
|
||||
_commentButton.titleLabel.font = [UIFont systemFontOfSize:10];
|
||||
|
||||
// 设置图片
|
||||
[_commentButton setImage:[UIImage imageNamed:@"ai_comment_icon"] forState:UIControlStateNormal];
|
||||
|
||||
// 设置文字
|
||||
[_commentButton setTitle:@"0" forState:UIControlStateNormal];
|
||||
[_commentButton setTitleColor:[[UIColor whiteColor] colorWithAlphaComponent:0.8] forState:UIControlStateNormal];
|
||||
|
||||
// 添加点击事件
|
||||
[_commentButton addTarget:self action:@selector(commentButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _commentButton;
|
||||
}
|
||||
|
||||
- (KBImagePositionButton *)likeButton {
|
||||
if (!_likeButton) {
|
||||
// 创建上图下文的按钮
|
||||
_likeButton = [[KBImagePositionButton alloc] initWithImagePosition:KBImagePositionTop spacing:4];
|
||||
|
||||
// 关键修复:先设置字体,再设置文字,避免循环调用
|
||||
_likeButton.titleLabel.font = [UIFont systemFontOfSize:10];
|
||||
|
||||
// 设置图片
|
||||
[_likeButton setImage:[UIImage imageNamed:@"ai_live_icon"] forState:UIControlStateNormal];
|
||||
[_likeButton setImage:[UIImage imageNamed:@"ai_livesel_icon"] forState:UIControlStateSelected];
|
||||
|
||||
// 设置文字
|
||||
[_likeButton setTitle:@"0" forState:UIControlStateNormal];
|
||||
[_likeButton setTitleColor:[[UIColor whiteColor] colorWithAlphaComponent:0.8] forState:UIControlStateNormal];
|
||||
|
||||
// 添加点击事件
|
||||
[_likeButton addTarget:self action:@selector(likeButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _likeButton;
|
||||
}
|
||||
|
||||
#pragma mark - Button Actions
|
||||
|
||||
- (void)commentButtonTapped:(KBImagePositionButton *)sender {
|
||||
sender.selected = !sender.selected;
|
||||
NSLog(@"[KBPersonaChatCell] 评论按钮点击,选中状态:%d", sender.selected);
|
||||
|
||||
// TODO: 在这里添加评论逻辑
|
||||
}
|
||||
|
||||
- (void)likeButtonTapped:(KBImagePositionButton *)sender {
|
||||
sender.selected = !sender.selected;
|
||||
NSLog(@"[KBPersonaChatCell] 喜欢按钮点击,选中状态:%d", sender.selected);
|
||||
|
||||
// TODO: 在这里添加喜欢逻辑
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user