fix(home): 修复按住说话功能,移除旧麦克风逻辑
This commit is contained in:
@@ -792,54 +792,43 @@ class _HomeScreenState extends State<HomeScreen>
|
|||||||
borderRadius: BorderRadius.circular(_inputRadius),
|
borderRadius: BorderRadius.circular(_inputRadius),
|
||||||
border: Border.all(color: AppColors.slate300),
|
border: Border.all(color: AppColors.slate300),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: _isRecording
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
? _buildListeningIndicator()
|
||||||
children: [
|
: _isTranscribing
|
||||||
Expanded(
|
? _buildTranscribingIndicator()
|
||||||
child: _isRecording
|
: TextField(
|
||||||
? _buildListeningIndicator()
|
controller: _messageController,
|
||||||
: _isTranscribing
|
minLines: 1,
|
||||||
? _buildTranscribingIndicator()
|
maxLines: 3,
|
||||||
: TextField(
|
decoration: const InputDecoration(
|
||||||
controller: _messageController,
|
hintText: '输入消息...',
|
||||||
minLines: 1,
|
border: InputBorder.none,
|
||||||
maxLines: 3,
|
enabledBorder: InputBorder.none,
|
||||||
decoration: const InputDecoration(
|
focusedBorder: InputBorder.none,
|
||||||
hintText: '输入消息...',
|
disabledBorder: InputBorder.none,
|
||||||
border: InputBorder.none,
|
errorBorder: InputBorder.none,
|
||||||
enabledBorder: InputBorder.none,
|
focusedErrorBorder: InputBorder.none,
|
||||||
focusedBorder: InputBorder.none,
|
isDense: true,
|
||||||
disabledBorder: InputBorder.none,
|
contentPadding: EdgeInsets.zero,
|
||||||
errorBorder: InputBorder.none,
|
filled: false,
|
||||||
focusedErrorBorder: InputBorder.none,
|
),
|
||||||
isDense: true,
|
onSubmitted: (_) => _sendMessage(context),
|
||||||
contentPadding: EdgeInsets.zero,
|
),
|
||||||
filled: false,
|
|
||||||
),
|
|
||||||
onSubmitted: (_) => _sendMessage(context),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
_buildInputActionIcon(state),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildInputActionIcon(ChatState state) {
|
Widget _buildRightActionButton(ChatState state) {
|
||||||
final isWaitingAgent =
|
final isWaitingAgent =
|
||||||
state.isWaitingFirstToken || state.isStreaming || state.isCancelling;
|
state.isWaitingFirstToken || state.isStreaming || state.isCancelling;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
key: _inputActionButtonKey,
|
key: _inputActionButtonKey,
|
||||||
onTap: _isTranscribing
|
onTap: _isTranscribing
|
||||||
? null
|
? null
|
||||||
: _isRecording
|
|
||||||
? () => _stopRecording(autoSendAfterTranscribe: true)
|
|
||||||
: isWaitingAgent
|
: isWaitingAgent
|
||||||
? () => _onStopGenerating(context)
|
? () => _onStopGenerating(context)
|
||||||
: _hasMessage
|
: _hasMessage
|
||||||
? () => _sendMessage(context)
|
? () => _sendMessage(context)
|
||||||
: _startRecording,
|
: _toggleHoldToSpeakMode,
|
||||||
child: _isTranscribing
|
child: _isTranscribing
|
||||||
? const SizedBox(
|
? const SizedBox(
|
||||||
width: _transcribingSpinnerSize,
|
width: _transcribingSpinnerSize,
|
||||||
@@ -853,43 +842,19 @@ class _HomeScreenState extends State<HomeScreen>
|
|||||||
key: _inputActionIconKey,
|
key: _inputActionIconKey,
|
||||||
isWaitingAgent
|
isWaitingAgent
|
||||||
? LucideIcons.square
|
? LucideIcons.square
|
||||||
: _isRecording || _hasMessage
|
: _hasMessage
|
||||||
? LucideIcons.send
|
? LucideIcons.send
|
||||||
: LucideIcons.mic,
|
: _isHoldToSpeakMode
|
||||||
|
? LucideIcons.keyboard
|
||||||
|
: LucideIcons.activity,
|
||||||
size: _iconSize,
|
size: _iconSize,
|
||||||
color: isWaitingAgent || _isRecording || _hasMessage
|
color: isWaitingAgent || _hasMessage
|
||||||
? AppColors.blue600
|
? AppColors.blue600
|
||||||
: AppColors.slate500,
|
: AppColors.slate500,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildRightActionButton(ChatState state) {
|
|
||||||
return GestureDetector(
|
|
||||||
key: _inputActionButtonKey,
|
|
||||||
onTap: _isTranscribing
|
|
||||||
? null
|
|
||||||
: _isHoldToSpeakMode
|
|
||||||
? _toggleHoldToSpeakMode
|
|
||||||
: _startRecording,
|
|
||||||
child: _isTranscribing
|
|
||||||
? const SizedBox(
|
|
||||||
width: _transcribingSpinnerSize,
|
|
||||||
height: _transcribingSpinnerSize,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
strokeWidth: _transcribingStrokeWidth,
|
|
||||||
color: AppColors.blue600,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Icon(
|
|
||||||
key: _inputActionIconKey,
|
|
||||||
_isHoldToSpeakMode ? LucideIcons.keyboard : LucideIcons.activity,
|
|
||||||
size: _iconSize,
|
|
||||||
color: AppColors.slate500,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildHoldToSpeakHint() {
|
Widget _buildHoldToSpeakHint() {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
Reference in New Issue
Block a user