From 5e8d615f3bb37c63be80501b9b7bb2d695d46c98 Mon Sep 17 00:00:00 2001 From: qzl Date: Thu, 12 Mar 2026 13:55:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(home):=20=E4=BF=AE=E5=A4=8D=E6=8C=89?= =?UTF-8?q?=E4=BD=8F=E8=AF=B4=E8=AF=9D=E5=8A=9F=E8=83=BD=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=97=A7=E9=BA=A6=E5=85=8B=E9=A3=8E=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/home/ui/screens/home_screen.dart | 93 ++++++------------- 1 file changed, 29 insertions(+), 64 deletions(-) diff --git a/apps/lib/features/home/ui/screens/home_screen.dart b/apps/lib/features/home/ui/screens/home_screen.dart index b36c753..a4699be 100644 --- a/apps/lib/features/home/ui/screens/home_screen.dart +++ b/apps/lib/features/home/ui/screens/home_screen.dart @@ -792,54 +792,43 @@ class _HomeScreenState extends State borderRadius: BorderRadius.circular(_inputRadius), border: Border.all(color: AppColors.slate300), ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: _isRecording - ? _buildListeningIndicator() - : _isTranscribing - ? _buildTranscribingIndicator() - : TextField( - controller: _messageController, - minLines: 1, - maxLines: 3, - decoration: const InputDecoration( - hintText: '输入消息...', - border: InputBorder.none, - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - disabledBorder: InputBorder.none, - errorBorder: InputBorder.none, - focusedErrorBorder: InputBorder.none, - isDense: true, - contentPadding: EdgeInsets.zero, - filled: false, - ), - onSubmitted: (_) => _sendMessage(context), - ), - ), - const SizedBox(width: 8), - _buildInputActionIcon(state), - ], - ), + child: _isRecording + ? _buildListeningIndicator() + : _isTranscribing + ? _buildTranscribingIndicator() + : TextField( + controller: _messageController, + minLines: 1, + maxLines: 3, + decoration: const InputDecoration( + hintText: '输入消息...', + border: InputBorder.none, + enabledBorder: InputBorder.none, + focusedBorder: InputBorder.none, + disabledBorder: InputBorder.none, + errorBorder: InputBorder.none, + focusedErrorBorder: InputBorder.none, + isDense: true, + contentPadding: EdgeInsets.zero, + filled: false, + ), + onSubmitted: (_) => _sendMessage(context), + ), ); } - Widget _buildInputActionIcon(ChatState state) { + Widget _buildRightActionButton(ChatState state) { final isWaitingAgent = state.isWaitingFirstToken || state.isStreaming || state.isCancelling; return GestureDetector( key: _inputActionButtonKey, onTap: _isTranscribing ? null - : _isRecording - ? () => _stopRecording(autoSendAfterTranscribe: true) : isWaitingAgent ? () => _onStopGenerating(context) : _hasMessage ? () => _sendMessage(context) - : _startRecording, + : _toggleHoldToSpeakMode, child: _isTranscribing ? const SizedBox( width: _transcribingSpinnerSize, @@ -853,43 +842,19 @@ class _HomeScreenState extends State key: _inputActionIconKey, isWaitingAgent ? LucideIcons.square - : _isRecording || _hasMessage + : _hasMessage ? LucideIcons.send - : LucideIcons.mic, + : _isHoldToSpeakMode + ? LucideIcons.keyboard + : LucideIcons.activity, size: _iconSize, - color: isWaitingAgent || _isRecording || _hasMessage + color: isWaitingAgent || _hasMessage ? AppColors.blue600 : 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() { return Column( children: [