Browse Source

feat(翻译视图): 优化语言显示和麦克风按钮样式

- 将目标语言文本显示改为行布局并添加图标
- 修改麦克风按钮为长条形并显示对应语言名称
- 调整按钮阴影效果和文本溢出处理
newdev_shunjiawei
lxm 1 year ago
parent
commit
686028abf8
  1. 93
      lib/modules/translation/views/translation_view.dart

93
lib/modules/translation/views/translation_view.dart

@ -206,16 +206,39 @@ class TranslationView extends GetView<TranslationController> {
: Colors.grey[100], : Colors.grey[100],
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
), ),
child: Obx(() => Text( child: Obx(() => Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Text(
'${controller.targetLanguage.value.split(' ')[0]}' '${controller.targetLanguage.value.split(' ')[0]}'
.tr, // Just show the English part .tr,
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: isDarkMode ? Colors.white : Colors.black, color:
isDarkMode ? Colors.white : Colors.black,
), ),
textAlign: TextAlign.center, textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
),
),
SizedBox(width: 4.w),
// Icon(
// Icons.public,
// size: 20.sp,
// color: isDarkMode
// ? Colors.white70
// : Colors.grey[600],
// ),
Icon(
Icons.person_pin_circle,
size: 20.sp,
color: isDarkMode
? Colors.white70
: Colors.grey[600],
),
],
)), )),
), ),
), ),
@ -418,23 +441,27 @@ class TranslationView extends GetView<TranslationController> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
// 耳机图标按钮 (说话者1) // 耳机图标按钮 (说话者1)-显示源语言
_buildHoldToTalkButton( Obx(() => _buildHoldToTalkButton(
isDarkMode: isDarkMode, isDarkMode: isDarkMode,
speakerId: 1, speakerId: 1,
activeSpeaker: controller.activeSpeaker.value, activeSpeaker: controller.activeSpeaker.value,
icon: Icons.headset, icon: Icons.mic_none,
label: "headsetUser".tr, label: controller.sourceLanguage.value
), .split(' ')[0]
SizedBox(width: 40.w), .tr, // 源语言名称
// 手机图标按钮 (说话者2) )),
_buildHoldToTalkButton( SizedBox(width: 16.w),
// 手机图标按钮 (说话者2)-显示目标语言
Obx(() => _buildHoldToTalkButton(
isDarkMode: isDarkMode, isDarkMode: isDarkMode,
speakerId: 2, speakerId: 2,
activeSpeaker: controller.activeSpeaker.value, activeSpeaker: controller.activeSpeaker.value,
icon: Icons.phone_android, icon: Icons.mic_none,
label: "phoneUser".tr, label: controller.targetLanguage.value
), .split(' ')[0]
.tr, // 目标语言名称
)),
], ],
) )
else else
@ -569,15 +596,15 @@ class TranslationView extends GetView<TranslationController> {
}, },
child: AnimatedContainer( child: AnimatedContainer(
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
width: 80.w, width: 160.w, // 长条形宽度
height: 80.w, height: 54.h, // 长条形高度
decoration: BoxDecoration( decoration: BoxDecoration(
color: isActive color: isActive
? (isDarkMode ? Colors.green[700] : Colors.green) ? (isDarkMode ? Colors.green[700] : Colors.green)
: (isDisabled : (isDisabled
? (isDarkMode ? Colors.grey[800] : Colors.grey[300]) ? (isDarkMode ? Colors.grey[800] : Colors.grey[300])
: (isDarkMode ? AppColors.primary : Colors.blue)), : (isDarkMode ? AppColors.primary : Colors.blue)),
shape: BoxShape.circle, borderRadius: BorderRadius.circular(25.r), // 圆角长条形
boxShadow: isActive boxShadow: isActive
? [ ? [
BoxShadow( BoxShadow(
@ -586,33 +613,43 @@ class TranslationView extends GetView<TranslationController> {
spreadRadius: 3, spreadRadius: 3,
) )
] ]
: null, : [
BoxShadow(
color: (isDarkMode ? Colors.black : Colors.grey)
.withOpacity(0.2),
blurRadius: 8,
spreadRadius: 1,
offset: Offset(0, 2),
)
],
), ),
child: Column( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Stack( // 左边图标
alignment: Alignment.center,
children: [
// 设备类型图标
Icon( Icon(
icon, icon,
color: isActive color: isActive
? Colors.white ? Colors.white
: Colors.white.withOpacity(isDisabled ? 0.3 : 0.9), : Colors.white.withOpacity(isDisabled ? 0.3 : 0.9),
size: 24.sp, size: 20.sp,
),
],
), ),
SizedBox(height: 4.h), SizedBox(width: 8.w), // 图标和文字间距
Text( // 右边语言名称
Flexible(
child: Text(
label, label,
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: FontWeight.w500,
color: isActive color: isActive
? Colors.white ? Colors.white
: Colors.white.withOpacity(isDisabled ? 0.3 : 0.9), : Colors.white.withOpacity(isDisabled ? 0.3 : 0.9),
), ),
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis, // 防止文本溢出
),
), ),
], ],
), ),

Loading…
Cancel
Save