|
|
|
@ -467,134 +467,122 @@ class TranslationView extends GetView<TranslationController> { |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
child: Obx(() { |
|
|
|
return Column( |
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
children: [ |
|
|
|
// 原有的按钮区域 |
|
|
|
if (controller.currentMode.value == 'faceToFace') |
|
|
|
Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
// 耳机图标按钮 (说话者1)-显示源语言 |
|
|
|
Obx(() => _buildHoldToTalkButton( |
|
|
|
isDarkMode: isDarkMode, |
|
|
|
speakerId: 1, |
|
|
|
activeSpeaker: controller.activeSpeaker.value, |
|
|
|
icon: Icons.mic_none, |
|
|
|
label: controller.sourceLanguage.value |
|
|
|
.split(' ')[0] |
|
|
|
.tr, // 源语言名称 |
|
|
|
)), |
|
|
|
SizedBox(width: 16.w), |
|
|
|
// 手机图标按钮 (说话者2)-显示目标语言 |
|
|
|
Obx(() => _buildHoldToTalkButton( |
|
|
|
isDarkMode: isDarkMode, |
|
|
|
speakerId: 2, |
|
|
|
activeSpeaker: controller.activeSpeaker.value, |
|
|
|
icon: Icons.mic_none, |
|
|
|
label: controller.targetLanguage.value |
|
|
|
.split(' ')[0] |
|
|
|
.tr, // 目标语言名称 |
|
|
|
)), |
|
|
|
], |
|
|
|
) |
|
|
|
else |
|
|
|
Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
// 主要控制按钮 - 开始/暂停语音识别 |
|
|
|
Obx(() { |
|
|
|
final isRecognizing = controller.isRecognizing.value; |
|
|
|
return GestureDetector( |
|
|
|
onTap: () { |
|
|
|
if (isRecognizing) { |
|
|
|
controller.stopAll(); |
|
|
|
} else { |
|
|
|
controller.startRecognition(); |
|
|
|
} |
|
|
|
}, |
|
|
|
child: Container( |
|
|
|
width: 60.w, |
|
|
|
height: 60.w, |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: isRecognizing |
|
|
|
? (isDarkMode ? Colors.red[700] : Colors.red) |
|
|
|
: (isDarkMode ? AppColors.primary : Colors.blue), |
|
|
|
shape: BoxShape.circle, |
|
|
|
), |
|
|
|
child: Icon( |
|
|
|
isRecognizing ? Icons.pause : Icons.play_arrow, |
|
|
|
color: Colors.white, |
|
|
|
size: 30.sp, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
}), |
|
|
|
], |
|
|
|
), |
|
|
|
child: Column( |
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
children: [ |
|
|
|
// 原有的按钮区域 |
|
|
|
Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
// 主要控制按钮 - 开始/暂停语音识别 |
|
|
|
Obx(() { |
|
|
|
final isRecognizing = controller.isRecognizing.value; |
|
|
|
final isPreparing = controller.isPreparing.value; |
|
|
|
return GestureDetector( |
|
|
|
onTap: () { |
|
|
|
if (isRecognizing) { |
|
|
|
controller.stopAll(); |
|
|
|
} else { |
|
|
|
controller.startRecognition(); |
|
|
|
} |
|
|
|
}, |
|
|
|
child: AnimatedContainer( |
|
|
|
duration: const Duration(milliseconds: 300), |
|
|
|
curve: Curves.easeInOut, |
|
|
|
width: 60.w, |
|
|
|
height: 60.w, |
|
|
|
transform: isPreparing |
|
|
|
? (Matrix4.identity()..scale(1.08)) |
|
|
|
: Matrix4.identity(), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: isRecognizing |
|
|
|
? (isDarkMode ? Colors.red[700] : Colors.red) |
|
|
|
: (isDarkMode ? AppColors.primary : Colors.blue), |
|
|
|
shape: BoxShape.circle, |
|
|
|
boxShadow: isPreparing |
|
|
|
? [ |
|
|
|
BoxShadow( |
|
|
|
color: (isDarkMode |
|
|
|
? AppColors.primary |
|
|
|
: Colors.blue) |
|
|
|
.withOpacity(0.5), |
|
|
|
blurRadius: 12, |
|
|
|
spreadRadius: 2, |
|
|
|
) |
|
|
|
] |
|
|
|
: [], |
|
|
|
), |
|
|
|
child: Icon( |
|
|
|
isRecognizing ? Icons.pause : Icons.play_arrow, |
|
|
|
color: Colors.white, |
|
|
|
size: 30.sp, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
}), |
|
|
|
], |
|
|
|
), |
|
|
|
|
|
|
|
// 添加间距 |
|
|
|
//SizedBox(height: 16.h), |
|
|
|
// 添加间距 |
|
|
|
//SizedBox(height: 16.h), |
|
|
|
|
|
|
|
// 语音识别结果显示框 |
|
|
|
// Container( |
|
|
|
// width: double.infinity, |
|
|
|
// padding: EdgeInsets.all(12.w), |
|
|
|
// decoration: BoxDecoration( |
|
|
|
// color: isDarkMode ? Colors.grey[800] : Colors.grey[100], |
|
|
|
// borderRadius: BorderRadius.circular(8.r), |
|
|
|
// border: Border.all( |
|
|
|
// color: isDarkMode ? Colors.grey[600]! : Colors.grey[300]!, |
|
|
|
// width: 1, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// child: Obx(() { |
|
|
|
// // 显示最新的语音识别结果 |
|
|
|
// final recognitionText = controller.latestRecognitionText.value; |
|
|
|
// final detectedLanguage = controller.detectedLanguageCode1.value; |
|
|
|
// 语音识别结果显示框 |
|
|
|
// Container( |
|
|
|
// width: double.infinity, |
|
|
|
// padding: EdgeInsets.all(12.w), |
|
|
|
// decoration: BoxDecoration( |
|
|
|
// color: isDarkMode ? Colors.grey[800] : Colors.grey[100], |
|
|
|
// borderRadius: BorderRadius.circular(8.r), |
|
|
|
// border: Border.all( |
|
|
|
// color: isDarkMode ? Colors.grey[600]! : Colors.grey[300]!, |
|
|
|
// width: 1, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// child: Obx(() { |
|
|
|
// // 显示最新的语音识别结果 |
|
|
|
// final recognitionText = controller.latestRecognitionText.value; |
|
|
|
// final detectedLanguage = controller.detectedLanguageCode1.value; |
|
|
|
|
|
|
|
// return Column( |
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
// children: [ |
|
|
|
// // 标题 |
|
|
|
// Text( |
|
|
|
// '麦头语音识别结果', |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 12.sp, |
|
|
|
// color: isDarkMode ? Colors.grey[400] : Colors.grey[600], |
|
|
|
// fontWeight: FontWeight.w500, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// SizedBox(height: 4.h), |
|
|
|
// // 识别文本 - 这里显示 finalResult1 的内容 |
|
|
|
// Text( |
|
|
|
// recognitionText.isEmpty ? '等待语音输入...' : recognitionText, |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 14.sp, |
|
|
|
// color: isDarkMode ? Colors.white : Colors.black87, |
|
|
|
// height: 1.3, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// // 检测到的语言(如果有) |
|
|
|
// if (detectedLanguage.isNotEmpty) ...[ |
|
|
|
// SizedBox(height: 4.h), |
|
|
|
// Text( |
|
|
|
// '检测语言: $detectedLanguage', |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 10.sp, |
|
|
|
// color: |
|
|
|
// isDarkMode ? Colors.grey[500] : Colors.grey[500], |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ], |
|
|
|
// ], |
|
|
|
// ); |
|
|
|
// }), |
|
|
|
// ), |
|
|
|
], |
|
|
|
); |
|
|
|
}), |
|
|
|
// return Column( |
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
// children: [ |
|
|
|
// // 标题 |
|
|
|
// Text( |
|
|
|
// '麦头语音识别结果', |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 12.sp, |
|
|
|
// color: isDarkMode ? Colors.grey[400] : Colors.grey[600], |
|
|
|
// fontWeight: FontWeight.w500, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// SizedBox(height: 4.h), |
|
|
|
// // 识别文本 - 这里显示 finalResult1 的内容 |
|
|
|
// Text( |
|
|
|
// recognitionText.isEmpty ? '等待语音输入...' : recognitionText, |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 14.sp, |
|
|
|
// color: isDarkMode ? Colors.white : Colors.black87, |
|
|
|
// height: 1.3, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// // 检测到的语言(如果有) |
|
|
|
// if (detectedLanguage.isNotEmpty) ...[ |
|
|
|
// SizedBox(height: 4.h), |
|
|
|
// Text( |
|
|
|
// '检测语言: $detectedLanguage', |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 10.sp, |
|
|
|
// color: |
|
|
|
// isDarkMode ? Colors.grey[500] : Colors.grey[500], |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ], |
|
|
|
// ], |
|
|
|
// ); |
|
|
|
// }), |
|
|
|
// ), |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|