diff --git a/lib/modules/agent/views/agent_view.dart b/lib/modules/agent/views/agent_view.dart index cca44635e..c0abce98c 100644 --- a/lib/modules/agent/views/agent_view.dart +++ b/lib/modules/agent/views/agent_view.dart @@ -190,535 +190,568 @@ class _AgentViewState extends State with WidgetsBindingObserver { children: [ // 聊天内容 Expanded( - child: Obx( - () => Align( - alignment: Alignment.topCenter, - child: ListView.builder( - controller: controller.scrollController, - shrinkWrap: true, - reverse: true, - padding: - const EdgeInsets.symmetric(vertical: 16, horizontal: 16), - itemCount: controller.messages.length, - itemBuilder: (context, index) { - final message = controller - .messages[controller.messages.length - 1 - index]; - return Padding( - padding: const EdgeInsets.only(bottom: 8), - child: GestureDetector( - onLongPressStart: (LongPressStartDetails details) { - messageActionController.onLongPressMessage( - context, isDarkMode, details, message); - }, - child: MessageBubble( - isUser: message.isUser, - message: message.text, - timestamp: message.timestamp, - isRecognizing: message.isRecognizing, - hasImage: message.hasImage, - imagePath: message.imagePath, - meta: message.meta, - ), - )); - }, + child: Obx( + () => Align( + alignment: Alignment.topCenter, + child: ListView.builder( + controller: controller.scrollController, + shrinkWrap: true, + reverse: true, + padding: const EdgeInsets.symmetric( + vertical: 16, horizontal: 16), + itemCount: controller.messages.length, + itemBuilder: (context, index) { + final message = controller + .messages[controller.messages.length - 1 - index]; + return Padding( + padding: const EdgeInsets.only(bottom: 8), + child: GestureDetector( + onLongPressStart: + (LongPressStartDetails details) { + messageActionController.onLongPressMessage( + context, isDarkMode, details, message); + }, + child: MessageBubble( + isUser: message.isUser, + message: message.text, + timestamp: message.timestamp, + isRecognizing: message.isRecognizing, + hasImage: message.hasImage, + imagePath: message.imagePath, + meta: message.meta, + ), + )); + }, + ), + ), ), ), - ), - ), - // 输入区域 - Container( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), - decoration: BoxDecoration( - color: backgroundColor, - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.06), - blurRadius: 8, - offset: const Offset(0, -1), - ), - ], - border: Border( - top: BorderSide( - color: Colors.grey.withOpacity(0.15), - width: 1, + // 输入区域 + Container( + padding: + const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + decoration: BoxDecoration( + color: backgroundColor, + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.06), + blurRadius: 8, + offset: const Offset(0, -1), + ), + ], + border: Border( + top: BorderSide( + color: Colors.grey.withOpacity(0.15), + width: 1, + ), + ), ), - ), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - // 图片预览区域 - 仅在图片输入模式下显示 - Obx(() { - if (controller.isImageInputActive.value && - controller.selectedImagePath.value != null) { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - // 图片预览和关闭按钮 - Stack( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + // 图片预览区域 - 仅在图片输入模式下显示 + Obx(() { + if (controller.isImageInputActive.value && + controller.selectedImagePath.value != null) { + return Column( + mainAxisSize: MainAxisSize.min, children: [ - ClipRRect( - borderRadius: BorderRadius.circular(12), - child: Image.file( - File(controller.selectedImagePath.value!), - height: 150, - width: double.infinity, - fit: BoxFit.cover, - ), - ), - Positioned( - top: 8, - right: 8, - child: GestureDetector( - onTap: () => controller.clearImageInput(), - child: Container( - padding: const EdgeInsets.all(4), - decoration: BoxDecoration( - color: Colors.black.withOpacity(0.6), - shape: BoxShape.circle, + // 图片预览和关闭按钮 + Stack( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(12), + child: Image.file( + File(controller.selectedImagePath.value!), + height: 150, + width: double.infinity, + fit: BoxFit.cover, ), - child: const Icon( - Icons.close, - color: Colors.white, - size: 16, + ), + Positioned( + top: 8, + right: 8, + child: GestureDetector( + onTap: () => controller.clearImageInput(), + child: Container( + padding: const EdgeInsets.all(4), + decoration: BoxDecoration( + color: Colors.black.withOpacity(0.6), + shape: BoxShape.circle, + ), + child: const Icon( + Icons.close, + color: Colors.white, + size: 16, + ), + ), ), ), + ], + ), + + // 预设提示选项 + const SizedBox(height: 12), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + _buildPromptChip( + context: context, + label: '总结图片内容'.tr, + onTap: () => controller.summarizeImage(), + ), + const SizedBox(width: 8), + _buildPromptChip( + context: context, + label: '抽取图像文字'.tr, + onTap: () => + controller.extractTextFromImage(), + ), + const SizedBox(width: 8), + _buildPromptChip( + context: context, + label: '翻译图像文字'.tr, + onTap: () => + controller.translateImageText(), + ), + ], ), ), + const SizedBox(height: 12), ], - ), + ); + } else { + return const SizedBox.shrink(); + } + }), - // 预设提示选项 - const SizedBox(height: 12), - SingleChildScrollView( - scrollDirection: Axis.horizontal, + // 输入控件区域 - 包含输入行和展开的选项 + Column( + children: [ + // 输入控件行 - 使用IntrinsicHeight确保按钮与输入框底部对齐 + IntrinsicHeight( child: Row( + crossAxisAlignment: + CrossAxisAlignment.end, // 所有元素底部对齐 children: [ - _buildPromptChip( - context: context, - label: '总结图片内容'.tr, - onTap: () => controller.summarizeImage(), - ), - const SizedBox(width: 8), - _buildPromptChip( - context: context, - label: '抽取图像文字'.tr, - onTap: () => controller.extractTextFromImage(), - ), - const SizedBox(width: 8), - _buildPromptChip( - context: context, - label: '翻译图像文字'.tr, - onTap: () => controller.translateImageText(), - ), - ], - ), - ), - const SizedBox(height: 12), - ], - ); - } else { - return const SizedBox.shrink(); - } - }), - - // 输入控件区域 - 包含输入行和展开的选项 - Column( - children: [ - // 输入控件行 - 使用IntrinsicHeight确保按钮与输入框底部对齐 - IntrinsicHeight( - child: Row( - crossAxisAlignment: CrossAxisAlignment.end, // 所有元素底部对齐 - children: [ - // 键盘/语音切换按钮 - Obx(() { - final isTextMode = controller.isTextInputMode.value; - return GestureDetector( - onTap: () { - controller.toggleInputMode(); - }, - child: Container( - width: 44, - height: 44, - decoration: BoxDecoration( - color: isDarkMode - ? Colors.grey[800] - : Colors.grey[200], - borderRadius: BorderRadius.circular(22), - ), - child: Icon( - isTextMode ? Icons.mic_none : Icons.keyboard, - color: isDarkMode - ? Colors.grey[300] - : Colors.grey[700], - size: 22, - ), - ), - ); - }), - - const SizedBox(width: 8), - - // 文本输入框或语音波形图 - Expanded( - child: Obx(() { - final isTextMode = - controller.isTextInputMode.value; - - if (isTextMode) { - // 文本输入模式 - 限制最大高度并只向上扩展 - return Container( - constraints: const BoxConstraints( - minHeight: 44, // 最小高度 - maxHeight: 120, // 最大高度限制,防止挤压按钮 - ), - padding: const EdgeInsets.symmetric( - horizontal: 16), - decoration: BoxDecoration( - color: isDarkMode - ? Colors.grey[800] - : Colors.grey[200], - borderRadius: BorderRadius.circular(22), - border: Border.all( + // 键盘/语音切换按钮 + Obx(() { + final isTextMode = + controller.isTextInputMode.value; + return GestureDetector( + onTap: () { + controller.toggleInputMode(); + }, + child: Container( + width: 44, + height: 44, + decoration: BoxDecoration( color: isDarkMode - ? Colors.grey[ - 800]! // 修改: 从 Colors.grey[700] 改为 Colors.grey[800] - : Colors.grey.withOpacity(0.1), - width: 1.0, + ? Colors.grey[800] + : Colors.grey[200], + borderRadius: BorderRadius.circular(22), + ), + child: Icon( + isTextMode + ? Icons.mic_none + : Icons.keyboard, + color: isDarkMode + ? Colors.grey[300] + : Colors.grey[700], + size: 22, ), - ), - child: Row( - crossAxisAlignment: - CrossAxisAlignment.end, // 对齐到底部,实现向上扩展 - children: [ - Expanded( - child: Obx(() { - // 图片模式下使用更高的输入框 - final isImageActive = controller - .isImageInputActive.value; - - return TextField( - controller: - controller.textController, - maxLines: isImageActive - ? 3 - : 5, // 设置合理的最大行数 - minLines: isImageActive ? 2 : 1, - keyboardType: TextInputType - .multiline, // 启用多行键盘 - textInputAction: TextInputAction - .newline, // 支持回车换行 - onTap: () { - // 当点击输入框时,如果'+'选项已展开,则收缩 - if (controller - .isPlusOptionsExpanded - .value) { - controller - .collapsePlusOptions(); - } - }, - style: TextStyle( - fontSize: 15, - color: isDarkMode - ? Colors.white - : Colors.grey[800], - ), - decoration: InputDecoration( - hintText: isImageActive - ? '添加对图片的问题或描述...' - : '输入消息...', - hintStyle: TextStyle( - color: Colors.grey[500], - fontSize: 15, - ), - filled: false, - border: InputBorder.none, - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: isDarkMode - ? Colors.grey[800]! - : Colors.grey[200]!, - width: 1.0, - ), - ), - contentPadding: - EdgeInsets.symmetric( - vertical: isImageActive - ? 12 - : 8), // 调整垂直内边距 - ), - onSubmitted: (_) => - controller.sendMessage(), - ); - }), - ), - ], ), ); - } else { - // 语音输入模式 - 按住说话模式 - return GestureDetector( - onLongPressStart: (_) { - // 开始按住说话 - controller.startPushToTalk(); - }, - onLongPressEnd: (_) { - // 结束按住说话 - controller.endPushToTalk(); - }, - onLongPressCancel: () { - // 取消按住说话 - controller.endPushToTalk(); - }, - child: Obx(() { - final isPushToTalkActive = controller.isPushToTalkActive.value; - final isListening = controller.isListening.value; + }), + + const SizedBox(width: 8), + + // 文本输入框或语音波形图 + Expanded( + child: Obx(() { + final isTextMode = + controller.isTextInputMode.value; + if (isTextMode) { + // 文本输入模式 - 限制最大高度并只向上扩展 return Container( - height: 50, + constraints: const BoxConstraints( + minHeight: 44, // 最小高度 + maxHeight: 120, // 最大高度限制,防止挤压按钮 + ), padding: const EdgeInsets.symmetric( horizontal: 16), decoration: BoxDecoration( - color: isPushToTalkActive - ? (isDarkMode ? Colors.blue[900] : Colors.blue[100]) - : (isDarkMode ? Colors.grey[800] : Colors.grey[200]), + color: isDarkMode + ? Colors.grey[800] + : Colors.grey[200], borderRadius: BorderRadius.circular(22), border: Border.all( - color: isPushToTalkActive - ? Colors.blue - : (isDarkMode - ? Colors.grey[800]! - : Colors.grey.withOpacity(0.1)), - width: isPushToTalkActive ? 2.0 : 1.0, + color: isDarkMode + ? Colors.grey[ + 800]! // 修改: 从 Colors.grey[700] 改为 Colors.grey[800] + : Colors.grey.withOpacity(0.1), + width: 1.0, ), ), child: Row( + crossAxisAlignment: CrossAxisAlignment + .end, // 对齐到底部,实现向上扩展 children: [ - // 语音波形图 - 只在按住时显示 - if (isPushToTalkActive) ...[ - const AgentSoundBarsWidget(), - const Spacer(), - ], - - // 状态文字和图标 Expanded( - child: Row( - mainAxisAlignment: isPushToTalkActive - ? MainAxisAlignment.end - : MainAxisAlignment.center, - children: [ - Icon( - isPushToTalkActive ? Icons.mic : Icons.mic_none, - size: 16, - color: isPushToTalkActive - ? Colors.blue - : Colors.grey[500], + child: Obx(() { + // 图片模式下使用更高的输入框 + final isImageActive = controller + .isImageInputActive.value; + + return TextField( + controller: + controller.textController, + maxLines: isImageActive + ? 3 + : 5, // 设置合理的最大行数 + minLines: isImageActive ? 2 : 1, + keyboardType: TextInputType + .multiline, // 启用多行键盘 + textInputAction: TextInputAction + .newline, // 支持回车换行 + onTap: () { + // 当点击输入框时,如果'+'选项已展开,则收缩 + if (controller + .isPlusOptionsExpanded + .value) { + controller + .collapsePlusOptions(); + } + }, + style: TextStyle( + fontSize: 15, + color: isDarkMode + ? Colors.white + : Colors.grey[800], ), - const SizedBox(width: 6), - Text( - isPushToTalkActive - ? '正在录音...' - : '按住说话', - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w500, - color: isPushToTalkActive - ? Colors.blue - : Colors.grey[600], + decoration: InputDecoration( + hintText: isImageActive + ? '添加对图片的问题或描述...' + : '输入消息...', + hintStyle: TextStyle( + color: Colors.grey[500], + fontSize: 15, + ), + filled: false, + border: InputBorder.none, + focusedBorder: + OutlineInputBorder( + borderSide: BorderSide( + color: isDarkMode + ? Colors.grey[800]! + : Colors.grey[200]!, + width: 1.0, + ), ), + contentPadding: + EdgeInsets.symmetric( + vertical: isImageActive + ? 12 + : 8), // 调整垂直内边距 ), - ], - ), + onSubmitted: (_) => + controller.sendMessage(), + ); + }), ), ], ), ); - }), - ); - } - }), - ), + } else { + // 语音输入模式 - 按住说话模式 + return Listener( + onPointerDown: (_) { + // 开始按住说话 + controller.startPushToTalk(); + }, + onPointerUp: (_) { + // 结束按住说话 + controller.endPushToTalk(); + }, + // onLongPressCancel: () { + // // 取消按住说话 + // controller.endPushToTalk(); + // }, + child: Obx(() { + final isPushToTalkActive = + controller.isPushToTalkActive.value; + final isListening = + controller.isListening.value; - const SizedBox(width: 8), + return Container( + height: 50, + padding: const EdgeInsets.symmetric( + horizontal: 16), + decoration: BoxDecoration( + color: isPushToTalkActive + ? (isDarkMode + ? Colors.blue[900] + : Colors.blue[100]) + : (isDarkMode + ? Colors.grey[800] + : Colors.grey[200]), + borderRadius: + BorderRadius.circular(22), + border: Border.all( + color: isPushToTalkActive + ? Colors.blue + : (isDarkMode + ? Colors.grey[800]! + : Colors.grey + .withOpacity(0.1)), + width: isPushToTalkActive + ? 2.0 + : 1.0, + ), + ), + child: Row( + children: [ + // 语音波形图 - 只在按住时显示 + if (isPushToTalkActive) ...[ + const AgentSoundBarsWidget(), + //const Spacer(), + ], - // 动态按钮区域:展开按钮 + 发送按钮 或 图片选择按钮 - Obx(() { - final hasText = controller.hasTextInput.value; - final hasImage = - controller.isImageInputActive.value; - final shouldShowSend = hasText || hasImage; - final shouldShowExpand = - controller.shouldShowExpandButton.value; + // 状态文字和图标 + Expanded( + child: Row( + mainAxisAlignment: + isPushToTalkActive + ? MainAxisAlignment + .center + : MainAxisAlignment + .center, + children: [ + Icon( + isPushToTalkActive + ? Icons.mic + : Icons.mic_none, + size: 16, + color: isPushToTalkActive + ? Colors.blue + : Colors.grey[500], + ), + const SizedBox(width: 6), + Text( + isPushToTalkActive + ? '正在录音...' + : '按住说话', + style: TextStyle( + fontSize: 14, + fontWeight: + FontWeight.w500, + color: + isPushToTalkActive + ? Colors.blue + : Colors + .grey[600], + ), + ), + ], + ), + ), + ], + ), + ); + }), + ); + } + }), + ), - if (shouldShowSend) { - // 显示发送按钮(可能还有展开按钮) - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - // 展开按钮(在发送按钮上方) - if (shouldShowExpand && hasText) - Padding( - padding: - const EdgeInsets.only(bottom: 40), - child: GestureDetector( - onTap: () { - // 打开底部弹出编辑模式 - controller.openFullScreenEdit(); - showModalBottomSheet( - context: context, - isScrollControlled: true, - backgroundColor: Colors.transparent, - builder: (context) => - const FullScreenEditor(), - ).then((_) { - // 弹出页关闭时的回调 - controller.closeFullScreenEdit(); - }); - }, + const SizedBox(width: 8), + + // 动态按钮区域:展开按钮 + 发送按钮 或 图片选择按钮 + Obx(() { + final hasText = controller.hasTextInput.value; + final hasImage = + controller.isImageInputActive.value; + final shouldShowSend = hasText || hasImage; + final shouldShowExpand = + controller.shouldShowExpandButton.value; + + if (shouldShowSend) { + // 显示发送按钮(可能还有展开按钮) + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + // 展开按钮(在发送按钮上方) + if (shouldShowExpand && hasText) + Padding( + padding: + const EdgeInsets.only(bottom: 40), + child: GestureDetector( + onTap: () { + // 打开底部弹出编辑模式 + controller.openFullScreenEdit(); + showModalBottomSheet( + context: context, + isScrollControlled: true, + backgroundColor: + Colors.transparent, + builder: (context) => + const FullScreenEditor(), + ).then((_) { + // 弹出页关闭时的回调 + controller + .closeFullScreenEdit(); + }); + }, + child: Container( + width: 32, + height: 32, + decoration: BoxDecoration( + color: isDarkMode + ? Colors.grey[700] + : Colors.grey[300], + borderRadius: + BorderRadius.circular(16), + ), + child: Icon( + Icons.expand_less, + color: isDarkMode + ? Colors.grey[300] + : Colors.grey[700], + size: 20, + ), + ), + ), + ), + // 发送按钮 + GestureDetector( + onTap: () => controller.sendMessage(), child: Container( - width: 32, - height: 32, + width: 44, + height: 44, decoration: BoxDecoration( - color: isDarkMode - ? Colors.grey[700] - : Colors.grey[300], + color: primaryColor, borderRadius: - BorderRadius.circular(16), + BorderRadius.circular(22), ), - child: Icon( - Icons.expand_less, - color: isDarkMode - ? Colors.grey[300] - : Colors.grey[700], - size: 20, + child: const Icon( + Icons.send, + color: Colors.white, + size: 22, ), ), ), - ), - // 发送按钮 - GestureDetector( - onTap: () => controller.sendMessage(), - child: Container( - width: 44, - height: 44, - decoration: BoxDecoration( - color: primaryColor, - borderRadius: BorderRadius.circular(22), - ), - child: const Icon( - Icons.send, - color: Colors.white, - size: 22, - ), - ), - ), - ], - ); - } else { - // 显示'+'选择按钮 - return Obx(() { - final isExpanded = - controller.isPlusOptionsExpanded.value; - return GestureDetector( - onTap: () { - controller.togglePlusOptions(); - }, - child: Container( - width: 44, - height: 44, - decoration: BoxDecoration( - color: isDarkMode - ? Colors.grey[800] - : Colors.grey[200], - borderRadius: BorderRadius.circular(22), - ), - child: Icon( - isExpanded ? Icons.close : Icons.add, - color: isDarkMode - ? Colors.grey[300] - : Colors.grey[700], - size: 22, - ), - ), - ); - }); - } - }), - ], - ), - ), - - // 展开的'+'选择选项 - Obx(() { - final isExpanded = - controller.isPlusOptionsExpanded.value; - return AnimatedContainer( - duration: const Duration(milliseconds: 300), - curve: Curves.easeInOut, - height: isExpanded ? 120.h : 0, // 调整高度以适应按钮尺寸 - child: isExpanded - ? Container( - margin: EdgeInsets.only(top: 8.h), - padding: EdgeInsets.symmetric(horizontal:16.w), // 添加左右边距 - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, // 改为均匀分布 - children: [ - // 相机按钮 - _buildPlusOptionButton( - context: context, - icon: Icons.camera_alt, - label: '拍照', - onTap: () async { - //controller.collapsePlusOptions(); - await controller.takePhoto(); - }, - isDarkMode: isDarkMode, - ), - // 相册按钮 - _buildPlusOptionButton( - context: context, - icon: Icons.photo_library, - label: '相册', - onTap: () async { - //controller.collapsePlusOptions(); - await controller.pickImage(); - }, - isDarkMode: isDarkMode, - ), - // 文件按钮(预留位置) - // _buildPlusOptionButton( - // context: context, - // icon: Icons.folder, - // label: '文件', - // onTap: () { - // //controller.collapsePlusOptions(); - // // TODO: 实现文件选择功能 - // }, - // isDarkMode: isDarkMode, - // ), - // 通话按钮 - _buildPlusOptionButton( - context: context, - icon: Icons.phone, - label: '打电话', + ], + ); + } else { + // 显示'+'选择按钮 + return Obx(() { + final isExpanded = + controller.isPlusOptionsExpanded.value; + return GestureDetector( onTap: () { - // 启动打电话模式 - controller.startPhoneCall(); + controller.togglePlusOptions(); }, - isDarkMode: isDarkMode, + child: Container( + width: 44, + height: 44, + decoration: BoxDecoration( + color: isDarkMode + ? Colors.grey[800] + : Colors.grey[200], + borderRadius: + BorderRadius.circular(22), + ), + child: Icon( + isExpanded ? Icons.close : Icons.add, + color: isDarkMode + ? Colors.grey[300] + : Colors.grey[700], + size: 22, + ), + ), + ); + }); + } + }), + ], + ), + ), + + // 展开的'+'选择选项 + Obx(() { + final isExpanded = + controller.isPlusOptionsExpanded.value; + return AnimatedContainer( + duration: const Duration(milliseconds: 300), + curve: Curves.easeInOut, + height: isExpanded ? 120.h : 0, // 调整高度以适应按钮尺寸 + child: isExpanded + ? Container( + margin: EdgeInsets.only(top: 8.h), + padding: EdgeInsets.symmetric( + horizontal: 16.w), // 添加左右边距 + child: Row( + mainAxisAlignment: MainAxisAlignment + .spaceEvenly, // 改为均匀分布 + children: [ + // 相机按钮 + _buildPlusOptionButton( + context: context, + icon: Icons.camera_alt, + label: '拍照', + onTap: () async { + //controller.collapsePlusOptions(); + await controller.takePhoto(); + }, + isDarkMode: isDarkMode, + ), + // 相册按钮 + _buildPlusOptionButton( + context: context, + icon: Icons.photo_library, + label: '相册', + onTap: () async { + //controller.collapsePlusOptions(); + await controller.pickImage(); + }, + isDarkMode: isDarkMode, + ), + // 文件按钮(预留位置) + // _buildPlusOptionButton( + // context: context, + // icon: Icons.folder, + // label: '文件', + // onTap: () { + // //controller.collapsePlusOptions(); + // // TODO: 实现文件选择功能 + // }, + // isDarkMode: isDarkMode, + // ), + // 通话按钮 + _buildPlusOptionButton( + context: context, + icon: Icons.phone, + label: '打电话', + onTap: () { + // 启动打电话模式 + controller.startPhoneCall(); + }, + isDarkMode: isDarkMode, + ), + ], ), - ], - ), - ) - : const SizedBox.shrink(), - ); - }), + ) + : const SizedBox.shrink(), + ); + }), + ], + ), ], ), - ], - ), - ), + ), ], ), @@ -734,12 +767,6 @@ class _AgentViewState extends State with WidgetsBindingObserver { ); } - - - - - - // 构建提示选项芯片 Widget _buildPromptChip({ required BuildContext context, @@ -773,8 +800,6 @@ class _AgentViewState extends State with WidgetsBindingObserver { ); } - - // 构建"+"号展开选项按钮 Widget _buildPlusOptionButton({ required BuildContext context, @@ -923,7 +948,8 @@ class _AgentViewState extends State with WidgetsBindingObserver { children: [ // 音频可视化圆圈 Obx(() { - final isActive = controller.isListening.value || controller.isSpeaking.value; + final isActive = + controller.isListening.value || controller.isSpeaking.value; return AnimatedContainer( duration: const Duration(milliseconds: 300), width: isActive ? 200 : 160, @@ -982,11 +1008,13 @@ class _AgentViewState extends State with WidgetsBindingObserver { children: [ // 静音按钮 Obx(() => _buildPhoneControlButton( - icon: controller.isTtsEnabled.value ? Icons.volume_up : Icons.volume_off, - onTap: () => controller.toggleTts(), - isDarkMode: isDarkMode, - isActive: controller.isTtsEnabled.value, - )), + icon: controller.isTtsEnabled.value + ? Icons.volume_up + : Icons.volume_off, + onTap: () => controller.toggleTts(), + isDarkMode: isDarkMode, + isActive: controller.isTtsEnabled.value, + )), // 主要通话按钮 Obx(() { @@ -1007,7 +1035,8 @@ class _AgentViewState extends State with WidgetsBindingObserver { color: isActive ? Colors.red : Colors.green, boxShadow: [ BoxShadow( - color: (isActive ? Colors.red : Colors.green).withOpacity(0.3), + color: (isActive ? Colors.red : Colors.green) + .withOpacity(0.3), blurRadius: 12, spreadRadius: 2, ), @@ -1050,7 +1079,8 @@ class _AgentViewState extends State with WidgetsBindingObserver { height: 56, decoration: BoxDecoration( shape: BoxShape.circle, - color: backgroundColor ?? (isDarkMode ? Colors.grey[800] : Colors.grey[200]), + color: backgroundColor ?? + (isDarkMode ? Colors.grey[800] : Colors.grey[200]), border: isActive ? Border.all(color: Colors.blue, width: 2) : null, ), child: Icon( @@ -1064,7 +1094,3 @@ class _AgentViewState extends State with WidgetsBindingObserver { ); } } - - - -