|
|
|
@ -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<TranslationHistoryController> { |
|
|
|
const TranslationHistoryView({Key? key}) : super(key: key); |
|
|
|
@ -116,7 +118,7 @@ class TranslationHistoryView extends GetView<TranslationHistoryController> { |
|
|
|
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<TranslationHistoryController> { |
|
|
|
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<TranslationHistoryController> { |
|
|
|
void _showTranslationDetail(TranslationItem item) { |
|
|
|
// 获取该会话的所有翻译项 |
|
|
|
final List<TranslationItem> sessionItems = controller.getSessionItems(item.sessionId); |
|
|
|
|
|
|
|
|
|
|
|
Get.to( |
|
|
|
() => TranslationDetailView(), |
|
|
|
arguments: { |
|
|
|
@ -173,6 +202,33 @@ class TranslationHistoryView extends GetView<TranslationHistoryController> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// 格式化会话时间 |
|
|
|
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<LanguageManager>(); |
|
|
|
|
|
|
|
// 获取源语言和目标语言的中文名称 |
|
|
|
final sourceName = languageManager.getChineseNameByAsrCode(item.sourceLanguageCode) ?? '未知语言'; |
|
|
|
final targetName = languageManager.getChineseNameByAsrCode(item.targetLanguageCode) ?? '未知语言'; |
|
|
|
|
|
|
|
// 使用双向箭头符号表示翻译方向 |
|
|
|
return '$sourceName ⇄ $targetName'; |
|
|
|
} |
|
|
|
|
|
|
|
void _showClearHistoryConfirmDialog() { |
|
|
|
final isDarkMode = Get.isDarkMode; |
|
|
|
|
|
|
|
|