|
|
@ -21,8 +21,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
Widget build(BuildContext context) { |
|
|
Widget build(BuildContext context) { |
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
|
|
return Scaffold( |
|
|
return Scaffold( |
|
|
backgroundColor: |
|
|
backgroundColor: isDarkMode ? AppColors.darkBackground : Colors.grey[50], |
|
|
isDarkMode ? AppColors.darkBackground : Colors.grey[50], |
|
|
|
|
|
appBar: _buildAppBar(isDarkMode), |
|
|
appBar: _buildAppBar(isDarkMode), |
|
|
body: SafeArea( |
|
|
body: SafeArea( |
|
|
child: Obx(() { |
|
|
child: Obx(() { |
|
|
@ -85,7 +84,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
IconButton( |
|
|
IconButton( |
|
|
icon: const Icon(Icons.history), |
|
|
icon: const Icon(Icons.history), |
|
|
onPressed: _showHistoryBottomSheet, |
|
|
onPressed: _showHistoryBottomSheet, |
|
|
tooltip: 'historyRecords'.tr, //历史记录 |
|
|
tooltip: 'historyRecords'.tr, // 历史记录 |
|
|
), |
|
|
), |
|
|
PopupMenuButton<String>( |
|
|
PopupMenuButton<String>( |
|
|
onSelected: _handleMenuAction, |
|
|
onSelected: _handleMenuAction, |
|
|
@ -157,12 +156,11 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
children: [ |
|
|
children: [ |
|
|
Text( |
|
|
Text( |
|
|
'选择图片来源'.tr, //选择图片来源 |
|
|
'selectImageSource'.tr, // 选择图片来源 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16.sp, |
|
|
fontSize: 16.sp, |
|
|
fontWeight: FontWeight.w600, |
|
|
fontWeight: FontWeight.w600, |
|
|
color: |
|
|
color: Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
SizedBox(height: 12.h), |
|
|
SizedBox(height: 12.h), |
|
|
@ -277,12 +275,11 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
Padding( |
|
|
Padding( |
|
|
padding: EdgeInsets.all(16.w), |
|
|
padding: EdgeInsets.all(16.w), |
|
|
child: Text( |
|
|
child: Text( |
|
|
'图片预览', |
|
|
'imagePreview'.tr, // 图片预览 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16.sp, |
|
|
fontSize: 16.sp, |
|
|
fontWeight: FontWeight.w600, |
|
|
fontWeight: FontWeight.w600, |
|
|
color: |
|
|
color: Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
@ -377,8 +374,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
), |
|
|
), |
|
|
); |
|
|
); |
|
|
case ProcessingStatus.error: |
|
|
case ProcessingStatus.error: |
|
|
return Icon(Icons.error_outline, |
|
|
return Icon(Icons.error_outline, color: AppColors.error, size: 20.sp); |
|
|
color: AppColors.error, size: 20.sp); |
|
|
|
|
|
case ProcessingStatus.idle: |
|
|
case ProcessingStatus.idle: |
|
|
return Icon(Icons.check_circle_outline, |
|
|
return Icon(Icons.check_circle_outline, |
|
|
color: AppColors.success, size: 20.sp); |
|
|
color: AppColors.success, size: 20.sp); |
|
|
@ -423,25 +419,24 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
Padding( |
|
|
Padding( |
|
|
padding: EdgeInsets.all(16.w), |
|
|
padding: EdgeInsets.all(16.w), |
|
|
child: Text( |
|
|
child: Text( |
|
|
'翻译结果', |
|
|
'translationResult'.tr, // 翻译结果 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16.sp, |
|
|
fontSize: 16.sp, |
|
|
fontWeight: FontWeight.w600, |
|
|
fontWeight: FontWeight.w600, |
|
|
color: |
|
|
color: Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
if (controller.sourceText.value.isNotEmpty) |
|
|
if (controller.sourceText.value.isNotEmpty) |
|
|
_buildTextCard( |
|
|
_buildTextCard( |
|
|
'识别结果', |
|
|
'recognitionResult'.tr, // 识别结果 |
|
|
controller.sourceText.value, |
|
|
controller.sourceText.value, |
|
|
controller.sourceLanguageChineseName.value, |
|
|
controller.sourceLanguageChineseName.value, |
|
|
Colors.blue, |
|
|
Colors.blue, |
|
|
), |
|
|
), |
|
|
if (controller.translatedText.value.isNotEmpty) |
|
|
if (controller.translatedText.value.isNotEmpty) |
|
|
_buildTextCard( |
|
|
_buildTextCard( |
|
|
'翻译结果', |
|
|
'translationResult'.tr, // 翻译结果 |
|
|
controller.translatedText.value, |
|
|
controller.translatedText.value, |
|
|
controller.targetLanguageChineseName.value, |
|
|
controller.targetLanguageChineseName.value, |
|
|
Colors.green, |
|
|
Colors.green, |
|
|
@ -449,22 +444,22 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
if (controller.translatedImageBytes.value != null) ...[ |
|
|
if (controller.translatedImageBytes.value != null) ...[ |
|
|
Padding( |
|
|
Padding( |
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w), |
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w), |
|
|
child: Text( |
|
|
child: Text( |
|
|
'翻译后的图片预览', |
|
|
'translatedImagePreview'.tr, // 翻译后的图片预览 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 14.sp, |
|
|
fontSize: 14.sp, |
|
|
fontWeight: FontWeight.w600, |
|
|
fontWeight: FontWeight.w600, |
|
|
color: |
|
|
color: |
|
|
Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
SizedBox(height: 8.h), |
|
|
SizedBox(height: 8.h), |
|
|
Container( |
|
|
Container( |
|
|
height: 200.h, |
|
|
height: 200.h, |
|
|
margin: |
|
|
margin: |
|
|
EdgeInsets.symmetric(horizontal: 16.w).copyWith(bottom: 16.h), |
|
|
EdgeInsets.symmetric(horizontal: 16.w).copyWith(bottom: 16.h), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
|
|
|
color: Get.isDarkMode |
|
|
color: Get.isDarkMode |
|
|
? AppColors.cardBackground |
|
|
? AppColors.cardBackground |
|
|
: Colors.grey[100], |
|
|
: Colors.grey[100], |
|
|
@ -491,7 +486,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
size: 48.sp, color: Colors.red[400]), |
|
|
size: 48.sp, color: Colors.red[400]), |
|
|
SizedBox(height: 8.h), |
|
|
SizedBox(height: 8.h), |
|
|
Text( |
|
|
Text( |
|
|
'翻译图片加载失败', |
|
|
'translatedImageLoadFailed'.tr, // 翻译图片加载失败 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 14.sp, color: Colors.red[600]), |
|
|
fontSize: 14.sp, color: Colors.red[600]), |
|
|
), |
|
|
), |
|
|
@ -517,8 +512,8 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: color.withOpacity(Get.isDarkMode ? 0.15 : 0.05), |
|
|
color: color.withOpacity(Get.isDarkMode ? 0.15 : 0.05), |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
border: Border.all( |
|
|
border: |
|
|
color: color.withOpacity(Get.isDarkMode ? 0.3 : 0.2)), |
|
|
Border.all(color: color.withOpacity(Get.isDarkMode ? 0.3 : 0.2)), |
|
|
), |
|
|
), |
|
|
child: Column( |
|
|
child: Column( |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
@ -538,11 +533,11 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
icon: Icon(Icons.copy, size: 18.sp, color: color), |
|
|
icon: Icon(Icons.copy, size: 18.sp, color: color), |
|
|
onPressed: () { |
|
|
onPressed: () { |
|
|
Clipboard.setData(ClipboardData(text: content)); |
|
|
Clipboard.setData(ClipboardData(text: content)); |
|
|
Get.snackbar('success'.tr, 'copied'.tr); // 翻译键代表的中文文本内容 |
|
|
Get.snackbar('success'.tr, 'copied'.tr); // 对应中文:复制成功 |
|
|
}, |
|
|
}, |
|
|
padding: EdgeInsets.zero, |
|
|
padding: EdgeInsets.zero, |
|
|
constraints: const BoxConstraints(), |
|
|
constraints: const BoxConstraints(), |
|
|
tooltip: 'copy'.tr, // 翻译键代表的中文文本内容 |
|
|
tooltip: 'copy'.tr, // 复制 |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -551,8 +546,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
content, |
|
|
content, |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 15.sp, |
|
|
fontSize: 15.sp, |
|
|
color: |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black87, |
|
|
Get.isDarkMode ? Colors.white70 : Colors.black87, |
|
|
|
|
|
height: 1.4), |
|
|
height: 1.4), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
@ -584,7 +578,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
children: [ |
|
|
children: [ |
|
|
Text( |
|
|
Text( |
|
|
'translationHistory'.tr, // 翻译键代表的中文文本内容 |
|
|
'translationHistory'.tr, // 翻译历史 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16.sp, |
|
|
fontSize: 16.sp, |
|
|
fontWeight: FontWeight.w600, |
|
|
fontWeight: FontWeight.w600, |
|
|
@ -594,7 +588,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
), |
|
|
), |
|
|
TextButton( |
|
|
TextButton( |
|
|
onPressed: _showHistoryBottomSheet, |
|
|
onPressed: _showHistoryBottomSheet, |
|
|
child: Text('viewAll'.tr), // 翻译键代表的中文文本内容 |
|
|
child: Text('viewAll'.tr), // 查看全部 |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -604,7 +598,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
padding: |
|
|
padding: |
|
|
EdgeInsets.symmetric(horizontal: 16.w).copyWith(bottom: 16.h), |
|
|
EdgeInsets.symmetric(horizontal: 16.w).copyWith(bottom: 16.h), |
|
|
child: Text( |
|
|
child: Text( |
|
|
'noTranslationHistory'.tr, // 翻译键代表的中文文本内容 |
|
|
'noTranslationHistory'.tr, // 暂无历史记录 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 14.sp, |
|
|
fontSize: 14.sp, |
|
|
color: Get.isDarkMode |
|
|
color: Get.isDarkMode |
|
|
@ -629,8 +623,9 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
child: Container( |
|
|
child: Container( |
|
|
width: 40.w, |
|
|
width: 40.w, |
|
|
height: 40.w, |
|
|
height: 40.w, |
|
|
color: |
|
|
color: Get.isDarkMode |
|
|
Get.isDarkMode ? Colors.white.withOpacity(0.05) : Colors.grey[200], |
|
|
? Colors.white.withOpacity(0.05) |
|
|
|
|
|
: Colors.grey[200], |
|
|
child: Icon(Icons.image, |
|
|
child: Icon(Icons.image, |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.grey[400]), |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.grey[400]), |
|
|
), |
|
|
), |
|
|
@ -642,18 +637,16 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
style: TextStyle(fontSize: 14.sp), |
|
|
style: TextStyle(fontSize: 14.sp), |
|
|
), |
|
|
), |
|
|
subtitle: Text( |
|
|
subtitle: Text( |
|
|
'${item.sourceLanguageName} → ${item.targetLanguageName}', |
|
|
'${item.sourceLanguageName.tr} → ${item.targetLanguageName.tr}', // 源语言名/目标语言名 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 12.sp, |
|
|
fontSize: 12.sp, |
|
|
color: |
|
|
color: Get.isDarkMode ? AppColors.textSecondary : Colors.grey[600]), |
|
|
Get.isDarkMode ? AppColors.textSecondary : Colors.grey[600]), |
|
|
|
|
|
), |
|
|
), |
|
|
trailing: Text( |
|
|
trailing: Text( |
|
|
_formatTime(item.timestamp), |
|
|
_formatTime(item.timestamp), |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 12.sp, |
|
|
fontSize: 12.sp, |
|
|
color: |
|
|
color: Get.isDarkMode ? Colors.white54 : Colors.grey[500]), |
|
|
Get.isDarkMode ? Colors.white54 : Colors.grey[500]), |
|
|
|
|
|
), |
|
|
), |
|
|
onTap: () => _showHistoryDetail(item), |
|
|
onTap: () => _showHistoryDetail(item), |
|
|
); |
|
|
); |
|
|
@ -675,19 +668,16 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
children: [ |
|
|
children: [ |
|
|
Text( |
|
|
Text( |
|
|
'translationHistory'.tr, // 翻译键代表的中文文本内容 |
|
|
'translationHistory'.tr, // 翻译历史 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 18.sp, |
|
|
fontSize: 18.sp, |
|
|
fontWeight: FontWeight.bold, |
|
|
fontWeight: FontWeight.bold, |
|
|
color: Get.isDarkMode |
|
|
color: Get.isDarkMode ? AppColors.textPrimary : null), |
|
|
? AppColors.textPrimary |
|
|
|
|
|
: null), |
|
|
|
|
|
), |
|
|
), |
|
|
IconButton( |
|
|
IconButton( |
|
|
onPressed: () => Get.back(), |
|
|
onPressed: () => Get.back(), |
|
|
icon: Icon(Icons.close, |
|
|
icon: Icon(Icons.close, |
|
|
color: |
|
|
color: Get.isDarkMode ? AppColors.textPrimary : null), |
|
|
Get.isDarkMode ? AppColors.textPrimary : null), |
|
|
|
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -698,7 +688,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
if (controller.historyList.isEmpty) { |
|
|
if (controller.historyList.isEmpty) { |
|
|
return Center( |
|
|
return Center( |
|
|
child: Text( |
|
|
child: Text( |
|
|
'noTranslationHistory'.tr, // 翻译键代表的中文文本内容 |
|
|
'noTranslationHistory'.tr, // 暂无历史记录 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16.sp, |
|
|
fontSize: 16.sp, |
|
|
color: Get.isDarkMode |
|
|
color: Get.isDarkMode |
|
|
@ -745,13 +735,18 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
final difference = now.difference(timestamp); |
|
|
final difference = now.difference(timestamp); |
|
|
|
|
|
|
|
|
if (difference.inDays > 0) { |
|
|
if (difference.inDays > 0) { |
|
|
return '${difference.inDays}天前'; |
|
|
return 'daysAgo' |
|
|
|
|
|
.tr |
|
|
|
|
|
.replaceAll('@days', difference.inDays.toString()); // @days天前 |
|
|
} else if (difference.inHours > 0) { |
|
|
} else if (difference.inHours > 0) { |
|
|
return '${difference.inHours}小时前'; |
|
|
return 'hoursAgo' |
|
|
|
|
|
.tr |
|
|
|
|
|
.replaceAll('@hours', difference.inHours.toString()); // @hours小时前 |
|
|
} else if (difference.inMinutes > 0) { |
|
|
} else if (difference.inMinutes > 0) { |
|
|
return '${difference.inMinutes}分钟前'; |
|
|
return 'minutesAgo'.tr.replaceAll( |
|
|
|
|
|
'@minutes', difference.inMinutes.toString()); // @minutes分钟前 |
|
|
} else { |
|
|
} else { |
|
|
return '刚刚'; |
|
|
return 'justNow'.tr; // 刚刚 |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -759,7 +754,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
Get.dialog( |
|
|
Get.dialog( |
|
|
AlertDialog( |
|
|
AlertDialog( |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
title: Text('设置', |
|
|
title: Text('settings'.tr, // 设置 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
content: Column( |
|
|
content: Column( |
|
|
@ -768,16 +763,17 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
ListTile( |
|
|
ListTile( |
|
|
leading: Icon(Icons.photo_size_select_actual, |
|
|
leading: Icon(Icons.photo_size_select_actual, |
|
|
color: Get.isDarkMode ? Colors.white : null), |
|
|
color: Get.isDarkMode ? Colors.white : null), |
|
|
title: Text('图片质量', |
|
|
title: Text('imageQuality'.tr, // 图片质量 |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
|
|
|
subtitle: Obx(() => Text( |
|
|
|
|
|
'currentQuality'.tr.replaceAll( |
|
|
|
|
|
'@value', |
|
|
|
|
|
controller.imageQuality.value |
|
|
|
|
|
.toString()), // 当前质量: @value% |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: |
|
|
color: |
|
|
Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
Get.isDarkMode ? Colors.white70 : Colors.black54))), |
|
|
subtitle: |
|
|
|
|
|
Obx(() => Text('当前: ${controller.imageQuality.value}%', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode |
|
|
|
|
|
? Colors.white70 |
|
|
|
|
|
: Colors.black54))), |
|
|
|
|
|
onTap: () { |
|
|
onTap: () { |
|
|
Get.back(); |
|
|
Get.back(); |
|
|
_showImageQualityDialog(); |
|
|
_showImageQualityDialog(); |
|
|
@ -786,16 +782,15 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
ListTile( |
|
|
ListTile( |
|
|
leading: Icon(Icons.photo_size_select_large, |
|
|
leading: Icon(Icons.photo_size_select_large, |
|
|
color: Get.isDarkMode ? Colors.white : null), |
|
|
color: Get.isDarkMode ? Colors.white : null), |
|
|
title: Text('最大尺寸', |
|
|
title: Text('maxSize'.tr, // 最大尺寸 |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
|
|
|
subtitle: Obx(() => Text( |
|
|
|
|
|
'currentMaxSize'.tr.replaceAll('@px', |
|
|
|
|
|
controller.maxImageSize.value.toString()), // 当前: @pxpx |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: |
|
|
color: |
|
|
Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
Get.isDarkMode ? Colors.white70 : Colors.black54))), |
|
|
subtitle: |
|
|
|
|
|
Obx(() => Text('当前: ${controller.maxImageSize.value}px', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode |
|
|
|
|
|
? Colors.white70 |
|
|
|
|
|
: Colors.black54))), |
|
|
|
|
|
onTap: () { |
|
|
onTap: () { |
|
|
Get.back(); |
|
|
Get.back(); |
|
|
_showImageSizeDialog(); |
|
|
_showImageSizeDialog(); |
|
|
@ -806,7 +801,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
actions: [ |
|
|
actions: [ |
|
|
TextButton( |
|
|
TextButton( |
|
|
onPressed: () => Get.back(), |
|
|
onPressed: () => Get.back(), |
|
|
child: Text('关闭', |
|
|
child: Text('close'.tr, // 关闭 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
), |
|
|
), |
|
|
@ -819,13 +814,17 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
Get.dialog( |
|
|
Get.dialog( |
|
|
AlertDialog( |
|
|
AlertDialog( |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
title: Text('设置图片质量', |
|
|
title: Text('setImageQuality'.tr, // 设置图片质量 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
content: Obx(() => Column( |
|
|
content: Obx(() => Column( |
|
|
mainAxisSize: MainAxisSize.min, |
|
|
mainAxisSize: MainAxisSize.min, |
|
|
children: [ |
|
|
children: [ |
|
|
Text('当前质量: ${controller.imageQuality.value}%', |
|
|
Text( |
|
|
|
|
|
'currentQuality'.tr.replaceAll( |
|
|
|
|
|
'@value', |
|
|
|
|
|
controller.imageQuality.value |
|
|
|
|
|
.toString()), // 当前质量: @value% |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: |
|
|
color: |
|
|
Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
@ -843,7 +842,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
actions: [ |
|
|
actions: [ |
|
|
TextButton( |
|
|
TextButton( |
|
|
onPressed: () => Get.back(), |
|
|
onPressed: () => Get.back(), |
|
|
child: Text('确定', |
|
|
child: Text('confirm'.tr, // 确认 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
), |
|
|
), |
|
|
@ -857,7 +856,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
Get.dialog( |
|
|
Get.dialog( |
|
|
AlertDialog( |
|
|
AlertDialog( |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
title: Text('设置最大尺寸', |
|
|
title: Text('setMaxSize'.tr, // 设置最大尺寸 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
content: Column( |
|
|
content: Column( |
|
|
@ -879,7 +878,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
actions: [ |
|
|
actions: [ |
|
|
TextButton( |
|
|
TextButton( |
|
|
onPressed: () => Get.back(), |
|
|
onPressed: () => Get.back(), |
|
|
child: Text('取消', |
|
|
child: Text('cancel'.tr, // 取消 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
), |
|
|
), |
|
|
@ -892,16 +891,16 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
Get.dialog( |
|
|
Get.dialog( |
|
|
AlertDialog( |
|
|
AlertDialog( |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
title: Text('清空历史', |
|
|
title: Text('clearHistory'.tr, // 清除历史记录 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
content: Text('确定要清空所有翻译历史吗?此操作不可撤销。', |
|
|
content: Text('clearHistoryConfirm'.tr, // 确定要清除所有翻译历史记录吗?此操作无法撤销。 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
actions: [ |
|
|
actions: [ |
|
|
TextButton( |
|
|
TextButton( |
|
|
onPressed: () => Get.back(), |
|
|
onPressed: () => Get.back(), |
|
|
child: Text('取消', |
|
|
child: Text('cancel'.tr, // 取消 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
), |
|
|
), |
|
|
@ -910,7 +909,8 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
controller.clearHistory(); |
|
|
controller.clearHistory(); |
|
|
Get.back(); |
|
|
Get.back(); |
|
|
}, |
|
|
}, |
|
|
child: Text('确定', style: TextStyle(color: AppColors.error)), |
|
|
child: Text('confirm'.tr, // 确认 |
|
|
|
|
|
style: TextStyle(color: AppColors.error)), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -923,11 +923,10 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
height: 200.h, |
|
|
height: 200.h, |
|
|
margin: EdgeInsets.symmetric(horizontal: 16.w).copyWith(bottom: 16.h), |
|
|
margin: EdgeInsets.symmetric(horizontal: 16.w).copyWith(bottom: 16.h), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: |
|
|
color: Get.isDarkMode ? AppColors.cardBackground : Colors.grey[100], |
|
|
Get.isDarkMode ? AppColors.cardBackground : Colors.grey[100], |
|
|
|
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
border: |
|
|
border: Border.all( |
|
|
Border.all(color: Get.isDarkMode ? Colors.white12 : Colors.grey[300]!), |
|
|
color: Get.isDarkMode ? Colors.white12 : Colors.grey[300]!), |
|
|
), |
|
|
), |
|
|
child: file == null |
|
|
child: file == null |
|
|
? Center( |
|
|
? Center( |
|
|
@ -936,10 +935,11 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
children: [ |
|
|
children: [ |
|
|
Icon(Icons.image_outlined, |
|
|
Icon(Icons.image_outlined, |
|
|
size: 48.sp, |
|
|
size: 48.sp, |
|
|
color: Get.isDarkMode ? Colors.white54 : Colors.grey[400]), |
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? Colors.white54 : Colors.grey[400]), |
|
|
SizedBox(height: 8.h), |
|
|
SizedBox(height: 8.h), |
|
|
Text( |
|
|
Text( |
|
|
'请选择图片', |
|
|
'pleaseSelectImage'.tr, // 请选择图片 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 14.sp, |
|
|
fontSize: 14.sp, |
|
|
color: Get.isDarkMode |
|
|
color: Get.isDarkMode |
|
|
@ -967,7 +967,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
size: 48.sp, color: Colors.red[400]), |
|
|
size: 48.sp, color: Colors.red[400]), |
|
|
SizedBox(height: 8.h), |
|
|
SizedBox(height: 8.h), |
|
|
Text( |
|
|
Text( |
|
|
'图片加载失败', |
|
|
'imageLoadFailed'.tr, // 图片加载失败 |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 14.sp, |
|
|
fontSize: 14.sp, |
|
|
color: Get.isDarkMode |
|
|
color: Get.isDarkMode |
|
|
@ -985,11 +985,15 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Widget _buildSourceTextBox() { |
|
|
Widget _buildSourceTextBox() { |
|
|
return _buildTextBox('识别结果', controller.sourceText.value); |
|
|
return _buildTextBox( |
|
|
|
|
|
'recognitionResult'.tr, // 识别结果 |
|
|
|
|
|
controller.sourceText.value); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Widget _buildTranslatedTextBox() { |
|
|
Widget _buildTranslatedTextBox() { |
|
|
return _buildTextBox('翻译结果', controller.translatedText.value); |
|
|
return _buildTextBox( |
|
|
|
|
|
'translationResult'.tr, // 翻译结果 |
|
|
|
|
|
controller.translatedText.value); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Widget _buildTextBox(String title, String content) { |
|
|
Widget _buildTextBox(String title, String content) { |
|
|
|