fix(home): 修复按住说话功能,移除旧麦克风逻辑
This commit is contained in:
@@ -792,10 +792,6 @@ 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(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: _isRecording
|
child: _isRecording
|
||||||
? _buildListeningIndicator()
|
? _buildListeningIndicator()
|
||||||
: _isTranscribing
|
: _isTranscribing
|
||||||
@@ -818,28 +814,21 @@ class _HomeScreenState extends State<HomeScreen>
|
|||||||
),
|
),
|
||||||
onSubmitted: (_) => _sendMessage(context),
|
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