|
|
@ -1,10 +1,14 @@ |
|
|
|
|
|
// import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|
|
import 'package:get/get.dart'; |
|
|
import 'package:get/get.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import '../../../../routes/app_routes.dart'; |
|
|
import '../../../../routes/app_routes.dart'; |
|
|
|
|
|
import '../../../../data/services/ble_manager.dart'; |
|
|
|
|
|
|
|
|
/// 翻译中间层控制器 |
|
|
/// 翻译中间层控制器 |
|
|
/// 负责管理翻译功能入口的导航和状态 |
|
|
/// 负责管理翻译功能入口的导航和状态 |
|
|
class TranslationMiddlewareController extends GetxController { |
|
|
class TranslationMiddlewareController extends GetxController { |
|
|
|
|
|
final BleManager bleManager = Get.find<BleManager>(); //获取BLE管理器实例 |
|
|
|
|
|
|
|
|
/// 翻译功能选项列表 |
|
|
/// 翻译功能选项列表 |
|
|
final List<TranslationOption> translationOptions = [ |
|
|
final List<TranslationOption> translationOptions = [ |
|
|
TranslationOption( |
|
|
TranslationOption( |
|
|
@ -57,6 +61,15 @@ class TranslationMiddlewareController extends GetxController { |
|
|
|
|
|
|
|
|
/// 导航到指定的翻译功能 |
|
|
/// 导航到指定的翻译功能 |
|
|
void navigateToTranslationFeature(TranslationOption option) { |
|
|
void navigateToTranslationFeature(TranslationOption option) { |
|
|
|
|
|
// 不可用则提示用户连接设备 |
|
|
|
|
|
if (!isOptionEnabled(option)) { |
|
|
|
|
|
// 翻译键代表的中文文本内容 |
|
|
|
|
|
Get.snackbar('connectDevice'.tr, |
|
|
|
|
|
'pleaseConnectDeepSoundDevice'.tr, // 连接设备 / 请连接 Voitrans 设备 |
|
|
|
|
|
snackPosition: SnackPosition.TOP); |
|
|
|
|
|
//EasyLoading.showInfo('connectDevice'.tr); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
Get.toNamed(option.targetRoute, |
|
|
Get.toNamed(option.targetRoute, |
|
|
arguments: {'translationId': option.translationId}); |
|
|
arguments: {'translationId': option.translationId}); |
|
|
} |
|
|
} |
|
|
@ -71,6 +84,16 @@ class TranslationMiddlewareController extends GetxController { |
|
|
// return option.description.tr; |
|
|
// return option.description.tr; |
|
|
return ''; |
|
|
return ''; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// 判断选项是否可用(音视频/通话依赖BLE连接) |
|
|
|
|
|
bool isOptionEnabled(TranslationOption option) { |
|
|
|
|
|
// 当 translationId 为 audioVideo 或 call 时,需要 BLE 已连接 |
|
|
|
|
|
if (option.translationId == 'audioVideo' || |
|
|
|
|
|
option.translationId == 'call') { |
|
|
|
|
|
return bleManager.isConnected; |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// 翻译功能选项数据模型 |
|
|
/// 翻译功能选项数据模型 |
|
|
|