Merge branch 'develop_liyi' into 'canary_release'

fix:调整配网loading卡主的问题

See merge request StarlockTeam/app-starlock!18
This commit is contained in:
李仪 2025-04-10 08:59:06 +00:00
commit 02cae612bb
2 changed files with 61 additions and 99 deletions

View File

@ -62,17 +62,15 @@ class ConfiguringWifiLogic extends BaseGetXController {
peerId: peerId,
);
if (entity.errorCode!.codeIsSuccessful) {
// peerID
StartChartManage().lockNetworkInfo = DeviceNetworkInfo(
wifiName: wifiName,
networkMac: networkMac,
secretKey: secretKey,
peerId: peerId,
);
showToast('配网成功'.tr, something: () async {
// peerID
StartChartManage().lockNetworkInfo = DeviceNetworkInfo(
wifiName: wifiName,
networkMac: networkMac,
secretKey: secretKey,
peerId: peerId,
);
});
_getUploadLockSet();
await _getUploadLockSet();
}
}
@ -106,8 +104,11 @@ class ConfiguringWifiLogic extends BaseGetXController {
// WIFI配网结果
Future<void> _replySenderConfiguringWifiResult(Reply reply) async {
final int status = reply.data[2];
state.sureBtnState.value = 0;
state.isLoading.value = false;
// state.sureBtnState.value = 0;
// loading超时定时器
state.loadingTimer?.cancel();
state.loadingTimer = null;
switch (status) {
case 0x00:
@ -140,15 +141,17 @@ class ConfiguringWifiLogic extends BaseGetXController {
secretKey: secretKey ?? '',
deviceMac: deviceMac ?? '',
networkMac: networkMac ?? '');
break;
default:
//
dismissEasyLoading();
dismissEasyLoading(); // loading
cancelBlueConnetctToastTimer();
if (state.loadingTimer != null) {
state.loadingTimer!.cancel();
state.loadingTimer = null;
}
cancelBlueConnetctToastTimer();
showToast('配网失败'.tr);
state.isLoading.value = false;
break;
@ -164,7 +167,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
// wifi
Future<void> senderConfiguringWifiAction() async {
AppLog.log('开始配网${EasyLoading.isShow}');
EasyLoading.show();
if (state.isLoading.isTrue) {
AppLog.log('正在配网中请勿重复点击');
return;
@ -178,10 +181,10 @@ class ConfiguringWifiLogic extends BaseGetXController {
showToast('请输入WiFi密码'.tr);
return;
}
if (state.sureBtnState.value == 1) {
return;
}
state.sureBtnState.value = 1;
// if (state.sureBtnState.value == 1) {
// return;
// }
// state.sureBtnState.value = 1;
final GetGatewayConfigurationEntity entity =
await ApiRepository.to.getGatewayConfigurationNotLoading(timeout: 60);
@ -218,9 +221,13 @@ class ConfiguringWifiLogic extends BaseGetXController {
//
state.getGatewayConfigurationStr = "{\"userPeerld\": \"$appPeerId\"}";
}
showEasyLoading();
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
state.isLoading.value = false;
});
AppLog.log('获取到配网信息===开始发送蓝牙指令${EasyLoading.isShow}');
//
BlueManage().blueSendData(
BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
@ -233,35 +240,16 @@ class ConfiguringWifiLogic extends BaseGetXController {
} else if (connectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0;
state.isLoading.value = false;
// state.sureBtnState.value = 0;
if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
}
}
},
isAddEquipment: true,
isAddEquipment: false,
);
state.loadingTimer ??= Timer.periodic(Duration(milliseconds: 100), (timer) {
if (!EasyLoading.isShow) {
EasyLoading.show();
}
});
state.isLoading.value = true;
// 15
Future.delayed(const Duration(seconds: 15), () {
if (state.isLoading.isTrue) {
EasyLoading.dismiss();
state.isLoading.value = false;
state.sureBtnState.value = 0;
if (state.loadingTimer != null) {
state.loadingTimer!.cancel();
state.loadingTimer = null;
}
showToast('配网失败'.tr);
}
});
AppLog.log('发送方法执行完毕${EasyLoading.isShow}');
}
//
@ -320,7 +308,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
getWifiLockServiceIpAndPort();
_initReplySubscription();
getDevicesStatusAction();
// getDevicesStatusAction();
}
@override
@ -336,13 +324,13 @@ class ConfiguringWifiLogic extends BaseGetXController {
void _replyGatewayGetStatusReply(GatewayGetStatusReply reply) {
final int status = reply.data[2];
//
dismissEasyLoading();
cancelBlueConnetctToastTimer();
switch (status) {
case 0x00:
//
// state.sureBtnState.value = 0;
cancelBlueConnetctToastTimer();
dismissEasyLoading();
// state.sureBtnState.value = 0;
final GetGatewayInfoModel gatewayModel = GetGatewayInfoModel();
// MAC地址
@ -393,28 +381,17 @@ class ConfiguringWifiLogic extends BaseGetXController {
}
}
void _replyStatusInfo(reply) {}
//
Future<void> _getUploadLockSet() async {
// showEasyLoading();
// showBlueConnetctToastTimer(action: () {
// dismissEasyLoading();
// });
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
final List<String>? token = await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!);
_uploadLockSet(getTokenList);
} else if (connectionState == BluetoothConnectionState.disconnected) {
cancelBlueConnetctToastTimer();
if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
}
}
showEasyLoading();
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
});
final List<String>? token = await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!);
await _uploadLockSet(getTokenList);
}
//
@ -438,15 +415,15 @@ class ConfiguringWifiLogic extends BaseGetXController {
//
Future<void> _replyUpdataLockSetReply(Reply reply) async {
final int status = reply.data[2];
dismissEasyLoading(); // loading
cancelBlueConnetctToastTimer();
switch (status) {
case 0x00:
//
dismissEasyLoading();
cancelBlueConnetctToastTimer();
_lockDataUpload(
await _lockDataUpload(
uploadType: 1,
recordType: 0,
records: reply.data.sublist(7, reply.data.length));
break;
case 0x06:
//
@ -475,33 +452,18 @@ class ConfiguringWifiLogic extends BaseGetXController {
records: records,
isUnShowLoading: true);
if (entity.errorCode!.codeIsSuccessful) {
await Future.delayed((Duration(seconds: 1)));
if (state.pageName.value == 'lockSet') {
Get.close(2);
} else {
Get.offAllNamed(Routers.starLockMain);
}
dismissEasyLoading();
eventBus
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
eventBus
.fire(SuccessfulDistributionNetwork());
if (state.loadingTimer != null) {
state.loadingTimer!.cancel();
state.loadingTimer = null;
}
}
}
showToast('配网成功'.tr, something: () {
state.isLoading.value = false;
if (state.pageName.value == 'lockSet') {
Get.close(2);
} else {
Get.offAllNamed(Routers.starLockMain);
}
@override
void dispose() {
dismissEasyLoading();
// TODO: implement dispose
super.dispose();
state.isLoading.value = false;
if (state.loadingTimer != null) {
state.loadingTimer!.cancel();
state.loadingTimer = null;
eventBus
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
eventBus.fire(SuccessfulDistributionNetwork());
});
}
}
}

View File

@ -93,7 +93,6 @@ class NearbyLockLogic extends BaseGetXController {
showToast('固件升级完成'.tr);
closeOTADAta();
}
dismissEasyLoading();
});
}
@ -160,6 +159,7 @@ class NearbyLockLogic extends BaseGetXController {
//
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
final int status = reply.data[2];
dismissEasyLoading();
switch (status) {
case 0x00:
//
@ -743,8 +743,8 @@ class NearbyLockLogic extends BaseGetXController {
@override
void onClose() {
super.onClose();
_replySubscription?.cancel();
super.onClose();
}
Future<void> getNearByLimits() async {