Files
keyboard/keyBoard/Class/AiTalk/V/KBVoiceInputBar.h
2026-01-29 17:56:53 +08:00

75 lines
1.7 KiB
Objective-C

//
// KBVoiceInputBar.h
// keyBoard
//
// Created by Kiro on 2026/1/26.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class KBVoiceInputBar;
/// 语音输入栏代理
@protocol KBVoiceInputBarDelegate <NSObject>
@optional
/// 开始录音
- (void)voiceInputBarDidBeginRecording:(KBVoiceInputBar *)inputBar;
/// 结束录音
- (void)voiceInputBarDidEndRecording:(KBVoiceInputBar *)inputBar;
/// 取消录音
- (void)voiceInputBarDidCancelRecording:(KBVoiceInputBar *)inputBar;
@end
typedef NS_ENUM(NSInteger, KBVoiceInputBarMode) {
KBVoiceInputBarModeText,
KBVoiceInputBarModeVoice
};
typedef NS_ENUM(NSInteger, KBVoiceInputBarState) {
KBVoiceInputBarStateText,
KBVoiceInputBarStateVoice,
KBVoiceInputBarStateRecording,
KBVoiceInputBarStateCancel
};
/// 底部语音输入栏
/// 包含:毛玻璃背景 + 录音按钮
@interface KBVoiceInputBar : UIView
/// 代理
@property (nonatomic, weak) id<KBVoiceInputBarDelegate> delegate;
/// 文本发送回调(文本模式下发送消息时触发)
@property (nonatomic, copy) void (^onTextSend)(NSString *text);
/// 状态文本(显示在按钮上方)
@property (nonatomic, copy) NSString *statusText;
/// 输入模式(文字/语音)
@property (nonatomic, assign) KBVoiceInputBarMode inputMode;
/// 输入状态(文字/语音/录音/取消)
@property (nonatomic, assign) KBVoiceInputBarState inputState;
/// 是否启用(禁用时按钮不可点击)
@property (nonatomic, assign) BOOL enabled;
/// 更新音量(用于波形动画)
/// @param rms 音量 RMS 值 (0.0 - 1.0)
- (void)updateVolumeRMS:(float)rms;
/// 设置录音状态
/// @param recording 是否正在录音
- (void)setRecording:(BOOL)recording;
@end
NS_ASSUME_NONNULL_END