From 542a61deeecb923c3136a1d3bb0e86220dad6c94 Mon Sep 17 00:00:00 2001 From: cogwheel0 <172976095+cogwheel0@users.noreply.github.com> Date: Fri, 5 Sep 2025 12:47:31 +0530 Subject: [PATCH] refactor: message sending ux --- .../widgets/assistant_message_widget.dart | 36 ++++++++----------- .../chat/widgets/modern_chat_input.dart | 10 +++--- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/lib/features/chat/widgets/assistant_message_widget.dart b/lib/features/chat/widgets/assistant_message_widget.dart index 82ce420..a6344bf 100644 --- a/lib/features/chat/widgets/assistant_message_widget.dart +++ b/lib/features/chat/widgets/assistant_message_widget.dart @@ -825,21 +825,12 @@ class _AssistantMessageWidgetState extends ConsumerState children: [ // Increase spacing between assistant name and typing indicator const SizedBox(height: Spacing.md), - // Give the dots breathing room to avoid any clip from transitions + // Give the indicator breathing room to avoid any clip from transitions Padding( padding: const EdgeInsets.only(left: 4, bottom: 4), child: SizedBox( height: 14, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - _buildTypingDot(0), - const SizedBox(width: Spacing.xs), - _buildTypingDot(200), - const SizedBox(width: Spacing.xs), - _buildTypingDot(400), - ], - ), + child: _buildTypingDot(), ), ), ], @@ -848,26 +839,29 @@ class _AssistantMessageWidgetState extends ConsumerState ); } - Widget _buildTypingDot(int delay) { + Widget _buildTypingDot() { + final min = AnimationValues.typingIndicatorScale; return Container( width: 10, height: 10, decoration: BoxDecoration( color: context.conduitTheme.textSecondary.withValues(alpha: 0.6), - borderRadius: BorderRadius.circular(AppBorderRadius.xs), + shape: BoxShape.circle, ), ) .animate(onPlay: (controller) => controller.repeat()) .scale( - duration: const Duration(milliseconds: 1000), - begin: const Offset(1, 1), - end: const Offset(1.25, 1.25), - ) - .then(delay: Duration(milliseconds: delay)) - .scale( - duration: const Duration(milliseconds: 1000), - begin: const Offset(1.25, 1.25), + duration: AnimationDuration.typingIndicator, + curve: AnimationCurves.typingIndicator, + begin: Offset(min, min), end: const Offset(1, 1), + ) + .then(delay: AnimationDelay.typingDelay) + .scale( + duration: AnimationDuration.typingIndicator, + curve: AnimationCurves.typingIndicator, + begin: const Offset(1, 1), + end: Offset(min, min), ); } diff --git a/lib/features/chat/widgets/modern_chat_input.dart b/lib/features/chat/widgets/modern_chat_input.dart index d6782e1..f5ff7de 100644 --- a/lib/features/chat/widgets/modern_chat_input.dart +++ b/lib/features/chat/widgets/modern_chat_input.dart @@ -323,10 +323,12 @@ class _ModernChatInputState extends ConsumerState PlatformUtils.lightHaptic(); widget.onSendMessage(text); _controller.clear(); - // Keep tools and web search enabled for the conversation - // Keep input expanded and focused for better UX - don't dismiss keyboard - // KeyboardUtils.dismissKeyboard(context); - // _setExpanded(false); + // After sending, dismiss keyboard and collapse input + if (_focusNode.hasFocus) { + _focusNode.unfocus(); + } + // Ensure UI reflects empty state and collapses + _setExpanded(false); } void _setExpanded(bool expanded) {