|
|
|
@ -24,15 +24,15 @@ class TextTranslationView extends GetView<TextTranslationController> { |
|
|
|
// 语言选择区域 |
|
|
|
_buildLanguageSelector(isDarkMode), |
|
|
|
SizedBox(height: 20.h), |
|
|
|
|
|
|
|
|
|
|
|
// 输入区域 |
|
|
|
_buildInputSection(isDarkMode), |
|
|
|
SizedBox(height: 20.h), |
|
|
|
|
|
|
|
|
|
|
|
// 翻译按钮 |
|
|
|
_buildTranslateButton(isDarkMode), |
|
|
|
SizedBox(height: 20.h), |
|
|
|
|
|
|
|
|
|
|
|
// 翻译结果区域 |
|
|
|
_buildResultSection(isDarkMode), |
|
|
|
], |
|
|
|
@ -49,8 +49,9 @@ class TextTranslationView extends GetView<TextTranslationController> { |
|
|
|
elevation: 0, |
|
|
|
leading: IconButton( |
|
|
|
icon: Icon( |
|
|
|
Icons.arrow_back, |
|
|
|
Icons.arrow_back_ios, |
|
|
|
color: isDarkMode ? Colors.white : Colors.black, |
|
|
|
size: 20.sp, |
|
|
|
), |
|
|
|
onPressed: () => Get.back(), |
|
|
|
), |
|
|
|
@ -94,14 +95,15 @@ class TextTranslationView extends GetView<TextTranslationController> { |
|
|
|
children: [ |
|
|
|
// 源语言选择 |
|
|
|
Obx(() => _buildLanguageButton( |
|
|
|
label: 'sourceLanguage'.tr, |
|
|
|
selectedLanguage: controller.sourceLanguageChineseName.value, |
|
|
|
onTap: () => controller.showLanguageSelector(isSourceLanguage: true), |
|
|
|
isDarkMode: isDarkMode, |
|
|
|
)), |
|
|
|
|
|
|
|
label: 'sourceLanguage'.tr, |
|
|
|
selectedLanguage: controller.sourceLanguageChineseName.value, |
|
|
|
onTap: () => |
|
|
|
controller.showLanguageSelector(isSourceLanguage: true), |
|
|
|
isDarkMode: isDarkMode, |
|
|
|
)), |
|
|
|
|
|
|
|
SizedBox(height: 12.h), |
|
|
|
|
|
|
|
|
|
|
|
// 交换语言按钮 |
|
|
|
Center( |
|
|
|
child: GestureDetector( |
|
|
|
@ -121,16 +123,17 @@ class TextTranslationView extends GetView<TextTranslationController> { |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
|
|
|
|
SizedBox(height: 12.h), |
|
|
|
|
|
|
|
|
|
|
|
// 目标语言选择 |
|
|
|
Obx(() => _buildLanguageButton( |
|
|
|
label: 'targetLanguage'.tr, |
|
|
|
selectedLanguage: controller.targetLanguageChineseName.value, |
|
|
|
onTap: () => controller.showLanguageSelector(isSourceLanguage: false), |
|
|
|
isDarkMode: isDarkMode, |
|
|
|
)), |
|
|
|
label: 'targetLanguage'.tr, |
|
|
|
selectedLanguage: controller.targetLanguageChineseName.value, |
|
|
|
onTap: () => |
|
|
|
controller.showLanguageSelector(isSourceLanguage: false), |
|
|
|
isDarkMode: isDarkMode, |
|
|
|
)), |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
@ -255,50 +258,53 @@ class TextTranslationView extends GetView<TextTranslationController> { |
|
|
|
/// 构建翻译按钮 |
|
|
|
Widget _buildTranslateButton(bool isDarkMode) { |
|
|
|
return Obx(() => SizedBox( |
|
|
|
width: double.infinity, |
|
|
|
child: ElevatedButton( |
|
|
|
onPressed: controller.isTranslating.value ? null : controller.translateText, |
|
|
|
style: ElevatedButton.styleFrom( |
|
|
|
backgroundColor: Colors.blue, |
|
|
|
foregroundColor: Colors.white, |
|
|
|
padding: EdgeInsets.symmetric(vertical: 16.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
), |
|
|
|
elevation: 0, |
|
|
|
disabledBackgroundColor: Colors.grey, |
|
|
|
), |
|
|
|
child: controller.isTranslating.value |
|
|
|
? Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
SizedBox( |
|
|
|
width: 20.w, |
|
|
|
height: 20.w, |
|
|
|
child: const CircularProgressIndicator( |
|
|
|
strokeWidth: 2, |
|
|
|
valueColor: AlwaysStoppedAnimation<Color>(Colors.white), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(width: 12.w), |
|
|
|
Text( |
|
|
|
'translating'.tr, |
|
|
|
width: double.infinity, |
|
|
|
child: ElevatedButton( |
|
|
|
onPressed: controller.isTranslating.value |
|
|
|
? null |
|
|
|
: controller.translateText, |
|
|
|
style: ElevatedButton.styleFrom( |
|
|
|
backgroundColor: Colors.blue, |
|
|
|
foregroundColor: Colors.white, |
|
|
|
padding: EdgeInsets.symmetric(vertical: 16.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
), |
|
|
|
elevation: 0, |
|
|
|
disabledBackgroundColor: Colors.grey, |
|
|
|
), |
|
|
|
child: controller.isTranslating.value |
|
|
|
? Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
SizedBox( |
|
|
|
width: 20.w, |
|
|
|
height: 20.w, |
|
|
|
child: const CircularProgressIndicator( |
|
|
|
strokeWidth: 2, |
|
|
|
valueColor: |
|
|
|
AlwaysStoppedAnimation<Color>(Colors.white), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(width: 12.w), |
|
|
|
Text( |
|
|
|
'translating'.tr, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
) |
|
|
|
: Text( |
|
|
|
'translate'.tr, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
) |
|
|
|
: Text( |
|
|
|
'translate'.tr, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
)); |
|
|
|
), |
|
|
|
)); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建翻译结果区域 |
|
|
|
@ -339,7 +345,8 @@ class TextTranslationView extends GetView<TextTranslationController> { |
|
|
|
GestureDetector( |
|
|
|
onTap: controller.copyResult, |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 6.h), |
|
|
|
padding: |
|
|
|
EdgeInsets.symmetric(horizontal: 12.w, vertical: 6.h), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: Colors.blue.withOpacity(0.1), |
|
|
|
borderRadius: BorderRadius.circular(6.r), |
|
|
|
|