From b92857d193cfba701ad97e09ff0d08fc45f0d95b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Tue, 9 Jan 2024 18:02:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=94=81=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=87=8C=E9=9D=A2=E8=93=9D=E7=89=99=E8=BF=9E=E6=8E=A5=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../card/cardList/cardList_page.dart | 4 +- .../fingerprintList/fingerprintList_page.dart | 4 +- .../automaticBlocking_logic.dart | 30 ++++-- .../automaticBlocking_page.dart | 66 ++++++++++++- .../automaticBlocking_state.dart | 3 + .../burglarAlarm/burglarAlarm_logic.dart | 18 +++- .../burglarAlarm/burglarAlarm_page.dart | 66 ++++++++++++- .../burglarAlarm/burglarAlarm_state.dart | 3 + .../configuringWifi_logic.dart | 20 +++- .../configuringWifi/configuringWifi_page.dart | 61 +++++++++++- .../configuringWifi_state.dart | 4 +- .../lcokSet/lockSet/lockSet_logic.dart | 15 ++- .../lcokSet/lockSet/lockSet_page.dart | 12 +-- .../lockSoundSet/lockSoundSet_logic.dart | 19 +++- .../lockSoundSet/lockSoundSet_page.dart | 62 +++++++++++- .../lockSoundSet/lockSoundSet_state.dart | 2 + .../lcokSet/lockTime/lockTime_logic.dart | 19 +++- .../lcokSet/lockTime/lockTime_page.dart | 66 ++++++++++++- .../lcokSet/lockTime/lockTime_state.dart | 4 +- .../normallyOpenMode_logic.dart | 48 +++++++++- .../normallyOpenMode_page.dart | 78 +++++++++++---- .../normallyOpenMode_state.dart | 8 +- .../remoteUnlocking_logic.dart | 17 +++- .../remoteUnlocking/remoteUnlocking_page.dart | 66 ++++++++++++- .../remoteUnlocking_state.dart | 3 + .../resetButton/resetButton_logic.dart | 18 +++- .../lcokSet/resetButton/resetButton_page.dart | 96 ++++++++++++++++++- .../resetButton/resetButton_state.dart | 3 + .../mine/mineSet/mineSet/mineSet_logic.dart | 1 - star_lock/lib/talk/udp/udp_help.dart | 4 +- 30 files changed, 741 insertions(+), 79 deletions(-) diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart index 4f0a6d73..545dc065 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart @@ -144,9 +144,7 @@ class _CardListPageState extends State { child: _keyItem( 'images/icon_card.png', fingerprintItemData.cardName!, - fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch - ? "已失效" - : "", + (fingerprintItemData.cardType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "", fingerprintItemData.validTimeStr!, // fingerprintItemData.cardType! == 1 // ? "永久" diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index e8bcb5ec..a4f18282 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -144,9 +144,7 @@ class _FingerprintListPageState extends State { child: _keyItem( 'images/icon_fingerprint.png', fingerprintItemData.fingerprintName!, - fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch - ? "已失效" - : "", + (fingerprintItemData.fingerprintType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "", fingerprintItemData.validTimeStr!, // fingerprintItemData.fingerprintType! == 1 // ? "永久" diff --git a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart index 0caf70dc..43d1b4b2 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart @@ -26,6 +26,10 @@ class AutomaticBlockingLogic extends BaseGetXController{ }else{ if(state.isCustomLockTime.value == true){ autoTime = state.timeController.text; + if(int.parse(autoTime) >= 1000){ + showToast("请输入小于1000的数字"); + return; + } }else{ autoTime = state.autoLockTime.value; } @@ -38,7 +42,7 @@ class AutomaticBlockingLogic extends BaseGetXController{ ); if(entity.errorCode!.codeIsSuccessful){ - state.autoLockTime.value = state.isOpen.value == false ? "0" : state.autoLockTime.value; + state.autoLockTime.value = autoTime; state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond = int.parse(state.autoLockTime.value); eventBus.fire(RefreshLockListInfoDataEvent()); eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); @@ -66,10 +70,11 @@ class AutomaticBlockingLogic extends BaseGetXController{ int status = reply.data[2]; switch(status){ case 0x00: - //成功 + //成功 print("${reply.commandType}数据解析成功"); + state.sureBtnState.value = 0; + dismissEasyLoading(); state.autoLockTime.value = reply.data[7].toString(); - break; case 0x06: //无权限 @@ -101,6 +106,7 @@ class AutomaticBlockingLogic extends BaseGetXController{ case 0x00: //成功 print("${reply.commandType}数据解析成功"); + state.sureBtnState.value = 0; setAutoUnLock(); break; case 0x06: @@ -154,10 +160,18 @@ class AutomaticBlockingLogic extends BaseGetXController{ // 设置支持功能(带参数) Future sendAutoLock() async { + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { - dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -177,7 +191,7 @@ class AutomaticBlockingLogic extends BaseGetXController{ autoTime = state.autoLockTime.value; } } - print("autoTimeautoTimeautoTime:${autoTime}"); + // print("autoTimeautoTimeautoTime:${autoTime}"); IoSenderManage.setSupportFunctionsWithParametersCommand( keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), userID: await Storage.getUid(), @@ -190,7 +204,11 @@ class AutomaticBlockingLogic extends BaseGetXController{ privateKey: getPrivateKeyList); } else if (connectionState == DeviceConnectionState.disconnected) { dismissEasyLoading(); - showBlueConnetctToast(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } } }); } diff --git a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart index ae33426c..8d8bbc3d 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart @@ -1,11 +1,13 @@ -import 'dart:convert'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/showBottomSheetTool.dart'; import '../../../../tools/titleAppBar.dart'; @@ -20,7 +22,7 @@ class AutomaticBlockingPage extends StatefulWidget { State createState() => _AutomaticBlockingPageState(); } -class _AutomaticBlockingPageState extends State { +class _AutomaticBlockingPageState extends State with RouteAware { final logic = Get.put(AutomaticBlockingLogic()); final state = Get.find().state; @@ -124,6 +126,7 @@ class _AutomaticBlockingPageState extends State { //输入框一行 maxLines: 1, controller: state.timeController, + keyboardType: TextInputType.number, autofocus: false, readOnly: state.isJustForShow.value == true ? true : false, decoration: InputDecoration( @@ -177,4 +180,63 @@ class _AutomaticBlockingPageState extends State { }, ); } + + + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// 从上级界面进入 当前界面即将出现 + @override + void didPush() { + super.didPush(); + print("lockSet===didPush"); + state.ifCurrentScreen.value = true; + } + + /// 返回上一个界面 当前界面即将消失 + @override + void didPop() { + super.didPop(); + print("lockSet===didPop"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + + /// 从下级返回 当前界面即将出现 + @override + void didPopNext() { + super.didPopNext(); + print("lockSet===didPopNext"); + state.ifCurrentScreen.value = true; + } + + /// 进入下级界面 当前界面即将消失 + @override + void didPushNext() { + super.didPushNext(); + print("lockSet===didPushNext"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + } diff --git a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart index fb2fecba..aad60abb 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart @@ -10,6 +10,8 @@ class AutomaticBlockingState { final lockBasicInfo = LockBasicInfo().obs; var isJustForShow = false.obs;// 是否只是作为展示作用,因为普通用户只是展示,不可修改 + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) var isOpen = false.obs;// 是否开启自动落锁 var autoLockTime = "5".obs; @@ -40,4 +42,5 @@ class AutomaticBlockingState { timeController.text = autoLockTime.value; } } + } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_logic.dart index b3e06ce9..9d443e4d 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_logic.dart @@ -85,6 +85,8 @@ class BurglarAlarmLogic extends BaseGetXController{ case 0x00: //成功 print("${reply.commandType}数据解析成功"); + state.sureBtnState.value = 0; + dismissEasyLoading(); _setLockSetGeneralSetting(); break; case 0x06: @@ -138,10 +140,18 @@ class BurglarAlarmLogic extends BaseGetXController{ // 设置支持功能(带参数) Future sendBurglarAlarm() async { + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { - dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -162,7 +172,11 @@ class BurglarAlarmLogic extends BaseGetXController{ privateKey: getPrivateKeyList); } else if (connectionState == DeviceConnectionState.disconnected) { dismissEasyLoading(); - showBlueConnetctToast(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } } }); } diff --git a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_page.dart b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_page.dart index 9702664a..a9863953 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_page.dart @@ -1,8 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; @@ -15,7 +18,7 @@ class BurglarAlarmPage extends StatefulWidget { State createState() => _BurglarAlarmPageState(); } -class _BurglarAlarmPageState extends State { +class _BurglarAlarmPageState extends State with RouteAware{ final logic = Get.put(BurglarAlarmLogic()); final state = Get.find().state; @@ -69,6 +72,65 @@ class _BurglarAlarmPageState extends State { })), ], ), - )); + ) + ); } + + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// 从上级界面进入 当前界面即将出现 + @override + void didPush() { + super.didPush(); + print("lockSet===didPush"); + state.ifCurrentScreen.value = true; + } + + /// 返回上一个界面 当前界面即将消失 + @override + void didPop() { + super.didPop(); + print("lockSet===didPop"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + + /// 从下级返回 当前界面即将出现 + @override + void didPopNext() { + super.didPopNext(); + print("lockSet===didPopNext"); + state.ifCurrentScreen.value = true; + } + + /// 进入下级界面 当前界面即将消失 + @override + void didPushNext() { + super.didPushNext(); + print("lockSet===didPushNext"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + } diff --git a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_state.dart b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_state.dart index 0dc6bf36..ce6f2d58 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_state.dart @@ -8,6 +8,9 @@ class BurglarAlarmState{ var burglarAlarmEnable = 0.obs; + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) + BurglarAlarmState() { var map = Get.arguments; lockSetInfoData.value = map["lockSetInfoData"]; diff --git a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_logic.dart index bb99c511..0c20864d 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_logic.dart @@ -70,6 +70,8 @@ class ConfiguringWifiLogic extends BaseGetXController{ case 0x00: //成功 print("${reply.commandType}数据解析成功"); + state.sureBtnState.value = 0; + dismissEasyLoading(); Toast.show(msg: "配网成功"); break; case 0x06: @@ -143,10 +145,18 @@ class ConfiguringWifiLogic extends BaseGetXController{ // 点击配置wifi Future senderConfiguringWifiAction() async { + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected){ - dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -206,7 +216,11 @@ class ConfiguringWifiLogic extends BaseGetXController{ ); } else if (connectionState == DeviceConnectionState.disconnected) { dismissEasyLoading(); - showBlueConnetctToast(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } } }); } @@ -257,5 +271,7 @@ class ConfiguringWifiLogic extends BaseGetXController{ @override void onClose() { // TODO: implement onClose + _replySubscription.cancel(); + super.onClose(); } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_page.dart b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_page.dart index 3c9fa901..073a3ea8 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_page.dart @@ -1,9 +1,12 @@ import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; @@ -17,7 +20,7 @@ class ConfiguringWifiPage extends StatefulWidget { State createState() => _ConfiguringWifiPageState(); } -class _ConfiguringWifiPageState extends State { +class _ConfiguringWifiPageState extends State with RouteAware { final logic = Get.put(ConfiguringWifiLogic()); final state = Get.find().state; @@ -89,4 +92,60 @@ class _ConfiguringWifiPageState extends State { ); } + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// 从上级界面进入 当前界面即将出现 + @override + void didPush() { + super.didPush(); + print("lockSet===didPush"); + state.ifCurrentScreen.value = true; + } + + /// 返回上一个界面 当前界面即将消失 + @override + void didPop() { + super.didPop(); + print("lockSet===didPop"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + + /// 从下级返回 当前界面即将出现 + @override + void didPopNext() { + super.didPopNext(); + print("lockSet===didPopNext"); + state.ifCurrentScreen.value = true; + } + + /// 进入下级界面 当前界面即将消失 + @override + void didPushNext() { + super.didPushNext(); + print("lockSet===didPushNext"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_state.dart b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_state.dart index 011dae01..e096a7ca 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_state.dart @@ -1,5 +1,4 @@ - import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -11,6 +10,9 @@ class ConfiguringWifiState{ var lockSetInfoData = LockSetInfoData().obs; var lockBasicInfo = LockBasicInfo().obs; + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) + TextEditingController wifiNameController = TextEditingController(); TextEditingController wifiPWDController = TextEditingController(); ConfiguringWifiState() { diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart index 31f3c01e..16a44e6d 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart @@ -419,20 +419,16 @@ class LockSetLogic extends BaseGetXController { ); if (entity.errorCode!.codeIsSuccessful) { state.lockSetInfoData.value = entity.data!; - state.lockSettingInfo.value = - state.lockSetInfoData.value.lockSettingInfo!; + state.lockSettingInfo.value = state.lockSetInfoData.value.lockSettingInfo!; state.lockFeature.value = state.lockSetInfoData.value.lockFeature!; state.lockStatus.value = state.lockSetInfoData.value.lockStatus!; state.lockBasicInfo.value = state.lockSetInfoData.value.lockBasicInfo!; state.isAttendance.value = state.lockSettingInfo.value.attendance!; - state.isOpenLockNeedOnline.value = - state.lockSettingInfo.value.appUnlockOnline!; + state.isOpenLockNeedOnline.value = state.lockSettingInfo.value.appUnlockOnline!; - state.isOpenBlueBroadcast.value = - state.lockSettingInfo.value.bluetoothBroadcast!; - state.isOpenExceptionWarnings.value = - state.lockSettingInfo.value.bluetoothBroadcast!; + state.isOpenBlueBroadcast.value = state.lockSettingInfo.value.bluetoothBroadcast!; + state.isOpenExceptionWarnings.value = state.lockSettingInfo.value.bluetoothBroadcast!; // await _readSupportFunctionsNoParameters(56); // _readSupportFunctionsNoParameters(62); @@ -646,7 +642,8 @@ class LockSetLogic extends BaseGetXController { void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus _passCurrentLockInformationEvent = eventBus.on().listen((event) { - // state.lockSetInfoData.value = event.keyInfo; + state.lockSetInfoData.value = event.lockSetInfoData; + // print("event.lockSetInfoData.lockSettingInfo!.autoLockSecond:${event.lockSetInfoData.lockSettingInfo!.autoLockSecond}"); blockSetStateCallback(); }); } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart index bf3e7508..d2bff65e 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -63,8 +63,7 @@ class _LockSetPageState extends State with RouteAware { List getListWidget() { print( "state.lockBasicInfo.value.isLockOwner:${state.lockBasicInfo.value.isLockOwner} state.lockBasicInfo.value.keyRight:${state.lockBasicInfo.value.keyRight}"); - if (state.lockBasicInfo.value.isLockOwner == 1 || - state.lockBasicInfo.value.keyRight == 1) { + if (state.lockBasicInfo.value.isLockOwner == 1 || state.lockBasicInfo.value.keyRight == 1) { // 超级管理员、授权管理员 return getAllWidget(); } else { @@ -248,10 +247,10 @@ class _LockSetPageState extends State with RouteAware { titleStr = TranslationLoader.lanKeys!.medium!.tr; break; case 4: - titleStr = TranslationLoader.lanKeys!.high!.tr; + titleStr = TranslationLoader.lanKeys!.higher!.tr; break; case 5: - titleStr = TranslationLoader.lanKeys!.higher!.tr; + titleStr = TranslationLoader.lanKeys!.high!.tr; break; } } else { @@ -288,8 +287,8 @@ class _LockSetPageState extends State with RouteAware { SizedBox(height: 10.h), // 常开模式 Obx(() => Visibility( - visible: state.lockFeature.value.passageMode == 1 ? true : false, - // visible:true, + // visible: state.lockFeature.value.passageMode == 1 ? true : false, + visible:true, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.normallyOpenMode!.tr, rightTitle: (state.lockSettingInfo.value.passageMode ?? 0) == 1 @@ -786,6 +785,7 @@ class _LockSetPageState extends State with RouteAware { // }, // ); // } + @override void didChangeDependencies() { // TODO: implement didChangeDependencies diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart index f511ce29..be5637d6 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart @@ -7,7 +7,6 @@ import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_readSupportFunctionsWithParameters.dart'; import '../../../../blue/io_protocol/io_setSupportFunctionsWithParameters.dart'; import '../../../../blue/io_reply.dart'; -import '../../../../blue/io_tool/io_manager.dart'; import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/sender_manage.dart'; @@ -93,6 +92,8 @@ class LockSoundSetLogic extends BaseGetXController { case 0x00: //成功 print("${reply.commandType}数据解析成功"); + state.sureBtnState.value = 0; + dismissEasyLoading(); _setLockSetGeneralSetting(); break; case 0x06: @@ -146,10 +147,18 @@ class LockSoundSetLogic extends BaseGetXController { // 设置支持功能(带参数) Future sendLockSound() async { + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { - dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -179,7 +188,11 @@ class LockSoundSetLogic extends BaseGetXController { privateKey: getPrivateKeyList); } else if (connectionState == DeviceConnectionState.disconnected) { dismissEasyLoading(); - showBlueConnetctToast(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } } }); } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_page.dart index c7897ce6..718fc307 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_page.dart @@ -1,9 +1,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; @@ -17,7 +20,7 @@ class LockSoundSetPage extends StatefulWidget { State createState() => _LockSoundSetPageState(); } -class _LockSoundSetPageState extends State { +class _LockSoundSetPageState extends State with RouteAware { final logic = Get.put(LockSoundSetLogic()); final state = Get.find().state; @@ -203,4 +206,61 @@ class _LockSoundSetPageState extends State { }, ); } + + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// 从上级界面进入 当前界面即将出现 + @override + void didPush() { + super.didPush(); + print("lockSet===didPush"); + state.ifCurrentScreen.value = true; + } + + /// 返回上一个界面 当前界面即将消失 + @override + void didPop() { + super.didPop(); + print("lockSet===didPop"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + + /// 从下级返回 当前界面即将出现 + @override + void didPopNext() { + super.didPopNext(); + print("lockSet===didPopNext"); + state.ifCurrentScreen.value = true; + } + + /// 进入下级界面 当前界面即将消失 + @override + void didPushNext() { + super.didPushNext(); + print("lockSet===didPushNext"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_state.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_state.dart index 20ca6ec9..f1859dfc 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_state.dart @@ -8,6 +8,8 @@ class LockSoundSetState { var isOpenLockSound = false.obs;// 是否开启声音 var lockSoundLevel = 0.obs;// 音量等级 + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) LockSoundSetState() { var map = Get.arguments; diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart index 826fde17..8785a8f9 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart @@ -102,7 +102,8 @@ class LockTimeLogic extends BaseGetXController{ // String dataEime = DateTool().dateToYMDHNSString("$value"); // state.dateTime.value = dataEime; - // _getLockStatus(); + state.sureBtnState.value = 0; + dismissEasyLoading(); Toast.show(msg:"锁时间更新成功"); break; case 0x06: @@ -146,10 +147,18 @@ class LockTimeLogic extends BaseGetXController{ // 校验时间 Future sendTiming() async { + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { - dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -170,7 +179,11 @@ class LockTimeLogic extends BaseGetXController{ ); } else if (connectionState == DeviceConnectionState.disconnected) { dismissEasyLoading(); - showBlueConnetctToast(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } } }); } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_page.dart index 118eacc6..1086d712 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_page.dart @@ -1,8 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; @@ -15,7 +18,7 @@ class LockTimePage extends StatefulWidget { State createState() => _LockTimePageState(); } -class _LockTimePageState extends State { +class _LockTimePageState extends State with RouteAware{ final logic = Get.put(LockTimeLogic()); final state = Get.find().state; @@ -69,6 +72,65 @@ class _LockTimePageState extends State { // ), ], ), - )); + ) + ); } + + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// 从上级界面进入 当前界面即将出现 + @override + void didPush() { + super.didPush(); + print("lockSet===didPush"); + state.ifCurrentScreen.value = true; + } + + /// 返回上一个界面 当前界面即将消失 + @override + void didPop() { + super.didPop(); + print("lockSet===didPop"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + + /// 从下级返回 当前界面即将出现 + @override + void didPopNext() { + super.didPopNext(); + print("lockSet===didPopNext"); + state.ifCurrentScreen.value = true; + } + + /// 进入下级界面 当前界面即将消失 + @override + void didPushNext() { + super.didPushNext(); + print("lockSet===didPushNext"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_state.dart b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_state.dart index 29bfe905..596e5954 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_state.dart @@ -6,9 +6,11 @@ class LockTimeState{ var lockSetInfoData = LockSetInfoData().obs; var dateTime = "".obs; + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) + LockTimeState() { var map = Get.arguments; lockSetInfoData.value = map["lockSetInfoData"]; } - } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart index a0f5ce02..b354be0b 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart @@ -112,6 +112,8 @@ class NormallyOpenModeLogic extends BaseGetXController{ case 0x00: //成功 print("${reply.commandType}数据解析成功"); + state.sureBtnState.value = 0; + dismissEasyLoading(); configPassageMode(); break; case 0x06: @@ -165,10 +167,18 @@ class NormallyOpenModeLogic extends BaseGetXController{ // 设置支持功能(带参数) Future sendAutoLock() async { + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { - dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -178,13 +188,37 @@ class NormallyOpenModeLogic extends BaseGetXController{ var publicKey = await Storage.getStringList(saveBluePublicKey); List getPublicKeyList = changeStringListToIntList(publicKey!); + var weekStr = "00000000"; + for (var day in state.weekDays.value) { + int index = day % 7; // 将周日的索引转换为 0 + weekStr = '${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}'; + } + // print("weekStrweekStrweekStr:$weekStr"); + int number = int.parse(weekStr, radix: 2); + List list = []; list.add(state.isOpenNormallyOpenMode.value == true ? 1:0); - list.add(state.beginTimeMinute.value); - list.add(state.endTimeMinute.value); + + int bieginTime = state.beginTimeMinute.value; + double bieginDouble = bieginTime / 256; + int biegin1 = bieginDouble.toInt(); + int biegin2 = bieginTime % 256; + list.add(biegin1); + list.add(biegin2); + // list.add(state.beginTimeMinute.value); + + int endTime = state.endTimeMinute.value; + double endDouble = endTime / 256; + int end1 = endDouble.toInt(); + int end2 = endTime % 256; + list.add(end1); + list.add(end2); + // list.add(state.endTimeMinute.value); + list.add(state.isAllDay.value == 1 ? 1:0); + list.add(number); list.add(0); - list.add(0); + print("listlistlistlist:$list"); IoSenderManage.setSupportFunctionsWithParametersCommand( keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), @@ -198,7 +232,11 @@ class NormallyOpenModeLogic extends BaseGetXController{ privateKey: getPrivateKeyList); } else if (connectionState == DeviceConnectionState.disconnected) { dismissEasyLoading(); - showBlueConnetctToast(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } } }); } diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart index 18147155..2be632c1 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart @@ -1,13 +1,15 @@ + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -// import 'package:flutter_pickers/pickers.dart'; -// import 'package:flutter_pickers/time_picker/model/date_mode.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; @@ -21,7 +23,7 @@ class NormallyOpenModePage extends StatefulWidget { State createState() => _NormallyOpenModePageState(); } -class _NormallyOpenModePageState extends State { +class _NormallyOpenModePageState extends State with RouteAware{ final logic = Get.put(NormallyOpenModeLogic()); final state = Get.find().state; @@ -318,17 +320,61 @@ class _NormallyOpenModePageState extends State { ); } - // CupertinoSwitch _autoUnlockSwitch() { - // return CupertinoSwitch( - // activeColor: CupertinoColors.activeBlue, - // trackColor: CupertinoColors.systemGrey5, - // thumbColor: CupertinoColors.white, - // value: state.isOpenAutomaticUnLock.value, - // onChanged: (value) { - // setState(() { - // state.isOpenAutomaticUnLock.value = value; - // }); - // }, - // ); - // } + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// 从上级界面进入 当前界面即将出现 + @override + void didPush() { + super.didPush(); + print("lockSet===didPush"); + state.ifCurrentScreen.value = true; + } + + /// 返回上一个界面 当前界面即将消失 + @override + void didPop() { + super.didPop(); + print("lockSet===didPop"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + + /// 从下级返回 当前界面即将出现 + @override + void didPopNext() { + super.didPopNext(); + print("lockSet===didPopNext"); + state.ifCurrentScreen.value = true; + } + + /// 进入下级界面 当前界面即将消失 + @override + void didPushNext() { + super.didPushNext(); + print("lockSet===didPushNext"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + } diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart index 2b5585ba..6cd3f0f6 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart @@ -4,7 +4,7 @@ import '../lockSet/lockSetInfo_entity.dart'; class NormallyOpenModeState{ var lockSetInfoData = LockSetInfoData().obs; - final lockBasicInfo = LockBasicInfo().obs; + var lockBasicInfo = LockBasicInfo().obs; var isJustForShow = false.obs;// 是否只是作为展示作用,因为普通用户只是展示,不可修改 // var getPassageModeConfigData = GetPassageModeConfigEntity().obs; @@ -17,11 +17,17 @@ class NormallyOpenModeState{ var beginTimeMinute = 0.obs;// 开始时间分钟 var endTimeMinute = 0.obs;// 结束时间分钟 + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) + NormallyOpenModeState() { var map = Get.arguments; lockSetInfoData.value = map["lockSetInfoData"]; + lockBasicInfo = lockSetInfoData.value.lockBasicInfo!.obs; + isOpenNormallyOpenMode.value = lockSetInfoData.value.lockSettingInfo!.passageMode! == 1 ? true : false; + print("lockBasicInfo.value.isLockOwner:${lockBasicInfo.value.isLockOwner} lockBasicInfo.value.keyRight:${lockBasicInfo.value.keyRight}"); if(lockBasicInfo.value.isLockOwner == 1 || lockBasicInfo.value.keyRight == 1){ isJustForShow.value = false; }else{ diff --git a/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart index 954ccf06..d06f46fc 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart @@ -85,6 +85,8 @@ class RemoteUnlockingLogic extends BaseGetXController{ case 0x00: //成功 print("${reply.commandType}数据解析成功"); + state.sureBtnState.value = 0; + dismissEasyLoading(); _remoteUnlockingOpenOrClose(); break; case 0x06: @@ -138,7 +140,16 @@ class RemoteUnlockingLogic extends BaseGetXController{ // 设置支持功能(带参数) 远程开锁 Future sendBurglarAlarm() async { + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -161,7 +172,11 @@ class RemoteUnlockingLogic extends BaseGetXController{ privateKey: getPrivateKeyList); } else if (connectionState == DeviceConnectionState.disconnected) { dismissEasyLoading(); - showBlueConnetctToast(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } } }); } diff --git a/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_page.dart b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_page.dart index 6b0ac125..934aca06 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_page.dart @@ -1,9 +1,12 @@ import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; @@ -15,7 +18,7 @@ class RemoteUnlockingPage extends StatefulWidget { State createState() => _RemoteUnlockingPageState(); } -class _RemoteUnlockingPageState extends State { +class _RemoteUnlockingPageState extends State with RouteAware { final logic = Get.put(RemoteUnlockingLogic()); final state = Get.find().state; @@ -69,6 +72,65 @@ class _RemoteUnlockingPageState extends State { })), ], ), - )); + ) + ); } + + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// 从上级界面进入 当前界面即将出现 + @override + void didPush() { + super.didPush(); + print("lockSet===didPush"); + state.ifCurrentScreen.value = true; + } + + /// 返回上一个界面 当前界面即将消失 + @override + void didPop() { + super.didPop(); + print("lockSet===didPop"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + + /// 从下级返回 当前界面即将出现 + @override + void didPopNext() { + super.didPopNext(); + print("lockSet===didPopNext"); + state.ifCurrentScreen.value = true; + } + + /// 进入下级界面 当前界面即将消失 + @override + void didPushNext() { + super.didPushNext(); + print("lockSet===didPushNext"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + } diff --git a/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_state.dart b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_state.dart index 017af500..ee1de354 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_state.dart @@ -7,6 +7,9 @@ class RemoteUnlockingState{ var lockSetInfoData = LockSetInfoData().obs; var remoteEnable = 1.obs; + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) + RemoteUnlockingState() { var map = Get.arguments; lockSetInfoData.value = map["lockSetInfoData"]; diff --git a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_logic.dart index cfcdc560..e134a47b 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_logic.dart @@ -87,6 +87,8 @@ class ResetButtonLogic extends BaseGetXController{ case 0x00: //成功 print("${reply.commandType}数据解析成功"); + state.sureBtnState.value = 0; + dismissEasyLoading(); _setLockSetGeneralSetting(); break; case 0x06: @@ -140,10 +142,18 @@ class ResetButtonLogic extends BaseGetXController{ // 设置支持功能(带参数) Future sendBurglarAlarm() async { + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { - dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -164,7 +174,11 @@ class ResetButtonLogic extends BaseGetXController{ privateKey: getPrivateKeyList); } else if (connectionState == DeviceConnectionState.disconnected) { dismissEasyLoading(); - showBlueConnetctToast(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } } }); } diff --git a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_page.dart b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_page.dart index f6eb2924..5c5d263d 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_page.dart @@ -1,8 +1,12 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; @@ -15,7 +19,7 @@ class ResetButtonPage extends StatefulWidget { State createState() => _ResetButtonPageState(); } -class _ResetButtonPageState extends State { +class _ResetButtonPageState extends State with RouteAware { final logic = Get.put(ResetButtonLogic()); final state = Get.find().state; @@ -78,10 +82,96 @@ class _ResetButtonPageState extends State { // margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { - logic.sendBurglarAlarm(); + showDeletAlertTipDialog(context); })), ], ), - )); + ) + ); } + + void showDeletAlertTipDialog(BuildContext context) { + showCupertinoDialog( + context: context, + builder: (context) { + return CupertinoAlertDialog( + title: const Text("提示"), + content: Text('确定要${state.resetButtonEnable.value == 1 ? TranslationLoader.lanKeys!.open!.tr : TranslationLoader.lanKeys!.close!.tr}重置键?'), + actions: [ + CupertinoDialogAction( + child: Text(TranslationLoader.lanKeys!.cancel!.tr), + onPressed: () { + Get.back(); + }, + ), + CupertinoDialogAction( + child: Text(TranslationLoader.lanKeys!.sure!.tr), + onPressed: () { + Get.back(); + logic.sendBurglarAlarm(); + }, + ), + ], + ); + }, + ); + } + + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// 从上级界面进入 当前界面即将出现 + @override + void didPush() { + super.didPush(); + print("lockSet===didPush"); + state.ifCurrentScreen.value = true; + } + + /// 返回上一个界面 当前界面即将消失 + @override + void didPop() { + super.didPop(); + print("lockSet===didPop"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + + /// 从下级返回 当前界面即将出现 + @override + void didPopNext() { + super.didPopNext(); + print("lockSet===didPopNext"); + state.ifCurrentScreen.value = true; + } + + /// 进入下级界面 当前界面即将消失 + @override + void didPushNext() { + super.didPushNext(); + print("lockSet===didPushNext"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + } diff --git a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_state.dart b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_state.dart index b22aee82..3d5c6d00 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_state.dart @@ -9,6 +9,9 @@ class ResetButtonState{ var resetButtonEnable = 1.obs; + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) + ResetButtonState() { var map = Get.arguments; lockSetInfoData.value = map["lockSetInfoData"]; diff --git a/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart b/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart index 50576c6c..6421f44c 100644 --- a/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart +++ b/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart @@ -55,7 +55,6 @@ class MineSetLogic extends BaseGetXController { if (entity.errorCode!.codeIsSuccessful) { UdpHelp().closeUDP(); logOut(); - // BlueManage().stopScan(); BlueManage().disconnect(BlueManage().connectDeviceMacAddress); Get.offNamedUntil(Routers.starLockLoginPage, (route) => false); } diff --git a/star_lock/lib/talk/udp/udp_help.dart b/star_lock/lib/talk/udp/udp_help.dart index e7bee774..4d765c77 100644 --- a/star_lock/lib/talk/udp/udp_help.dart +++ b/star_lock/lib/talk/udp/udp_help.dart @@ -53,7 +53,9 @@ class UdpHelp { } void closeUDP() { - udpHeartTimer!.cancel(); + if(udpHeartTimer != null){ + udpHeartTimer!.cancel(); + } } dispose() {