From 4b52586f42b461efb58459338bd685660492d286 Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Fri, 31 Oct 2025 16:40:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ui):=20=E4=BC=98=E5=8C=96=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E6=89=93=E6=96=AD=E5=8A=9F=E8=83=BD=E7=9A=84UI?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E5=B9=B6=E6=9B=B4=E6=96=B0=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=E9=94=AE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将语音打断功能从弹出菜单改为行内显示,提升操作便捷性 统一翻译键名从language_interrupt改为voice_interrupt --- lib/core/translations/language/en_us.dart | 2 +- lib/core/translations/language/zh_cn.dart | 2 +- lib/core/translations/language/zh_hk.dart | 2 +- lib/modules/agent/views/agent_view.dart | 2 +- lib/modules/home/views/home_view.dart | 112 ++++++---------------- 5 files changed, 33 insertions(+), 87 deletions(-) diff --git a/lib/core/translations/language/en_us.dart b/lib/core/translations/language/en_us.dart index 6640f0c88..d01651e54 100644 --- a/lib/core/translations/language/en_us.dart +++ b/lib/core/translations/language/en_us.dart @@ -543,7 +543,7 @@ const Map enUS = { "loadFailedClickRetry": "Load failed, click to retry", "swipeUpForMore": "Swipe up for more", "callingTool": "I'm helping you, please wait!", // 正在帮您,请稍等! - "language_interrupt": "Language Interrupt", // 语言打断 + "voice_interrupt": "Interrupt", // 语音打断 // 预设提示词 "presetMusic": "Play some music", // Play some music diff --git a/lib/core/translations/language/zh_cn.dart b/lib/core/translations/language/zh_cn.dart index 8da12ffcc..74d2c9999 100644 --- a/lib/core/translations/language/zh_cn.dart +++ b/lib/core/translations/language/zh_cn.dart @@ -514,7 +514,7 @@ const Map zhCN = { "loadFailedClickRetry": "加载失败,点击重试", "swipeUpForMore": "向上滑动查看更多", "callingTool": "正在帮您,请稍等!", // 正在帮您,请稍等! - "language_interrupt": "语言打断", // 语言打断 + "voice_interrupt": "语音打断", // 语音打断 // 预设提示词 "presetMusic": "来点音乐", // 来点音乐 diff --git a/lib/core/translations/language/zh_hk.dart b/lib/core/translations/language/zh_hk.dart index 3e7446dfb..2a2c7fbfd 100644 --- a/lib/core/translations/language/zh_hk.dart +++ b/lib/core/translations/language/zh_hk.dart @@ -296,7 +296,7 @@ const Map zhHK = { "loadFailedClickRetry": "載入失敗,點擊重試", "swipeUpForMore": "向上滑動查看更多", "callingTool": "正在帮您,请稍等!", // 正在帮您,请稍等! - "language_interrupt": "语言打断", // 语言打断 + "voice_interrupt": "语音打断", // 语音打断 // Agent controller 'welcomeMessage': '你好!我是**小言**,我能幫你:\n\n' diff --git a/lib/modules/agent/views/agent_view.dart b/lib/modules/agent/views/agent_view.dart index 4151cf6b9..5aabbb9b1 100644 --- a/lib/modules/agent/views/agent_view.dart +++ b/lib/modules/agent/views/agent_view.dart @@ -225,7 +225,7 @@ class _AgentViewState extends State with WidgetsBindingObserver { SizedBox(width: 8.w), Text( //'ttsInterruptToggle'.tr, - "language_interrupt".tr, // 语言打断 + "voice_interrupt".tr, // 语音打断 style: TextStyle(fontSize: 14.sp), ), const Spacer(), diff --git a/lib/modules/home/views/home_view.dart b/lib/modules/home/views/home_view.dart index fbf1dbe51..31678e85f 100644 --- a/lib/modules/home/views/home_view.dart +++ b/lib/modules/home/views/home_view.dart @@ -164,96 +164,42 @@ class HomeView extends GetView { color: isDarkMode ? Colors.white : Colors.grey[800], ), ), - Container( - width: 32.w, - height: 32.w, - decoration: BoxDecoration( - color: isDarkMode ? Colors.grey[800] : Colors.grey[200], - shape: BoxShape.circle, - // boxShadow: [ - // BoxShadow( - // color: Colors.grey.withOpacity(0.2), - // blurRadius: 4, - // offset: const Offset(0, 2), - // ), - // ], - ), - child: Obx(() => PopupMenuButton( - padding: EdgeInsets.zero, - // 中文注释:缩小弹窗整体宽度,让展开窗口更紧凑 - constraints: BoxConstraints( - minWidth: 120.w, - maxWidth: 140.w, - ), - icon: Icon( + // 中文注释:去除菜单模式,直接在同一行展示“语音打断”与开关 + Obx(() => Row( + mainAxisSize: MainAxisSize.min, // 中文注释:按需占宽,避免占满右侧 + mainAxisAlignment: + MainAxisAlignment.end, // 中文注释:靠右紧凑排布 + children: [ + Icon( controller.isTtsInterruptEnabled.value ? Icons.voice_over_off : Icons.voice_over_off_outlined, - size: 12.sp, color: controller.isTtsInterruptEnabled.value - ? Theme.of(Get.context!).colorScheme.primary // 使用主题主色 - : (isDarkMode ? Colors.white70 : Colors.grey[600]), + ? Theme.of(Get.context!).colorScheme.primary + : (isDarkMode ? Colors.grey[600] : Colors.grey[600]), + size: 14.sp, // 中文注释:图标保持较小尺寸,减少占位 ), - elevation: 0, // 中文注释:去除弹窗阴影,实现扁平化 - // 中文注释:将弹窗位置整体上移,使菜单与“Voitrans”更为平齐 - offset: Offset(0, -10.h), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10.w), // 中文注释:略微减小圆角 - side: BorderSide.none, // 中文注释:移除边框线,边缘不明显 + SizedBox(width: 4.w), // 中文注释:图标与文字间距 + Text( + 'voice_interrupt'.tr, // 语音打断 + style: TextStyle( + fontSize: 12.sp, + height: 1.0, // 中文注释:降低行高以压缩垂直空间 + color: isDarkMode ? Colors.white70 : Colors.grey[800], + ), ), - color: isDarkMode ? Colors.grey[900] : Colors.grey[50], - itemBuilder: (context) => [ - PopupMenuItem( - // 中文注释:降低菜单项高度并收紧默认内边距,减少上下留白 - height: 15.h, - padding: - EdgeInsets.symmetric(horizontal: 2.w, vertical: 0.h), - child: Obx(() => Row( - mainAxisSize: MainAxisSize.max, // 中文注释:收紧行宽度 - mainAxisAlignment: - MainAxisAlignment.spaceBetween, // 让 Switch 靠右 - children: [ - Icon( - controller.isTtsInterruptEnabled.value - ? Icons.voice_over_off - : Icons.voice_over_off_outlined, - color: controller.isTtsInterruptEnabled.value - ? Theme.of(context).colorScheme.primary - : (isDarkMode - ? Colors.grey[400] - : Colors.grey), - size: 14.sp, // 中文注释:进一步缩小图标尺寸 - ), - SizedBox(width: 4.w), - Text( - // 翻译键代表的中文文本内容:语言打断 - 'language_interrupt'.tr, // 语言打断 - style: TextStyle( - fontSize: 11.sp, - height: 1.0, // 中文注释:降低行高,减小垂直占用 - ), - ), - //SizedBox(width: 0.w), // 中文注释:控制文字与开关间距 - Transform.scale( - scale: 0.6, // 中文注释:缩放开关控件,减小视觉尺寸 - child: Switch( - value: controller.isTtsInterruptEnabled.value, - onChanged: (value) => - controller.toggleTtsInterrupt(), - activeColor: - Theme.of(context).colorScheme.primary, - materialTapTargetSize: - MaterialTapTargetSize.shrinkWrap, - // 中文注释:删除不支持的 visualDensity 参数,保留缩放缩小尺寸 - ), - ), - ], - )), - onTap: () => controller.toggleTtsInterrupt(), + SizedBox(width: 4.w), // 中文注释:文字与开关间距 + Transform.scale( + scale: 0.7, // 中文注释:缩小开关视觉尺寸,保持紧凑 + child: Switch( + value: controller.isTtsInterruptEnabled.value, + onChanged: (value) => controller.toggleTtsInterrupt(), + activeColor: Theme.of(Get.context!).colorScheme.primary, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), - ], - )), - ), + ), + ], + )), ], ); }