|
|
@ -21,7 +21,8 @@ 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: Colors.grey[50], |
|
|
backgroundColor: |
|
|
|
|
|
isDarkMode ? AppColors.darkBackground : Colors.grey[50], |
|
|
appBar: _buildAppBar(isDarkMode), |
|
|
appBar: _buildAppBar(isDarkMode), |
|
|
body: SafeArea( |
|
|
body: SafeArea( |
|
|
child: Obx(() { |
|
|
child: Obx(() { |
|
|
@ -140,11 +141,13 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
return Container( |
|
|
return Container( |
|
|
padding: EdgeInsets.all(16.w), |
|
|
padding: EdgeInsets.all(16.w), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: Colors.white, |
|
|
color: Get.isDarkMode ? AppColors.cardBackground : Colors.white, |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
boxShadow: [ |
|
|
boxShadow: [ |
|
|
BoxShadow( |
|
|
BoxShadow( |
|
|
color: Colors.black.withOpacity(0.05), |
|
|
color: Get.isDarkMode |
|
|
|
|
|
? Colors.black.withOpacity(0.2) |
|
|
|
|
|
: Colors.black.withOpacity(0.05), |
|
|
blurRadius: 10, |
|
|
blurRadius: 10, |
|
|
offset: const Offset(0, 2), |
|
|
offset: const Offset(0, 2), |
|
|
), |
|
|
), |
|
|
@ -158,7 +161,8 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16.sp, |
|
|
fontSize: 16.sp, |
|
|
fontWeight: FontWeight.w600, |
|
|
fontWeight: FontWeight.w600, |
|
|
color: Colors.black87, |
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
SizedBox(height: 12.h), |
|
|
SizedBox(height: 12.h), |
|
|
@ -195,8 +199,9 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
required VoidCallback onTap, |
|
|
required VoidCallback onTap, |
|
|
required Color color, |
|
|
required Color color, |
|
|
}) { |
|
|
}) { |
|
|
|
|
|
final isDarkMode = Get.isDarkMode; |
|
|
return Material( |
|
|
return Material( |
|
|
color: color.withOpacity(0.1), |
|
|
color: color.withOpacity(isDarkMode ? 0.2 : 0.1), |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
child: InkWell( |
|
|
child: InkWell( |
|
|
onTap: controller.isProcessing.value ? null : onTap, |
|
|
onTap: controller.isProcessing.value ? null : onTap, |
|
|
@ -254,11 +259,13 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
Widget _buildImageSection() { |
|
|
Widget _buildImageSection() { |
|
|
return Container( |
|
|
return Container( |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: Colors.white, |
|
|
color: Get.isDarkMode ? AppColors.cardBackground : Colors.white, |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
boxShadow: [ |
|
|
boxShadow: [ |
|
|
BoxShadow( |
|
|
BoxShadow( |
|
|
color: Colors.black.withOpacity(0.05), |
|
|
color: Get.isDarkMode |
|
|
|
|
|
? Colors.black.withOpacity(0.2) |
|
|
|
|
|
: Colors.black.withOpacity(0.05), |
|
|
blurRadius: 10, |
|
|
blurRadius: 10, |
|
|
offset: const Offset(0, 2), |
|
|
offset: const Offset(0, 2), |
|
|
), |
|
|
), |
|
|
@ -274,7 +281,8 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16.sp, |
|
|
fontSize: 16.sp, |
|
|
fontWeight: FontWeight.w600, |
|
|
fontWeight: FontWeight.w600, |
|
|
color: Colors.black87, |
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
@ -289,11 +297,13 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
return Container( |
|
|
return Container( |
|
|
padding: EdgeInsets.all(16.w), |
|
|
padding: EdgeInsets.all(16.w), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: Colors.white, |
|
|
color: Get.isDarkMode ? AppColors.cardBackground : Colors.white, |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
boxShadow: [ |
|
|
boxShadow: [ |
|
|
BoxShadow( |
|
|
BoxShadow( |
|
|
color: Colors.black.withOpacity(0.05), |
|
|
color: Get.isDarkMode |
|
|
|
|
|
? Colors.black.withOpacity(0.2) |
|
|
|
|
|
: Colors.black.withOpacity(0.05), |
|
|
blurRadius: 10, |
|
|
blurRadius: 10, |
|
|
offset: const Offset(0, 2), |
|
|
offset: const Offset(0, 2), |
|
|
), |
|
|
), |
|
|
@ -315,15 +325,21 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16.sp, |
|
|
fontSize: 16.sp, |
|
|
fontWeight: FontWeight.w600, |
|
|
fontWeight: FontWeight.w600, |
|
|
color: Colors.black87, |
|
|
color: Get.isDarkMode |
|
|
|
|
|
? AppColors.textPrimary |
|
|
|
|
|
: Colors.black87, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
if (step.description.isNotEmpty) ...[ |
|
|
if (step.description.isNotEmpty) ...[ |
|
|
SizedBox(height: 4.h), |
|
|
SizedBox(height: 4.h), |
|
|
Text( |
|
|
Text( |
|
|
step.description, |
|
|
step.description, |
|
|
style: |
|
|
style: TextStyle( |
|
|
TextStyle(fontSize: 14.sp, color: Colors.grey[600]), |
|
|
fontSize: 14.sp, |
|
|
|
|
|
color: Get.isDarkMode |
|
|
|
|
|
? AppColors.textSecondary |
|
|
|
|
|
: Colors.grey[600], |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
], |
|
|
], |
|
|
@ -335,7 +351,8 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
SizedBox(height: 12.h), |
|
|
SizedBox(height: 12.h), |
|
|
LinearProgressIndicator( |
|
|
LinearProgressIndicator( |
|
|
value: step.progress, |
|
|
value: step.progress, |
|
|
backgroundColor: Colors.grey[200], |
|
|
backgroundColor: |
|
|
|
|
|
Get.isDarkMode ? Colors.white12 : Colors.grey[200], |
|
|
valueColor: |
|
|
valueColor: |
|
|
AlwaysStoppedAnimation<Color>(_getStatusColor(step.status)), |
|
|
AlwaysStoppedAnimation<Color>(_getStatusColor(step.status)), |
|
|
), |
|
|
), |
|
|
@ -360,38 +377,41 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
), |
|
|
), |
|
|
); |
|
|
); |
|
|
case ProcessingStatus.error: |
|
|
case ProcessingStatus.error: |
|
|
return Icon(Icons.error_outline, color: Colors.red, size: 20.sp); |
|
|
return Icon(Icons.error_outline, |
|
|
|
|
|
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: Colors.green, size: 20.sp); |
|
|
color: AppColors.success, size: 20.sp); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Color _getStatusColor(ProcessingStatus status) { |
|
|
Color _getStatusColor(ProcessingStatus status) { |
|
|
switch (status) { |
|
|
switch (status) { |
|
|
case ProcessingStatus.picking: |
|
|
case ProcessingStatus.picking: |
|
|
return Colors.blue; |
|
|
return AppColors.primary; |
|
|
case ProcessingStatus.recognizing: |
|
|
case ProcessingStatus.recognizing: |
|
|
return Colors.orange; |
|
|
return AppColors.warning; |
|
|
case ProcessingStatus.translating: |
|
|
case ProcessingStatus.translating: |
|
|
return Colors.purple; |
|
|
return AppColors.accent; |
|
|
case ProcessingStatus.saving: |
|
|
case ProcessingStatus.saving: |
|
|
return Colors.green; |
|
|
return AppColors.success; |
|
|
case ProcessingStatus.error: |
|
|
case ProcessingStatus.error: |
|
|
return Colors.red; |
|
|
return AppColors.error; |
|
|
case ProcessingStatus.idle: |
|
|
case ProcessingStatus.idle: |
|
|
return Colors.grey; |
|
|
return AppColors.disabled; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Widget _buildResultsSection() { |
|
|
Widget _buildResultsSection() { |
|
|
return Container( |
|
|
return Container( |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: Colors.white, |
|
|
color: Get.isDarkMode ? AppColors.cardBackground : Colors.white, |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
boxShadow: [ |
|
|
boxShadow: [ |
|
|
BoxShadow( |
|
|
BoxShadow( |
|
|
color: Colors.black.withOpacity(0.05), |
|
|
color: Get.isDarkMode |
|
|
|
|
|
? Colors.black.withOpacity(0.2) |
|
|
|
|
|
: Colors.black.withOpacity(0.05), |
|
|
blurRadius: 10, |
|
|
blurRadius: 10, |
|
|
offset: const Offset(0, 2), |
|
|
offset: const Offset(0, 2), |
|
|
), |
|
|
), |
|
|
@ -407,7 +427,8 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16.sp, |
|
|
fontSize: 16.sp, |
|
|
fontWeight: FontWeight.w600, |
|
|
fontWeight: FontWeight.w600, |
|
|
color: Colors.black87, |
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
@ -428,24 +449,28 @@ 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( |
|
|
'翻译后的图片预览', |
|
|
'翻译后的图片预览', |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 14.sp, |
|
|
fontSize: 14.sp, |
|
|
fontWeight: FontWeight.w600, |
|
|
fontWeight: FontWeight.w600, |
|
|
color: Colors.black87, |
|
|
color: |
|
|
), |
|
|
Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
SizedBox(height: 8.h), |
|
|
), |
|
|
Container( |
|
|
SizedBox(height: 8.h), |
|
|
height: 200.h, |
|
|
Container( |
|
|
margin: |
|
|
height: 200.h, |
|
|
EdgeInsets.symmetric(horizontal: 16.w).copyWith(bottom: 16.h), |
|
|
margin: |
|
|
decoration: BoxDecoration( |
|
|
EdgeInsets.symmetric(horizontal: 16.w).copyWith(bottom: 16.h), |
|
|
color: Colors.grey[100], |
|
|
decoration: BoxDecoration( |
|
|
|
|
|
color: Get.isDarkMode |
|
|
|
|
|
? AppColors.cardBackground |
|
|
|
|
|
: Colors.grey[100], |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
border: Border.all(color: Colors.grey[300]!), |
|
|
border: Border.all( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white12 : Colors.grey[300]!), |
|
|
), |
|
|
), |
|
|
child: GestureDetector( |
|
|
child: GestureDetector( |
|
|
onTap: () => _openImageViewer( |
|
|
onTap: () => _openImageViewer( |
|
|
@ -490,9 +515,10 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
margin: EdgeInsets.symmetric(horizontal: 16.w).copyWith(bottom: 16.h), |
|
|
margin: EdgeInsets.symmetric(horizontal: 16.w).copyWith(bottom: 16.h), |
|
|
padding: EdgeInsets.all(16.w), |
|
|
padding: EdgeInsets.all(16.w), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: color.withOpacity(0.05), |
|
|
color: color.withOpacity(Get.isDarkMode ? 0.15 : 0.05), |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
border: Border.all(color: color.withOpacity(0.2)), |
|
|
border: Border.all( |
|
|
|
|
|
color: color.withOpacity(Get.isDarkMode ? 0.3 : 0.2)), |
|
|
), |
|
|
), |
|
|
child: Column( |
|
|
child: Column( |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
@ -523,8 +549,11 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
SizedBox(height: 8.h), |
|
|
SizedBox(height: 8.h), |
|
|
SelectableText( |
|
|
SelectableText( |
|
|
content, |
|
|
content, |
|
|
style: |
|
|
style: TextStyle( |
|
|
TextStyle(fontSize: 15.sp, color: Colors.black87, height: 1.4), |
|
|
fontSize: 15.sp, |
|
|
|
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? Colors.white70 : Colors.black87, |
|
|
|
|
|
height: 1.4), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -534,11 +563,13 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
Widget _buildHistorySection() { |
|
|
Widget _buildHistorySection() { |
|
|
return Container( |
|
|
return Container( |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: Colors.white, |
|
|
color: Get.isDarkMode ? AppColors.cardBackground : Colors.white, |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
boxShadow: [ |
|
|
boxShadow: [ |
|
|
BoxShadow( |
|
|
BoxShadow( |
|
|
color: Colors.black.withOpacity(0.05), |
|
|
color: Get.isDarkMode |
|
|
|
|
|
? Colors.black.withOpacity(0.2) |
|
|
|
|
|
: Colors.black.withOpacity(0.05), |
|
|
blurRadius: 10, |
|
|
blurRadius: 10, |
|
|
offset: const Offset(0, 2), |
|
|
offset: const Offset(0, 2), |
|
|
), |
|
|
), |
|
|
@ -557,7 +588,8 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 16.sp, |
|
|
fontSize: 16.sp, |
|
|
fontWeight: FontWeight.w600, |
|
|
fontWeight: FontWeight.w600, |
|
|
color: Colors.black87, |
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? AppColors.textPrimary : Colors.black87, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
TextButton( |
|
|
TextButton( |
|
|
@ -573,7 +605,11 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
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(fontSize: 14.sp, color: Colors.grey[600]), |
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
|
color: Get.isDarkMode |
|
|
|
|
|
? AppColors.textSecondary |
|
|
|
|
|
: Colors.grey[600]), |
|
|
), |
|
|
), |
|
|
) |
|
|
) |
|
|
else |
|
|
else |
|
|
@ -593,8 +629,10 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
child: Container( |
|
|
child: Container( |
|
|
width: 40.w, |
|
|
width: 40.w, |
|
|
height: 40.w, |
|
|
height: 40.w, |
|
|
color: Colors.grey[200], |
|
|
color: |
|
|
child: Icon(Icons.image, color: Colors.grey[400]), |
|
|
Get.isDarkMode ? Colors.white.withOpacity(0.05) : Colors.grey[200], |
|
|
|
|
|
child: Icon(Icons.image, |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.grey[400]), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
title: Text( |
|
|
title: Text( |
|
|
@ -605,11 +643,17 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
), |
|
|
), |
|
|
subtitle: Text( |
|
|
subtitle: Text( |
|
|
'${item.sourceLanguageName} → ${item.targetLanguageName}', |
|
|
'${item.sourceLanguageName} → ${item.targetLanguageName}', |
|
|
style: TextStyle(fontSize: 12.sp, color: Colors.grey[600]), |
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? AppColors.textSecondary : Colors.grey[600]), |
|
|
), |
|
|
), |
|
|
trailing: Text( |
|
|
trailing: Text( |
|
|
_formatTime(item.timestamp), |
|
|
_formatTime(item.timestamp), |
|
|
style: TextStyle(fontSize: 12.sp, color: Colors.grey[500]), |
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? Colors.white54 : Colors.grey[500]), |
|
|
), |
|
|
), |
|
|
onTap: () => _showHistoryDetail(item), |
|
|
onTap: () => _showHistoryDetail(item), |
|
|
); |
|
|
); |
|
|
@ -620,7 +664,7 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
Container( |
|
|
Container( |
|
|
height: 600.h, |
|
|
height: 600.h, |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: Colors.white, |
|
|
color: Get.isDarkMode ? AppColors.cardBackground : Colors.white, |
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20.r)), |
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20.r)), |
|
|
), |
|
|
), |
|
|
child: Column( |
|
|
child: Column( |
|
|
@ -632,12 +676,18 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
children: [ |
|
|
children: [ |
|
|
Text( |
|
|
Text( |
|
|
'translationHistory'.tr, // 翻译键代表的中文文本内容 |
|
|
'translationHistory'.tr, // 翻译键代表的中文文本内容 |
|
|
style: |
|
|
style: TextStyle( |
|
|
TextStyle(fontSize: 18.sp, fontWeight: FontWeight.bold), |
|
|
fontSize: 18.sp, |
|
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
|
color: Get.isDarkMode |
|
|
|
|
|
? AppColors.textPrimary |
|
|
|
|
|
: null), |
|
|
), |
|
|
), |
|
|
IconButton( |
|
|
IconButton( |
|
|
onPressed: () => Get.back(), |
|
|
onPressed: () => Get.back(), |
|
|
icon: const Icon(Icons.close), |
|
|
icon: Icon(Icons.close, |
|
|
|
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? AppColors.textPrimary : null), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -649,8 +699,11 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
return Center( |
|
|
return Center( |
|
|
child: Text( |
|
|
child: Text( |
|
|
'noTranslationHistory'.tr, // 翻译键代表的中文文本内容 |
|
|
'noTranslationHistory'.tr, // 翻译键代表的中文文本内容 |
|
|
style: |
|
|
style: TextStyle( |
|
|
TextStyle(fontSize: 16.sp, color: Colors.grey[600]), |
|
|
fontSize: 16.sp, |
|
|
|
|
|
color: Get.isDarkMode |
|
|
|
|
|
? AppColors.textSecondary |
|
|
|
|
|
: Colors.grey[600]), |
|
|
), |
|
|
), |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
@ -705,25 +758,44 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
void _showSettingsDialog() { |
|
|
void _showSettingsDialog() { |
|
|
Get.dialog( |
|
|
Get.dialog( |
|
|
AlertDialog( |
|
|
AlertDialog( |
|
|
title: const Text('设置'), |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
|
|
|
title: Text('设置', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
content: Column( |
|
|
content: Column( |
|
|
mainAxisSize: MainAxisSize.min, |
|
|
mainAxisSize: MainAxisSize.min, |
|
|
children: [ |
|
|
children: [ |
|
|
ListTile( |
|
|
ListTile( |
|
|
leading: const Icon(Icons.photo_size_select_actual), |
|
|
leading: Icon(Icons.photo_size_select_actual, |
|
|
title: const Text('图片质量'), |
|
|
color: Get.isDarkMode ? Colors.white : null), |
|
|
|
|
|
title: Text('图片质量', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
subtitle: |
|
|
subtitle: |
|
|
Obx(() => Text('当前: ${controller.imageQuality.value}%')), |
|
|
Obx(() => Text('当前: ${controller.imageQuality.value}%', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode |
|
|
|
|
|
? Colors.white70 |
|
|
|
|
|
: Colors.black54))), |
|
|
onTap: () { |
|
|
onTap: () { |
|
|
Get.back(); |
|
|
Get.back(); |
|
|
_showImageQualityDialog(); |
|
|
_showImageQualityDialog(); |
|
|
}, |
|
|
}, |
|
|
), |
|
|
), |
|
|
ListTile( |
|
|
ListTile( |
|
|
leading: const Icon(Icons.photo_size_select_large), |
|
|
leading: Icon(Icons.photo_size_select_large, |
|
|
title: const Text('最大尺寸'), |
|
|
color: Get.isDarkMode ? Colors.white : null), |
|
|
|
|
|
title: Text('最大尺寸', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
subtitle: |
|
|
subtitle: |
|
|
Obx(() => Text('当前: ${controller.maxImageSize.value}px')), |
|
|
Obx(() => Text('当前: ${controller.maxImageSize.value}px', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode |
|
|
|
|
|
? Colors.white70 |
|
|
|
|
|
: Colors.black54))), |
|
|
onTap: () { |
|
|
onTap: () { |
|
|
Get.back(); |
|
|
Get.back(); |
|
|
_showImageSizeDialog(); |
|
|
_showImageSizeDialog(); |
|
|
@ -734,7 +806,9 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
actions: [ |
|
|
actions: [ |
|
|
TextButton( |
|
|
TextButton( |
|
|
onPressed: () => Get.back(), |
|
|
onPressed: () => Get.back(), |
|
|
child: const Text('关闭'), |
|
|
child: Text('关闭', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -744,11 +818,17 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
void _showImageQualityDialog() { |
|
|
void _showImageQualityDialog() { |
|
|
Get.dialog( |
|
|
Get.dialog( |
|
|
AlertDialog( |
|
|
AlertDialog( |
|
|
title: const Text('设置图片质量'), |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
|
|
|
title: Text('设置图片质量', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
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('当前质量: ${controller.imageQuality.value}%', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
Slider( |
|
|
Slider( |
|
|
value: controller.imageQuality.value.toDouble(), |
|
|
value: controller.imageQuality.value.toDouble(), |
|
|
min: 50, |
|
|
min: 50, |
|
|
@ -763,7 +843,9 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
actions: [ |
|
|
actions: [ |
|
|
TextButton( |
|
|
TextButton( |
|
|
onPressed: () => Get.back(), |
|
|
onPressed: () => Get.back(), |
|
|
child: const Text('确定'), |
|
|
child: Text('确定', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -774,7 +856,10 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
final sizes = [1280, 1920, 2560, 3840]; |
|
|
final sizes = [1280, 1920, 2560, 3840]; |
|
|
Get.dialog( |
|
|
Get.dialog( |
|
|
AlertDialog( |
|
|
AlertDialog( |
|
|
title: const Text('设置最大尺寸'), |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
|
|
|
title: Text('设置最大尺寸', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
content: Column( |
|
|
content: Column( |
|
|
mainAxisSize: MainAxisSize.min, |
|
|
mainAxisSize: MainAxisSize.min, |
|
|
children: sizes |
|
|
children: sizes |
|
|
@ -794,7 +879,9 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
actions: [ |
|
|
actions: [ |
|
|
TextButton( |
|
|
TextButton( |
|
|
onPressed: () => Get.back(), |
|
|
onPressed: () => Get.back(), |
|
|
child: const Text('取消'), |
|
|
child: Text('取消', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -804,19 +891,26 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
void _showClearHistoryDialog() { |
|
|
void _showClearHistoryDialog() { |
|
|
Get.dialog( |
|
|
Get.dialog( |
|
|
AlertDialog( |
|
|
AlertDialog( |
|
|
title: const Text('清空历史'), |
|
|
backgroundColor: Get.isDarkMode ? Colors.grey[900] : Colors.white, |
|
|
content: const Text('确定要清空所有翻译历史吗?此操作不可撤销。'), |
|
|
title: Text('清空历史', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white : Colors.black87)), |
|
|
|
|
|
content: Text('确定要清空所有翻译历史吗?此操作不可撤销。', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
actions: [ |
|
|
actions: [ |
|
|
TextButton( |
|
|
TextButton( |
|
|
onPressed: () => Get.back(), |
|
|
onPressed: () => Get.back(), |
|
|
child: const Text('取消'), |
|
|
child: Text('取消', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white70 : Colors.black54)), |
|
|
), |
|
|
), |
|
|
TextButton( |
|
|
TextButton( |
|
|
onPressed: () { |
|
|
onPressed: () { |
|
|
controller.clearHistory(); |
|
|
controller.clearHistory(); |
|
|
Get.back(); |
|
|
Get.back(); |
|
|
}, |
|
|
}, |
|
|
child: Text('确定', style: TextStyle(color: Colors.red)), |
|
|
child: Text('确定', style: TextStyle(color: AppColors.error)), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -829,9 +923,11 @@ 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: Colors.grey[100], |
|
|
color: |
|
|
|
|
|
Get.isDarkMode ? AppColors.cardBackground : Colors.grey[100], |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
border: Border.all(color: Colors.grey[300]!), |
|
|
border: |
|
|
|
|
|
Border.all(color: Get.isDarkMode ? Colors.white12 : Colors.grey[300]!), |
|
|
), |
|
|
), |
|
|
child: file == null |
|
|
child: file == null |
|
|
? Center( |
|
|
? Center( |
|
|
@ -839,11 +935,16 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
children: [ |
|
|
children: [ |
|
|
Icon(Icons.image_outlined, |
|
|
Icon(Icons.image_outlined, |
|
|
size: 48.sp, color: Colors.grey[400]), |
|
|
size: 48.sp, |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white54 : Colors.grey[400]), |
|
|
SizedBox(height: 8.h), |
|
|
SizedBox(height: 8.h), |
|
|
Text( |
|
|
Text( |
|
|
'请选择图片', |
|
|
'请选择图片', |
|
|
style: TextStyle(fontSize: 14.sp, color: Colors.grey[600]), |
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
|
color: Get.isDarkMode |
|
|
|
|
|
? AppColors.textSecondary |
|
|
|
|
|
: Colors.grey[600]), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -868,7 +969,10 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
Text( |
|
|
Text( |
|
|
'图片加载失败', |
|
|
'图片加载失败', |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 14.sp, color: Colors.grey[600]), |
|
|
fontSize: 14.sp, |
|
|
|
|
|
color: Get.isDarkMode |
|
|
|
|
|
? AppColors.textSecondary |
|
|
|
|
|
: Colors.grey[600]), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
@ -893,7 +997,8 @@ class PictureTranslationView extends GetView<PictureTranslationController> { |
|
|
padding: EdgeInsets.all(12.w), |
|
|
padding: EdgeInsets.all(12.w), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
border: Border.all(color: Colors.grey.shade300), |
|
|
border: Border.all( |
|
|
|
|
|
color: Get.isDarkMode ? Colors.white12 : Colors.grey.shade300), |
|
|
), |
|
|
), |
|
|
child: Column( |
|
|
child: Column( |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|