处理语音

This commit is contained in:
2026-01-29 20:56:24 +08:00
parent 23c0d14128
commit 36135313d8
8 changed files with 236 additions and 9 deletions

View File

@@ -16,6 +16,7 @@
@property (nonatomic, strong) UIView *bubbleView;
@property (nonatomic, strong, readwrite) UILabel *messageLabel; // readwrite
@property (nonatomic, strong) UIActivityIndicatorView *loadingIndicator;
@property (nonatomic, strong) UIActivityIndicatorView *messageLoadingIndicator; // AI
@property (nonatomic, strong) KBAiChatMessage *currentMessage;
//
@@ -61,6 +62,12 @@
self.loadingIndicator.hidesWhenStopped = YES;
[self.contentView addSubview:self.loadingIndicator];
// AI AI
self.messageLoadingIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleMedium];
self.messageLoadingIndicator.color = [UIColor whiteColor];
self.messageLoadingIndicator.hidesWhenStopped = YES;
[self.contentView addSubview:self.messageLoadingIndicator];
//
self.bubbleView = [[UIView alloc] init];
self.bubbleView.backgroundColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:0.7];
@@ -83,8 +90,7 @@
[self.voiceButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(16);
make.top.equalTo(self.contentView).offset(8);
// make.width.height.mas_equalTo(24);
make.width.height.mas_equalTo(0);
make.width.height.mas_equalTo(24);
}];
[self.durationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -96,6 +102,12 @@
make.center.equalTo(self.voiceButton);
}];
// AI bubbleView
[self.messageLoadingIndicator mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(16);
make.top.equalTo(self.voiceButton.mas_bottom).offset(12);
}];
// bubbleView
[self.bubbleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.voiceButton.mas_bottom).offset(4);
@@ -116,8 +128,8 @@
}
- (void)configureWithMessage:(KBAiChatMessage *)message {
NSLog(@"[KBChatAssistantMessageCell] 配置消息 - 文本长度: %lu, isComplete: %d, needsTypewriter: %d, 打字机运行中: %d",
(unsigned long)message.text.length, message.isComplete, message.needsTypewriterEffect,
NSLog(@"[KBChatAssistantMessageCell] 配置消息 - 文本长度: %lu, isComplete: %d, needsTypewriter: %d, isLoading: %d, 打字机运行中: %d",
(unsigned long)message.text.length, message.isComplete, message.needsTypewriterEffect, message.isLoading,
(self.typewriterTimer && self.typewriterTimer.isValid));
//
@@ -125,6 +137,21 @@
self.currentMessage = message;
// loading
if (message.isLoading) {
self.messageLabel.attributedText = nil;
self.messageLabel.text = @"";
self.bubbleView.hidden = YES;
self.voiceButton.hidden = YES;
self.durationLabel.hidden = YES;
[self.messageLoadingIndicator startAnimating];
return;
}
// loading loading
[self.messageLoadingIndicator stopAnimating];
self.bubbleView.hidden = NO;
// 使
if (message.needsTypewriterEffect && !message.isComplete && message.text.length > 0) {
//