2026-01-15 18:16:56 +08:00
|
|
|
|
//
|
|
|
|
|
|
// KBChatPanelView.m
|
|
|
|
|
|
// CustomKeyboard
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#import "KBChatPanelView.h"
|
|
|
|
|
|
#import "KBChatMessage.h"
|
2026-01-30 13:17:11 +08:00
|
|
|
|
#import "KBChatUserCell.h"
|
|
|
|
|
|
#import "KBChatAssistantCell.h"
|
2026-01-15 18:16:56 +08:00
|
|
|
|
#import "Masonry.h"
|
|
|
|
|
|
|
2026-01-30 13:17:11 +08:00
|
|
|
|
static NSString * const kUserCellIdentifier = @"KBChatUserCell";
|
|
|
|
|
|
static NSString * const kAssistantCellIdentifier = @"KBChatAssistantCell";
|
|
|
|
|
|
static const NSUInteger kKBChatMessageLimit = 10;
|
|
|
|
|
|
|
|
|
|
|
|
@interface KBChatPanelView () <UITableViewDataSource, UITableViewDelegate, KBChatAssistantCellDelegate>
|
2026-01-15 18:49:31 +08:00
|
|
|
|
@property (nonatomic, strong) UIView *headerView;
|
|
|
|
|
|
@property (nonatomic, strong) UILabel *titleLabel;
|
|
|
|
|
|
@property (nonatomic, strong) UIButton *closeButton;
|
2026-01-15 18:16:56 +08:00
|
|
|
|
@property (nonatomic, strong) UITableView *tableViewInternal;
|
2026-01-30 13:17:11 +08:00
|
|
|
|
@property (nonatomic, strong) NSMutableArray<KBChatMessage *> *messages;
|
2026-01-15 18:16:56 +08:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation KBChatPanelView
|
|
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
|
|
|
if (self = [super initWithFrame:frame]) {
|
2026-01-15 18:49:31 +08:00
|
|
|
|
self.backgroundColor = [UIColor clearColor];
|
2026-01-30 13:17:11 +08:00
|
|
|
|
self.messages = [NSMutableArray array];
|
2026-01-15 18:16:56 +08:00
|
|
|
|
|
2026-01-15 18:49:31 +08:00
|
|
|
|
[self addSubview:self.headerView];
|
2026-01-15 18:16:56 +08:00
|
|
|
|
[self addSubview:self.tableViewInternal];
|
|
|
|
|
|
|
2026-01-15 18:49:31 +08:00
|
|
|
|
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.left.right.equalTo(self);
|
|
|
|
|
|
make.top.equalTo(self.mas_top);
|
|
|
|
|
|
make.height.mas_equalTo(KBFit(36.0f));
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
2026-01-15 18:16:56 +08:00
|
|
|
|
[self.tableViewInternal mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.left.right.equalTo(self);
|
2026-01-15 18:49:31 +08:00
|
|
|
|
make.top.equalTo(self.headerView.mas_bottom).offset(4);
|
2026-01-15 18:16:56 +08:00
|
|
|
|
make.bottom.equalTo(self.mas_bottom).offset(-8);
|
|
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
return self;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Public
|
|
|
|
|
|
|
|
|
|
|
|
- (void)kb_reloadWithMessages:(NSArray<KBChatMessage *> *)messages {
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] ⚠️ kb_reloadWithMessages 被调用,传入 %lu 条消息", (unsigned long)messages.count);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
|
|
|
|
|
|
[self.messages removeAllObjects];
|
|
|
|
|
|
if (messages.count > 0) {
|
|
|
|
|
|
[self.messages addObjectsFromArray:messages];
|
|
|
|
|
|
}
|
2026-01-15 18:16:56 +08:00
|
|
|
|
[self.tableViewInternal reloadData];
|
2026-01-30 13:17:11 +08:00
|
|
|
|
[self kb_scrollToBottom];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)kb_addUserMessage:(NSString *)text {
|
|
|
|
|
|
if (text.length == 0) return;
|
|
|
|
|
|
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] 添加用户消息: %@,当前消息数: %lu", text, (unsigned long)self.messages.count);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
|
|
|
|
|
|
KBChatMessage *msg = [KBChatMessage userMessageWithText:text];
|
|
|
|
|
|
[self kb_appendMessage:msg];
|
|
|
|
|
|
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] 添加后消息数: %lu", (unsigned long)self.messages.count);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)kb_addLoadingAssistantMessage {
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] 添加 loading 消息,当前消息数: %lu", (unsigned long)self.messages.count);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
|
|
|
|
|
|
KBChatMessage *msg = [KBChatMessage loadingAssistantMessage];
|
|
|
|
|
|
[self kb_appendMessage:msg];
|
|
|
|
|
|
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] 添加后消息数: %lu", (unsigned long)self.messages.count);
|
2026-01-15 18:16:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-30 13:17:11 +08:00
|
|
|
|
- (void)kb_removeLoadingAssistantMessage {
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] 移除 loading 消息,当前消息数: %lu", (unsigned long)self.messages.count);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
|
|
|
|
|
|
for (NSInteger i = self.messages.count - 1; i >= 0; i--) {
|
|
|
|
|
|
KBChatMessage *msg = self.messages[i];
|
|
|
|
|
|
// 只移除 AI 消息(outgoing == NO)且是 loading 状态的
|
|
|
|
|
|
if (!msg.outgoing && msg.isLoading) {
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] ✅ 找到 loading 消息,移除索引: %ld", (long)i);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
[self.messages removeObjectAtIndex:i];
|
2026-01-30 13:46:08 +08:00
|
|
|
|
|
|
|
|
|
|
// 使用 beginUpdates/endUpdates 包裹删除操作
|
|
|
|
|
|
[self.tableViewInternal beginUpdates];
|
2026-01-30 13:17:11 +08:00
|
|
|
|
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
|
|
|
|
|
|
[self.tableViewInternal deleteRowsAtIndexPaths:@[indexPath]
|
|
|
|
|
|
withRowAnimation:UITableViewRowAnimationNone];
|
2026-01-30 13:46:08 +08:00
|
|
|
|
[self.tableViewInternal endUpdates];
|
|
|
|
|
|
|
|
|
|
|
|
NSLog(@"[Panel] 移除后消息数: %lu", (unsigned long)self.messages.count);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)kb_addAssistantMessage:(NSString *)text audioId:(NSString *)audioId {
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] ========== kb_addAssistantMessage ==========");
|
|
|
|
|
|
NSLog(@"[Panel] 当前消息数: %lu", (unsigned long)self.messages.count);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
|
2026-01-30 13:46:08 +08:00
|
|
|
|
// 查找 loading 消息的索引
|
|
|
|
|
|
NSInteger loadingIndex = -1;
|
|
|
|
|
|
for (NSInteger i = self.messages.count - 1; i >= 0; i--) {
|
|
|
|
|
|
KBChatMessage *msg = self.messages[i];
|
|
|
|
|
|
if (!msg.outgoing && msg.isLoading) {
|
|
|
|
|
|
loadingIndex = i;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-01-30 13:17:11 +08:00
|
|
|
|
|
2026-01-30 13:46:08 +08:00
|
|
|
|
// 创建 AI 消息
|
2026-01-30 13:17:11 +08:00
|
|
|
|
KBChatMessage *msg = [KBChatMessage assistantMessageWithText:text audioId:audioId];
|
|
|
|
|
|
msg.displayName = KBLocalized(@"AI助手");
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] 创建 AI 消息,needsTypewriter: %d", msg.needsTypewriterEffect);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
|
2026-01-30 13:46:08 +08:00
|
|
|
|
// 使用批量更新,避免界面跳动
|
|
|
|
|
|
[self.tableViewInternal beginUpdates];
|
|
|
|
|
|
|
|
|
|
|
|
if (loadingIndex >= 0) {
|
|
|
|
|
|
// 移除 loading 消息
|
|
|
|
|
|
NSLog(@"[Panel] 移除 loading 索引: %ld", (long)loadingIndex);
|
|
|
|
|
|
[self.messages removeObjectAtIndex:loadingIndex];
|
|
|
|
|
|
NSIndexPath *deleteIndexPath = [NSIndexPath indexPathForRow:loadingIndex inSection:0];
|
|
|
|
|
|
[self.tableViewInternal deleteRowsAtIndexPaths:@[deleteIndexPath]
|
|
|
|
|
|
withRowAnimation:UITableViewRowAnimationNone];
|
2026-01-30 13:17:11 +08:00
|
|
|
|
}
|
2026-01-30 13:46:08 +08:00
|
|
|
|
|
|
|
|
|
|
// 添加 AI 消息
|
|
|
|
|
|
NSInteger insertIndex = self.messages.count;
|
|
|
|
|
|
[self.messages addObject:msg];
|
|
|
|
|
|
NSLog(@"[Panel] 插入 AI 消息索引: %ld", (long)insertIndex);
|
|
|
|
|
|
NSIndexPath *insertIndexPath = [NSIndexPath indexPathForRow:insertIndex inSection:0];
|
|
|
|
|
|
[self.tableViewInternal insertRowsAtIndexPaths:@[insertIndexPath]
|
|
|
|
|
|
withRowAnimation:UITableViewRowAnimationNone];
|
|
|
|
|
|
|
|
|
|
|
|
[self.tableViewInternal endUpdates];
|
|
|
|
|
|
|
|
|
|
|
|
// 滚动到底部
|
|
|
|
|
|
[self kb_scrollToBottom];
|
|
|
|
|
|
|
|
|
|
|
|
NSLog(@"[Panel] 添加后消息数: %lu", (unsigned long)self.messages.count);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)kb_updateLastAssistantMessageWithAudioData:(NSData *)audioData duration:(NSTimeInterval)duration {
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] 更新音频数据,duration: %.2f", duration);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
for (NSInteger i = self.messages.count - 1; i >= 0; i--) {
|
|
|
|
|
|
KBChatMessage *msg = self.messages[i];
|
|
|
|
|
|
// 只更新 AI 消息(outgoing == NO)且非 loading 状态的
|
|
|
|
|
|
if (!msg.outgoing && !msg.isLoading) {
|
|
|
|
|
|
msg.audioData = audioData;
|
|
|
|
|
|
msg.audioDuration = duration;
|
|
|
|
|
|
|
2026-01-30 13:46:08 +08:00
|
|
|
|
// 不刷新 Cell,避免打断打字机效果
|
|
|
|
|
|
if (duration > 0) {
|
|
|
|
|
|
msg.needsTypewriterEffect = NO;
|
|
|
|
|
|
msg.isComplete = YES;
|
2026-01-30 13:17:11 +08:00
|
|
|
|
}
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] ✅ 音频数据已更新");
|
2026-01-30 13:17:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)kb_scrollToBottom {
|
|
|
|
|
|
if (self.messages.count == 0) return;
|
|
|
|
|
|
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] 滚动到底部,消息数: %lu", (unsigned long)self.messages.count);
|
|
|
|
|
|
|
2026-01-30 13:17:11 +08:00
|
|
|
|
[self.tableViewInternal layoutIfNeeded];
|
|
|
|
|
|
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.messages.count - 1 inSection:0];
|
|
|
|
|
|
[self.tableViewInternal scrollToRowAtIndexPath:indexPath
|
|
|
|
|
|
atScrollPosition:UITableViewScrollPositionBottom
|
2026-01-30 13:46:08 +08:00
|
|
|
|
animated:NO]; // 改为 NO,避免动画导致跳动
|
2026-01-30 13:17:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Private
|
|
|
|
|
|
|
|
|
|
|
|
- (void)kb_appendMessage:(KBChatMessage *)message {
|
|
|
|
|
|
if (!message) return;
|
|
|
|
|
|
|
|
|
|
|
|
NSInteger oldCount = self.messages.count;
|
|
|
|
|
|
[self.messages addObject:message];
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] kb_appendMessage: oldCount=%ld, newCount=%lu", (long)oldCount, (unsigned long)self.messages.count);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
|
|
|
|
|
|
// 限制消息数量
|
|
|
|
|
|
if (self.messages.count > kKBChatMessageLimit) {
|
|
|
|
|
|
NSUInteger overflow = self.messages.count - kKBChatMessageLimit;
|
|
|
|
|
|
[self.messages removeObjectsInRange:NSMakeRange(0, overflow)];
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] 消息超限,reloadData");
|
2026-01-30 13:17:11 +08:00
|
|
|
|
[self.tableViewInternal reloadData];
|
|
|
|
|
|
} else {
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] 插入新行: %ld", (long)oldCount);
|
|
|
|
|
|
[self.tableViewInternal beginUpdates];
|
2026-01-30 13:17:11 +08:00
|
|
|
|
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:oldCount inSection:0];
|
|
|
|
|
|
[self.tableViewInternal insertRowsAtIndexPaths:@[indexPath]
|
|
|
|
|
|
withRowAnimation:UITableViewRowAnimationNone];
|
2026-01-30 13:46:08 +08:00
|
|
|
|
[self.tableViewInternal endUpdates];
|
2026-01-30 13:17:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-30 13:46:08 +08:00
|
|
|
|
// 直接滚动,不用 dispatch_async
|
|
|
|
|
|
[self kb_scrollToBottom];
|
2026-01-30 13:17:11 +08:00
|
|
|
|
}
|
2026-01-15 18:49:31 +08:00
|
|
|
|
|
|
|
|
|
|
#pragma mark - Actions
|
|
|
|
|
|
|
|
|
|
|
|
- (void)kb_onTapClose {
|
|
|
|
|
|
if ([self.delegate respondsToSelector:@selector(chatPanelViewDidTapClose:)]) {
|
|
|
|
|
|
[self.delegate chatPanelViewDidTapClose:self];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 18:16:56 +08:00
|
|
|
|
#pragma mark - UITableViewDataSource
|
|
|
|
|
|
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
|
|
|
return self.messages.count;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
2026-01-30 13:17:11 +08:00
|
|
|
|
if (indexPath.row >= self.messages.count) {
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] ❌ cellForRow 索引越界: %ld >= %lu", (long)indexPath.row, (unsigned long)self.messages.count);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
return [[UITableViewCell alloc] init];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 18:16:56 +08:00
|
|
|
|
KBChatMessage *msg = self.messages[indexPath.row];
|
2026-01-30 13:46:08 +08:00
|
|
|
|
NSLog(@"[Panel] cellForRow[%ld]: outgoing=%d, isLoading=%d", (long)indexPath.row, msg.outgoing, msg.isLoading);
|
2026-01-30 13:17:11 +08:00
|
|
|
|
|
|
|
|
|
|
if (msg.outgoing) {
|
|
|
|
|
|
// 用户消息(右侧)
|
|
|
|
|
|
KBChatUserCell *cell = [tableView dequeueReusableCellWithIdentifier:kUserCellIdentifier forIndexPath:indexPath];
|
|
|
|
|
|
[cell configureWithMessage:msg];
|
|
|
|
|
|
return cell;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// AI 消息(左侧)
|
|
|
|
|
|
KBChatAssistantCell *cell = [tableView dequeueReusableCellWithIdentifier:kAssistantCellIdentifier forIndexPath:indexPath];
|
|
|
|
|
|
cell.delegate = self;
|
|
|
|
|
|
[cell configureWithMessage:msg];
|
|
|
|
|
|
return cell;
|
|
|
|
|
|
}
|
2026-01-15 18:16:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - UITableViewDelegate
|
|
|
|
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
|
return UITableViewAutomaticDimension;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
2026-01-30 13:17:11 +08:00
|
|
|
|
return 60.0;
|
2026-01-15 18:16:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
|
if (indexPath.row >= self.messages.count) { return; }
|
|
|
|
|
|
KBChatMessage *msg = self.messages[indexPath.row];
|
|
|
|
|
|
if ([self.delegate respondsToSelector:@selector(chatPanelView:didTapMessage:)]) {
|
|
|
|
|
|
[self.delegate chatPanelView:self didTapMessage:msg];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-30 13:17:11 +08:00
|
|
|
|
#pragma mark - KBChatAssistantCellDelegate
|
|
|
|
|
|
|
|
|
|
|
|
- (void)assistantCell:(KBChatAssistantCell *)cell didTapVoiceButtonForMessage:(KBChatMessage *)message {
|
|
|
|
|
|
if ([self.delegate respondsToSelector:@selector(chatPanelView:didTapVoiceButtonForMessage:)]) {
|
|
|
|
|
|
[self.delegate chatPanelView:self didTapVoiceButtonForMessage:message];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 18:16:56 +08:00
|
|
|
|
#pragma mark - Lazy
|
|
|
|
|
|
|
|
|
|
|
|
- (UITableView *)tableViewInternal {
|
|
|
|
|
|
if (!_tableViewInternal) {
|
|
|
|
|
|
_tableViewInternal = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
|
|
|
|
|
_tableViewInternal.backgroundColor = [UIColor clearColor];
|
2026-01-15 18:49:31 +08:00
|
|
|
|
_tableViewInternal.backgroundView = nil;
|
2026-01-15 18:16:56 +08:00
|
|
|
|
_tableViewInternal.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
|
|
|
|
_tableViewInternal.dataSource = self;
|
|
|
|
|
|
_tableViewInternal.delegate = self;
|
2026-01-30 13:17:11 +08:00
|
|
|
|
_tableViewInternal.estimatedRowHeight = 60.0;
|
2026-01-15 18:16:56 +08:00
|
|
|
|
_tableViewInternal.rowHeight = UITableViewAutomaticDimension;
|
2026-01-30 13:17:11 +08:00
|
|
|
|
// 注册两种 Cell
|
|
|
|
|
|
[_tableViewInternal registerClass:KBChatUserCell.class forCellReuseIdentifier:kUserCellIdentifier];
|
|
|
|
|
|
[_tableViewInternal registerClass:KBChatAssistantCell.class forCellReuseIdentifier:kAssistantCellIdentifier];
|
|
|
|
|
|
if (@available(iOS 11.0, *)) {
|
|
|
|
|
|
_tableViewInternal.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
|
|
|
}
|
2026-01-15 18:16:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
return _tableViewInternal;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 18:49:31 +08:00
|
|
|
|
- (UIView *)headerView {
|
|
|
|
|
|
if (!_headerView) {
|
|
|
|
|
|
_headerView = [[UIView alloc] init];
|
|
|
|
|
|
_headerView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
|
[_headerView addSubview:self.titleLabel];
|
|
|
|
|
|
[_headerView addSubview:self.closeButton];
|
|
|
|
|
|
|
|
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.left.equalTo(_headerView.mas_left).offset(12);
|
|
|
|
|
|
make.centerY.equalTo(_headerView);
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.right.equalTo(_headerView.mas_right).offset(-12);
|
|
|
|
|
|
make.centerY.equalTo(_headerView);
|
|
|
|
|
|
make.width.height.mas_equalTo(KBFit(24.0f));
|
|
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
return _headerView;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UILabel *)titleLabel {
|
|
|
|
|
|
if (!_titleLabel) {
|
|
|
|
|
|
_titleLabel = [[UILabel alloc] init];
|
|
|
|
|
|
_titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
|
2026-01-15 19:14:34 +08:00
|
|
|
|
_titleLabel.textColor =
|
|
|
|
|
|
[UIColor kb_dynamicColorWithLightColor:[UIColor colorWithHex:0x1B1F1A]
|
|
|
|
|
|
darkColor:[UIColor whiteColor]];
|
2026-01-15 18:49:31 +08:00
|
|
|
|
_titleLabel.text = KBLocalized(@"AI对话");
|
|
|
|
|
|
}
|
|
|
|
|
|
return _titleLabel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UIButton *)closeButton {
|
|
|
|
|
|
if (!_closeButton) {
|
|
|
|
|
|
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
|
UIImage *icon = [UIImage imageNamed:@"close_icon"];
|
|
|
|
|
|
[_closeButton setImage:icon forState:UIControlStateNormal];
|
|
|
|
|
|
_closeButton.backgroundColor = [UIColor clearColor];
|
|
|
|
|
|
[_closeButton addTarget:self
|
|
|
|
|
|
action:@selector(kb_onTapClose)
|
|
|
|
|
|
forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
}
|
|
|
|
|
|
return _closeButton;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 18:16:56 +08:00
|
|
|
|
#pragma mark - Expose
|
|
|
|
|
|
|
|
|
|
|
|
- (UITableView *)tableView { return self.tableViewInternal; }
|
|
|
|
|
|
|
|
|
|
|
|
@end
|