Browse Source

refactor(ui): 优化语音打断功能的UI布局并更新翻译键名

将语音打断功能从弹出菜单改为行内显示,提升操作便捷性
统一翻译键名从language_interrupt改为voice_interrupt
weicu
lxm 12 months ago
parent
commit
cbc5f82d3c
  1. 2
      lib/core/translations/language/en_us.dart
  2. 2
      lib/core/translations/language/zh_cn.dart
  3. 2
      lib/core/translations/language/zh_hk.dart
  4. 2
      lib/modules/agent/views/agent_view.dart
  5. 112
      lib/modules/home/views/home_view.dart

2
lib/core/translations/language/en_us.dart

@ -543,7 +543,7 @@ const Map<String, String> 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

2
lib/core/translations/language/zh_cn.dart

@ -514,7 +514,7 @@ const Map<String, String> zhCN = {
"loadFailedClickRetry": "加载失败,点击重试",
"swipeUpForMore": "向上滑动查看更多",
"callingTool": "正在帮您,请稍等!", // 正在帮您,请稍等!
"language_interrupt": "语言打断", // 语言打断
"voice_interrupt": "语音打断", // 语音打断
// 预设提示词
"presetMusic": "来点音乐", // 来点音乐

2
lib/core/translations/language/zh_hk.dart

@ -296,7 +296,7 @@ const Map<String, String> zhHK = {
"loadFailedClickRetry": "載入失敗,點擊重試",
"swipeUpForMore": "向上滑動查看更多",
"callingTool": "正在帮您,请稍等!", // 正在帮您,请稍等!
"language_interrupt": "语言打断", // 语言打断
"voice_interrupt": "语音打断", // 语音打断
// Agent controller
'welcomeMessage': '你好!我是**小言**,我能幫你:\n\n'

2
lib/modules/agent/views/agent_view.dart

@ -225,7 +225,7 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver {
SizedBox(width: 8.w),
Text(
//'ttsInterruptToggle'.tr,
"language_interrupt".tr, // 语言打断
"voice_interrupt".tr, // 语音打断
style: TextStyle(fontSize: 14.sp),
),
const Spacer(),

112
lib/modules/home/views/home_view.dart

@ -164,96 +164,42 @@ class HomeView extends GetView<HomeController> {
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,
),
],
)),
),
),
],
)),
],
);
}

Loading…
Cancel
Save