fix:增加添加锁时选择语音包的页面
This commit is contained in:
parent
b2952b3c72
commit
4045adf0b2
@ -1159,5 +1159,6 @@
|
|||||||
"请确认后再继续": "Please confirm before continuing",
|
"请确认后再继续": "Please confirm before continuing",
|
||||||
"需要相机权限": "Camera permission required",
|
"需要相机权限": "Camera permission required",
|
||||||
"此功能的开启和关闭只能在锁附近通过手机蓝牙进行": "The activation and deactivation of this feature can only be done through Bluetooth on the phone near the lock",
|
"此功能的开启和关闭只能在锁附近通过手机蓝牙进行": "The activation and deactivation of this feature can only be done through Bluetooth on the phone near the lock",
|
||||||
"网关添加成功": "Gateway added successfully"
|
"网关添加成功": "Gateway added successfully",
|
||||||
|
"语音包设置": "Voice packet settings"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1101,7 +1101,7 @@
|
|||||||
"支持的国家": "支持的国家",
|
"支持的国家": "支持的国家",
|
||||||
"支持的国家值": "美国、加拿大、英国、澳大利亚、印度、德国、法国、意大利、西班牙、日本",
|
"支持的国家值": "美国、加拿大、英国、澳大利亚、印度、德国、法国、意大利、西班牙、日本",
|
||||||
"操作流程": "操作流程",
|
"操作流程": "操作流程",
|
||||||
"操作流程值":"1 用智能锁APP添加锁和网关\n\n2 在APP里开启锁的远程开锁功能(这个功能默认是关闭的)。如果没有这个选项,则锁不支持Alexa \n\n3 在Alexa中添加Skill,并用智能锁APP的账号和密码进行授权。授权成功后就可以发现账号下的设备\n\n4 在Alexa app里找到锁,开启语音开锁的功能,并设置语言密码\n\n5 可以通过Alexa操作锁了",
|
"操作流程值": "1 用智能锁APP添加锁和网关\n\n2 在APP里开启锁的远程开锁功能(这个功能默认是关闭的)。如果没有这个选项,则锁不支持Alexa \n\n3 在Alexa中添加Skill,并用智能锁APP的账号和密码进行授权。授权成功后就可以发现账号下的设备\n\n4 在Alexa app里找到锁,开启语音开锁的功能,并设置语言密码\n\n5 可以通过Alexa操作锁了",
|
||||||
"Google Home": "Google Home",
|
"Google Home": "Google Home",
|
||||||
"Action name": "Action name",
|
"Action name": "Action name",
|
||||||
"ScienerSmart": "ScienerSmart",
|
"ScienerSmart": "ScienerSmart",
|
||||||
@ -1164,5 +1164,6 @@
|
|||||||
"请确认后再继续": "请确认后再继续",
|
"请确认后再继续": "请确认后再继续",
|
||||||
"需要相机权限": "需要相机权限",
|
"需要相机权限": "需要相机权限",
|
||||||
"此功能的开启和关闭只能在锁附近通过手机蓝牙进行": "此功能的开启和关闭只能在锁附近通过手机蓝牙进行",
|
"此功能的开启和关闭只能在锁附近通过手机蓝牙进行": "此功能的开启和关闭只能在锁附近通过手机蓝牙进行",
|
||||||
"网关添加成功": "网关添加成功"
|
"网关添加成功": "网关添加成功",
|
||||||
|
"语音包设置": "语音包设置",
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1166,5 +1166,6 @@
|
|||||||
"请确认后再继续": "请确认后再继续",
|
"请确认后再继续": "请确认后再继续",
|
||||||
"需要相机权限": "需要相机权限",
|
"需要相机权限": "需要相机权限",
|
||||||
"一键登录": "一键登录",
|
"一键登录": "一键登录",
|
||||||
"网关添加成功": "网关添加成功"
|
"网关添加成功": "网关添加成功",
|
||||||
|
"语音包设置": "语音包设置"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,10 +79,6 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
|
|||||||
// await sendGetDeviceModelBleMessage();
|
// await sendGetDeviceModelBleMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void onClose() {
|
|
||||||
_replySubscription?.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 获取列表
|
/// 获取列表
|
||||||
initList() async {
|
initList() async {
|
||||||
@ -185,7 +181,10 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
|
|||||||
.packageData(),
|
.packageData(),
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState ==
|
} else if (deviceConnectionState ==
|
||||||
BluetoothConnectionState.disconnected) {}
|
BluetoothConnectionState.disconnected) {
|
||||||
|
dismissEasyLoading();
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +334,6 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() async {
|
void dispose() async {
|
||||||
super.dispose();
|
|
||||||
await _replySubscription?.cancel();
|
await _replySubscription?.cancel();
|
||||||
_replySubscription = null;
|
_replySubscription = null;
|
||||||
await BlueManage().disconnect();
|
await BlueManage().disconnect();
|
||||||
@ -347,5 +345,22 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
|
|||||||
state.voiceSubcontractingIndex = 0;
|
state.voiceSubcontractingIndex = 0;
|
||||||
state.voiceSubcontractingCount = 0;
|
state.voiceSubcontractingCount = 0;
|
||||||
state.data = null;
|
state.data = null;
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() async {
|
||||||
|
await _replySubscription?.cancel();
|
||||||
|
_replySubscription = null;
|
||||||
|
await BlueManage().disconnect();
|
||||||
|
dismissEasyLoading();
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
EasyLoading.dismiss();
|
||||||
|
// 清理分包相关状态
|
||||||
|
state.progress.value = 0.0;
|
||||||
|
state.voiceSubcontractingIndex = 0;
|
||||||
|
state.voiceSubcontractingCount = 0;
|
||||||
|
state.data = null;
|
||||||
|
super.onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,7 +60,38 @@ class _SpeechLanguageSettingsPageState
|
|||||||
return Obx(
|
return Obx(
|
||||||
() => SingleChildScrollView(
|
() => SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: _buildList(),
|
children: [
|
||||||
|
// Container(
|
||||||
|
// width: 1.sw,
|
||||||
|
// decoration: BoxDecoration(color: Colors.white),
|
||||||
|
// child: Column(
|
||||||
|
// children: [
|
||||||
|
// RadioListTile(
|
||||||
|
// title: Text("男声".tr),
|
||||||
|
// value: 1,
|
||||||
|
// groupValue: state.selectedValue.value,
|
||||||
|
// onChanged: (value) {
|
||||||
|
// state.selectedValue.value = int.parse(value.toString());
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// RadioListTile(
|
||||||
|
// title: Text("女声".tr),
|
||||||
|
// value: 2,
|
||||||
|
// groupValue: state.selectedValue.value,
|
||||||
|
// onChanged: (value) {
|
||||||
|
// state.selectedValue.value = int.parse(value.toString());
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
SizedBox(
|
||||||
|
height: 8.h,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: _buildList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -40,5 +40,7 @@ class SpeechLanguageSettingsState {
|
|||||||
// 分包发送进度(0.0~1.0)
|
// 分包发送进度(0.0~1.0)
|
||||||
RxDouble progress = 0.0.obs;
|
RxDouble progress = 0.0.obs;
|
||||||
|
|
||||||
|
RxInt selectedValue = 1.obs;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,10 +2,13 @@ import 'dart:async';
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/appRouters.dart';
|
||||||
|
import 'package:star_lock/app_settings/app_colors.dart';
|
||||||
import 'package:star_lock/blue/blue_manage.dart';
|
import 'package:star_lock/blue/blue_manage.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_getDeviceModel.dart';
|
import 'package:star_lock/blue/io_protocol/io_getDeviceModel.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_voicePackageConfigure.dart';
|
import 'package:star_lock/blue/io_protocol/io_voicePackageConfigure.dart';
|
||||||
@ -19,12 +22,14 @@ import 'package:star_lock/mine/addLock/lock_voice_setting/lock_voice_setting_sta
|
|||||||
import 'package:star_lock/network/api_repository.dart';
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
import 'package:star_lock/tools/eventBusEventManage.dart';
|
import 'package:star_lock/tools/eventBusEventManage.dart';
|
||||||
|
import 'package:star_lock/tools/showTipView.dart';
|
||||||
import 'package:star_lock/tools/storage.dart';
|
import 'package:star_lock/tools/storage.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
class LockVoiceSettingLogic extends BaseGetXController {
|
class LockVoiceSettingLogic extends BaseGetXController {
|
||||||
LockVoiceSettingState state = LockVoiceSettingState();
|
LockVoiceSettingState state = LockVoiceSettingState();
|
||||||
StreamSubscription<Reply>? _replySubscription;
|
StreamSubscription<Reply>? _replySubscription;
|
||||||
|
bool _isThrottled = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() async {
|
void onInit() async {
|
||||||
@ -41,33 +46,81 @@ class LockVoiceSettingLogic extends BaseGetXController {
|
|||||||
} else if (reply is VoicePackageConfigureProcessReply) {
|
} else if (reply is VoicePackageConfigureProcessReply) {
|
||||||
_handlerVoicePackageConfigureProcess(reply);
|
_handlerVoicePackageConfigureProcess(reply);
|
||||||
} else if (reply is VoicePackageConfigureConfirmationReply) {
|
} else if (reply is VoicePackageConfigureConfirmationReply) {
|
||||||
final PassthroughItem item =
|
handleVoiceConfigureThrottled(reply);
|
||||||
state.languages[state.selectPassthroughListIndex.value];
|
|
||||||
final timbre = item.timbres[state.selectLanguageIndex.value];
|
|
||||||
final LoginEntity entity =
|
|
||||||
await ApiRepository.to.settingCurrentVoiceTimbre(
|
|
||||||
data: {
|
|
||||||
'lang': item.lang,
|
|
||||||
'timbre': timbre.timbre,
|
|
||||||
},
|
|
||||||
lockId: state.lockSetInfoData.value.lockId!,
|
|
||||||
);
|
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
|
||||||
showSuccess('设置成功'.tr, something: () {
|
|
||||||
state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre
|
|
||||||
?.lang = item.lang;
|
|
||||||
state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre
|
|
||||||
?.timbre = timbre.timbre;
|
|
||||||
eventBus.fire(
|
|
||||||
PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dismissEasyLoading();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await sendGetDeviceModelBleMessage();
|
await sendGetDeviceModelBleMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleVoiceConfigureThrottled(
|
||||||
|
VoicePackageConfigureConfirmationReply reply,
|
||||||
|
) {
|
||||||
|
if (_isThrottled) return;
|
||||||
|
|
||||||
|
_isThrottled = true;
|
||||||
|
|
||||||
|
// 执行你的逻辑
|
||||||
|
_executeLogic(reply);
|
||||||
|
|
||||||
|
// 设置节流时间(比如 1 秒)
|
||||||
|
Future.delayed(Duration(seconds: 1), () {
|
||||||
|
_isThrottled = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _executeLogic(
|
||||||
|
VoicePackageConfigureConfirmationReply reply) async {
|
||||||
|
final PassthroughItem item =
|
||||||
|
state.languages[state.selectPassthroughListIndex.value];
|
||||||
|
final timbre = item.timbres[state.selectLanguageIndex.value];
|
||||||
|
final LoginEntity entity = await ApiRepository.to.settingCurrentVoiceTimbre(
|
||||||
|
data: {
|
||||||
|
'lang': item.lang,
|
||||||
|
'timbre': timbre.timbre,
|
||||||
|
},
|
||||||
|
lockId: state.lockSetInfoData.value.lockId!,
|
||||||
|
);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
showCupertinoDialog(
|
||||||
|
context: Get.context!,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return CupertinoAlertDialog(
|
||||||
|
title: Text('语音设置'.tr),
|
||||||
|
content: Text('语音设置成功'.tr),
|
||||||
|
actions: <Widget>[
|
||||||
|
CupertinoDialogAction(
|
||||||
|
child: Text(
|
||||||
|
'取消'.tr,
|
||||||
|
style: TextStyle(color: AppColors.mainColor),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
CupertinoDialogAction(
|
||||||
|
child: Text(
|
||||||
|
'返回主页'.tr,
|
||||||
|
style: TextStyle(color: AppColors.mainColor),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
state.lockSetInfoData.value.lockSettingInfo
|
||||||
|
?.currentVoiceTimbre?.lang = item.lang;
|
||||||
|
state.lockSetInfoData.value.lockSettingInfo
|
||||||
|
?.currentVoiceTimbre?.timbre = timbre.timbre;
|
||||||
|
|
||||||
|
eventBus.fire(PassCurrentLockInformationEvent(
|
||||||
|
state.lockSetInfoData.value));
|
||||||
|
Get.offAllNamed(Routers.starLockMain);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
dismissEasyLoading();
|
||||||
|
}
|
||||||
|
|
||||||
void saveSpeechLanguageSettings() async {
|
void saveSpeechLanguageSettings() async {
|
||||||
// 如果已经开始发送中则不处理保存点击事件
|
// 如果已经开始发送中则不处理保存点击事件
|
||||||
if (state.progress.value > 0) {
|
if (state.progress.value > 0) {
|
||||||
@ -132,7 +185,11 @@ class LockVoiceSettingLogic extends BaseGetXController {
|
|||||||
.packageData(),
|
.packageData(),
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState ==
|
} else if (deviceConnectionState ==
|
||||||
BluetoothConnectionState.disconnected) {}
|
BluetoothConnectionState.disconnected) {
|
||||||
|
dismissEasyLoading();
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
// showBlueConnetctToast();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,14 +366,13 @@ class LockVoiceSettingLogic extends BaseGetXController {
|
|||||||
BluetoothConnectionState.disconnected) {
|
BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
showBlueConnetctToast();
|
// showBlueConnetctToast();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() async {
|
void dispose() async {
|
||||||
super.dispose();
|
|
||||||
await _replySubscription?.cancel();
|
await _replySubscription?.cancel();
|
||||||
_replySubscription = null;
|
_replySubscription = null;
|
||||||
await BlueManage().disconnect();
|
await BlueManage().disconnect();
|
||||||
@ -328,5 +384,23 @@ class LockVoiceSettingLogic extends BaseGetXController {
|
|||||||
state.voiceSubcontractingIndex = 0;
|
state.voiceSubcontractingIndex = 0;
|
||||||
state.voiceSubcontractingCount = 0;
|
state.voiceSubcontractingCount = 0;
|
||||||
state.data = null;
|
state.data = null;
|
||||||
|
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() async {
|
||||||
|
await _replySubscription?.cancel();
|
||||||
|
_replySubscription = null;
|
||||||
|
await BlueManage().disconnect();
|
||||||
|
dismissEasyLoading();
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
EasyLoading.dismiss();
|
||||||
|
// 清理分包相关状态
|
||||||
|
state.progress.value = 0.0;
|
||||||
|
state.voiceSubcontractingIndex = 0;
|
||||||
|
state.voiceSubcontractingCount = 0;
|
||||||
|
state.data = null;
|
||||||
|
super.onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class _LockVoiceSettingState extends State<LockVoiceSetting> {
|
|||||||
Get.offAllNamed(Routers.starLockMain);
|
Get.offAllNamed(Routers.starLockMain);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'跳过',
|
'跳过'.tr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 24.sp,
|
fontSize: 24.sp,
|
||||||
|
|||||||
@ -84,17 +84,17 @@ class _SelectLockTypePageState extends State<SelectLockTypePage>
|
|||||||
arguments: <String, int>{'getLockType': 1});
|
arguments: <String, int>{'getLockType': 1});
|
||||||
}),
|
}),
|
||||||
// if (!F.isLite)
|
// if (!F.isLite)
|
||||||
lockTypeItem('images/lockType/lockType_NFCLock.png', 'NFC无源锁'.tr, () {
|
lockTypeItem('images/lockType/lockType_NFCLock.png', 'NFC无源锁'.tr, () {
|
||||||
CommonDataManage().seletLockType = 2;
|
CommonDataManage().seletLockType = 2;
|
||||||
// Navigator.pushNamed(context, Routers.addLockPage);
|
// Navigator.pushNamed(context, Routers.addLockPage);
|
||||||
logic.getNearByLimits();
|
logic.getNearByLimits();
|
||||||
}),
|
}),
|
||||||
// if (!F.isLite)
|
// if (!F.isLite)
|
||||||
lockTypeItem('images/lockType/lockType_padlock.png', '挂锁'.tr, () {
|
lockTypeItem('images/lockType/lockType_padlock.png', '挂锁'.tr, () {
|
||||||
CommonDataManage().seletLockType = 3;
|
CommonDataManage().seletLockType = 3;
|
||||||
// Navigator.pushNamed(context, Routers.addLockPage);
|
// Navigator.pushNamed(context, Routers.addLockPage);
|
||||||
logic.getNearByLimits();
|
logic.getNearByLimits();
|
||||||
}),
|
}),
|
||||||
lockTypeItem('images/lockType/lockType_safeLock.png', '保险箱锁'.tr, () {
|
lockTypeItem('images/lockType/lockType_safeLock.png', '保险箱锁'.tr, () {
|
||||||
CommonDataManage().seletLockType = 4;
|
CommonDataManage().seletLockType = 4;
|
||||||
Navigator.pushNamed(context, Routers.addLockPage,
|
Navigator.pushNamed(context, Routers.addLockPage,
|
||||||
@ -223,9 +223,16 @@ class _SelectLockTypePageState extends State<SelectLockTypePage>
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(lockTypeTitle,
|
Text(
|
||||||
style: TextStyle(
|
lockTypeTitle,
|
||||||
fontSize: 22.sp, color: AppColors.blackColor)),
|
maxLines: 2, // 最大行数
|
||||||
|
overflow: TextOverflow.ellipsis, // 超出显示省略号
|
||||||
|
softWrap: true, // 自动换行
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22.sp,
|
||||||
|
color: AppColors.blackColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user