From dd03ba86bd2e0a117cebcfc5994f5a58d194b354 Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Sun, 6 Jul 2025 15:41:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=BF=BB=E8=AF=91=E5=8E=86=E5=8F=B2):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=B6=E9=97=B4=E5=92=8C=E8=AF=AD=E7=A7=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=B9=B6=E4=BC=98=E5=8C=96=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在翻译历史列表中新增时间和语种信息的显示,包括: 1. 格式化显示时间(今天显示时间,其他日期显示月日时间) 2. 添加源语言和目标语言的显示(使用双向箭头符号) 3. 调整列表项布局为顶部对齐 4. 移除翻译详情页中暂时不需要的"记录摘要"标签页 --- .../views/translation_detail_view.dart | 35 +++++------ .../views/translation_history_view.dart | 60 ++++++++++++++++++- 2 files changed, 76 insertions(+), 19 deletions(-) diff --git a/lib/modules/translation/views/translation_detail_view.dart b/lib/modules/translation/views/translation_detail_view.dart index 5b988b5c5..c31db5552 100644 --- a/lib/modules/translation/views/translation_detail_view.dart +++ b/lib/modules/translation/views/translation_detail_view.dart @@ -72,14 +72,14 @@ class TranslationDetailView extends GetView { ), onPressed: () => Get.back(), ), - title: Text( - 'Detail', - style: TextStyle( - color: isDarkMode ? Colors.white : Colors.black, - fontSize: 24.sp, - fontWeight: FontWeight.bold, - ), - ), + // title: Text( + // 'Detail', + // style: TextStyle( + // color: isDarkMode ? Colors.white : Colors.black, + // fontSize: 24.sp, + // fontWeight: FontWeight.bold, + // ), + // ), centerTitle: true, actions: [ IconButton( @@ -108,15 +108,16 @@ class TranslationDetailView extends GetView { isDarkMode: isDarkMode, )), ), - SizedBox(width: 12.w), - Expanded( - child: Obx(() => _buildTabButton( - title: '记录摘要', - isSelected: controller.selectedTabIndex.value == 1, - onTap: () => controller.switchTab(1), - isDarkMode: isDarkMode, - )), - ), + //屏蔽“记录摘要”,需要是开启 + // SizedBox(width: 12.w), + // Expanded( + // child: Obx(() => _buildTabButton( + // title: '记录摘要', + // isSelected: controller.selectedTabIndex.value == 1, + // onTap: () => controller.switchTab(1), + // isDarkMode: isDarkMode, + // )), + // ), ], ), ); diff --git a/lib/modules/translation/views/translation_history_view.dart b/lib/modules/translation/views/translation_history_view.dart index 1283a4c27..4aeb6ef38 100644 --- a/lib/modules/translation/views/translation_history_view.dart +++ b/lib/modules/translation/views/translation_history_view.dart @@ -1,11 +1,13 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:intl/intl.dart'; import '../controllers/translation_controller.dart'; import '../controllers/translation_history_controller.dart'; import '../bindings/translation_detail_binding.dart'; import 'translation_detail_view.dart'; import '../../../core/theme/app_colors.dart'; +import '../../../data/services/language_manager.dart'; class TranslationHistoryView extends GetView { const TranslationHistoryView({Key? key}) : super(key: key); @@ -116,7 +118,7 @@ class TranslationHistoryView extends GetView { child: Padding( padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 16.h), child: Row( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Column( @@ -144,9 +146,36 @@ class TranslationHistoryView extends GetView { maxLines: 2, overflow: TextOverflow.ellipsis, ), + SizedBox(height: 8.h), + // 时间和语种信息行 + Row( + children: [ + // 时间信息 + Text( + _formatSessionTime(item.timestamp), + style: TextStyle( + fontSize: 12.sp, + color: isDarkMode ? Colors.grey[500] : Colors.grey[600], + ), + ), + SizedBox(width: 12.w), + // 语种信息 + Expanded( + child: Text( + _formatLanguagePair(item), + style: TextStyle( + fontSize: 12.sp, + color: isDarkMode ? Colors.grey[500] : Colors.grey[600], + ), + overflow: TextOverflow.ellipsis, + ), + ), + ], + ), ], ), ), + SizedBox(width: 12.w), Icon( Icons.chevron_right, color: isDarkMode ? Colors.grey[600] : Colors.grey[350], @@ -161,7 +190,7 @@ class TranslationHistoryView extends GetView { void _showTranslationDetail(TranslationItem item) { // 获取该会话的所有翻译项 final List sessionItems = controller.getSessionItems(item.sessionId); - + Get.to( () => TranslationDetailView(), arguments: { @@ -173,6 +202,33 @@ class TranslationHistoryView extends GetView { ); } + // 格式化会话时间 + String _formatSessionTime(DateTime timestamp) { + final now = DateTime.now(); + final today = DateTime(now.year, now.month, now.day); + final itemDate = DateTime(timestamp.year, timestamp.month, timestamp.day); + + if (itemDate == today) { + // 今天:只显示时间 HH:mm + return DateFormat('HH:mm').format(timestamp); + } else { + // 其他日期:显示月日和时间 MM-dd HH:mm + return DateFormat('MM-dd HH:mm').format(timestamp); + } + } + + // 格式化语种对信息 + String _formatLanguagePair(TranslationItem item) { + final languageManager = Get.find(); + + // 获取源语言和目标语言的中文名称 + final sourceName = languageManager.getChineseNameByAsrCode(item.sourceLanguageCode) ?? '未知语言'; + final targetName = languageManager.getChineseNameByAsrCode(item.targetLanguageCode) ?? '未知语言'; + + // 使用双向箭头符号表示翻译方向 + return '$sourceName ⇄ $targetName'; + } + void _showClearHistoryConfirmDialog() { final isDarkMode = Get.isDarkMode;