From 581311f7d9f1f56fc96891a73d9589a3eac82b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Thu, 25 Apr 2024 16:17:49 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8D=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E5=B7=A6=E5=8F=B3=E6=BB=91=E5=8A=A8=E5=88=87=E6=8D=A2=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E7=A0=81=E7=B1=BB=E5=9E=8B=E4=B8=8D=E5=AF=B9?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=822=E3=80=81=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8C=87=E7=BA=B9=E5=8D=A1=E4=BA=BA=E8=84=B8?= =?UTF-8?q?=E4=BC=A0=E9=92=A5=E5=8C=99=E5=8F=B7=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?3=E3=80=81=E5=8F=96=E6=B6=88=E7=BB=91=E5=AE=9A=E5=AE=8C?= =?UTF-8?q?=E9=94=81=E4=B9=8B=E5=90=8E=E5=BC=B9=E6=A1=86=E7=BB=99=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=AE=E6=94=B9=E7=AE=A1=E7=90=86=E5=91=98=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/appRouters.dart | 8 +- star_lock/lib/blue/reciver_data.dart | 2 +- .../card/addICCard/addICCard_logic.dart | 4 +- .../face/addFace/addFace_logic.dart | 4 +- .../addFingerprint/addFingerprint_logic.dart | 4 +- .../passwordKeyList/passwordKeyList_page.dart | 2 +- .../passwordKeyManage_tabbar.dart | 6 +- .../passwordKey_perpetual_page.dart | 266 ++++++++++++------ .../passwordKey_perpetual_state.dart | 10 + .../mine/addLock/saveLock/saveLock_logic.dart | 253 +++++++++-------- .../mine/addLock/saveLock/saveLock_page.dart | 4 + 11 files changed, 330 insertions(+), 233 deletions(-) diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index 46f6c130..2a22e31a 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -115,7 +115,7 @@ import 'main/lockDetail/lockSet/wirelessKeyboard/selectWirelessKeyboard/selectWi import 'main/lockDetail/lockSet/wirelessKeyboard/wirelessKeyboardList/wirelessKeyboard_page.dart'; import 'main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart'; import 'main/lockDetail/monitoring/monitoringRealTimeScreen/monitoringRealTimeScreen_page.dart'; -import 'main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_page.dart'; +import 'main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart'; import 'main/lockDetail/realTimePicture/realTimePicture_page.dart'; import 'main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart'; import 'main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart'; @@ -214,7 +214,7 @@ abstract class Routers { '/ElectronicKeyPeriodValidityPage'; // 电子钥匙有效期 static const sendEmailNotificationPage = '/SendEmailNotificationPage'; // 邮件通知 static const passwordKeyListPage = '/PasswordKeyListPage'; // 密码钥匙列表 - static const passwordKeyManagePage = '/PasswordKeyManagePage'; // 密码钥匙 + static const passwordKeyPerpetualPage = '/PasswordKeyPerpetualPage'; // 密码钥匙 static const passwordKeyDetailPage = '/PasswordKeyDetailPage'; // 密码钥匙详情 // static const otherTypeKeyListPage = '/OtherTypeKeyListPage'; // 卡、指纹、遥控钥匙列表 // static const otherTypeKeyDetailPage = '/OtherTypeKeyDetailPage'; // 卡、指纹、遥控钥匙详情 @@ -519,8 +519,8 @@ abstract class AppRouters { page: () => const PasswordKeyListPage(), ), GetPage( - name: Routers.passwordKeyManagePage, - page: () => const PasswordKeyManagePage(), + name: Routers.passwordKeyPerpetualPage, + page: () => const PasswordKeyPerpetualPage(), ), GetPage( name: Routers.passwordKeyDetailPage, diff --git a/star_lock/lib/blue/reciver_data.dart b/star_lock/lib/blue/reciver_data.dart index a03e31c7..b256b1be 100644 --- a/star_lock/lib/blue/reciver_data.dart +++ b/star_lock/lib/blue/reciver_data.dart @@ -114,7 +114,7 @@ class CommandReciverManager { oriDataList = SM4.decrypt(getDataList, key: getPrivateKeyList, mode: SM4CryptoMode.ECB); oriDataList = oriDataList.sublist(0, oriLen); - // print("SM4 oriDataList:$oriDataList"); + print("SM4 oriDataList:$oriDataList"); break; } parseData(oriDataList).then((value) async { diff --git a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart index 39d6956b..8d2c29b6 100644 --- a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart +++ b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart @@ -81,7 +81,7 @@ class AddICCardLogic extends BaseGetXController{ IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( keyID:"1", userID:await Storage.getUid(), - cardNo:state.isAdministrator.value == "2" ? 254 : 1, + cardNo:state.isAdministrator.value == "2" ? 254 : 0, useCountLimit:0xff, isForce:state.isCoerced.value == "1" ? 0 : 1, // 是否是胁迫 isRound:state.selectType.value == "2" ? 1: 0, // 是否是循环 @@ -229,7 +229,7 @@ class AddICCardLogic extends BaseGetXController{ IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( keyID:"1", userID:await Storage.getUid(), - cardNo:state.isAdministrator.value == "2" ? 254 : 1, + cardNo:state.isAdministrator.value == "2" ? 254 : 0, useCountLimit:0xff, isForce:state.isCoerced.value == "2" ? 1 : 0, // 是否是胁迫 isRound:state.selectType.value == "2" ? 1: 0, // 是否是循环 diff --git a/star_lock/lib/main/lockDetail/face/addFace/addFace_logic.dart b/star_lock/lib/main/lockDetail/face/addFace/addFace_logic.dart index b5ed0a44..4826ddeb 100644 --- a/star_lock/lib/main/lockDetail/face/addFace/addFace_logic.dart +++ b/star_lock/lib/main/lockDetail/face/addFace/addFace_logic.dart @@ -83,7 +83,7 @@ class AddFaceLogic extends BaseGetXController { IoSenderManage.senderAddFaceCommand( keyID:"1", userID:await Storage.getUid(), - faceNo:state.isAdministrator.value == "2" ? 254 : 1, + faceNo:state.isAdministrator.value == "2" ? 254 : 0, useCountLimit:0xff, isForce:state.isCoerced.value == "2" ? 1 : 0, // 是否是胁迫 isRound:state.selectType.value == "2" ? 1: 0, // 是否是循环 @@ -232,7 +232,7 @@ class AddFaceLogic extends BaseGetXController { IoSenderManage.senderAddFaceCommand( keyID:"1", userID:await Storage.getUid(), - faceNo:state.isAdministrator.value == "2" ? 254 : 1, + faceNo:state.isAdministrator.value == "2" ? 254 : 0, useCountLimit:0xff, isForce:state.isCoerced.value == "2" ? 1 : 0, // 是否是胁迫 isRound:state.selectType.value == "2" ? 1: 0, // 是否是循环 diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart index 8dee9a66..9b5326ff 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart @@ -93,7 +93,7 @@ class AddFingerprintLogic extends BaseGetXController { IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( keyID:"1", userID:await Storage.getUid(), - fingerNo:state.isAdministrator.value == "2" ? 254 : 1, + fingerNo:state.isAdministrator.value == "2" ? 254 : 0, useCountLimit:0xff, isForce:state.isCoerced.value == "1" ? 1 : 0, // 是否是胁迫 isRound:state.selectType.value == "2" ? 1: 0, // 是否是循环 @@ -283,7 +283,7 @@ class AddFingerprintLogic extends BaseGetXController { IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( keyID:"1", userID:await Storage.getUid(), - fingerNo:state.isAdministrator.value == "2" ? 254 : 1, + fingerNo:state.isAdministrator.value == "2" ? 254 : 0, useCountLimit:0xff, isForce:state.isCoerced.value == "2" ? 1 : 0, // 是否是胁迫 isRound:state.selectType.value == "2" ? 1: 0, // 是否是循环 diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index c0808f61..7795a6bf 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -107,7 +107,7 @@ class _PasswordKeyListPageState extends State with RouteAwa AddBottomWhiteBtn( btnName: TranslationLoader.lanKeys!.getPassword!.tr, onClick: () { - Navigator.pushNamed(context, Routers.passwordKeyManagePage, + Navigator.pushNamed(context, Routers.passwordKeyPerpetualPage, arguments: {"keyInfo": state.keyInfo.value}).then((val) { if (val != null) { logic.pageNo = 1; diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart index 75d41a9a..9b7dd9ef 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart @@ -115,11 +115,7 @@ class _PasswordKeyManageTabbarPageState extends State PasswordKeyPerpetualPage( - type: item.type, - getKeyInfo: widget.keyInfo, - )) - .toList(), + children: _itemTabs.map((ItemView item) => PasswordKeyPerpetualPage()).toList(), ), ); } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index 315f384b..fd1a2ada 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -16,157 +16,178 @@ import 'package:star_lock/tools/storage.dart'; import '../../../../appRouters.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_modelVendor.dart'; +import '../../../../tools/CustomUnderlineTabIndicator.dart'; import '../../../../tools/NativeInteractionTool.dart'; import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/dateTool.dart'; import '../../../../tools/submitBtn.dart'; +import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; import '../../../lockMian/entity/lockListInfo_entity.dart'; class PasswordKeyPerpetualPage extends StatefulWidget { - final String type; - final LockListInfoItemEntity getKeyInfo; - const PasswordKeyPerpetualPage( - {Key? key, required this.type, required this.getKeyInfo}) - : super(key: key); + {Key? key}) : super(key: key); @override State createState() => _PasswordKeyPerpetualPageState(); } -class _PasswordKeyPerpetualPageState extends State with RouteAware{ +class _PasswordKeyPerpetualPageState extends State with RouteAware, SingleTickerProviderStateMixin{ final logic = Get.put(PasswordKeyPerpetualLogic()); final state = Get.find().state; @override void initState() { + // TODO: implement initState super.initState(); - initData(); - // state.isSendSuccess.value = false; - } + state.tabController = TabController( + vsync: this, + length: _itemTabs.length, + initialIndex: 0); + state.tabController.addListener(() { + WidgetsBinding.instance.addPostFrameCallback((_) { + state.widgetType.value = state.tabController.index; + }); - void initData() { - // if (!state.isInitialized.value) { - // state.isInitialized.value = true; - // state.keyInfo.value = widget.getKeyInfo; - // } + if (state.tabController.animation!.value == state.tabController.index) { + FocusScope.of(context).requestFocus(FocusNode()); + } + }); } @override Widget build(BuildContext context) { - state.keyInfo.value = widget.getKeyInfo; - state.widgetType.value = int.parse(widget.type); - print("state.widgetType.value:${state.widgetType.value}"); - - return SingleChildScrollView( - child: Obx(() => indexChangeWidget()), + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.getPassword!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + _tabBar(), + _pageWidget(), + ], + ), ); } Widget indexChangeWidget() { - if (state.isSendSuccess.value == true && state.sendSucceedType.value.toString() == widget.type) { + if (state.isSendSuccess.value == true && state.sendSucceedType.value == state.widgetType.value) { return sendElectronicKeySucceed(); } else { - switch (int.parse(widget.type)) { + switch (state.widgetType.value) { case 0: { // 永久 - return Column( - children: [ - perpetualKeyWidget( - false, - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - state.nameController), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr) - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + false, + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + state.nameController), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr) + ], + ), ); } case 1: { // 限时 - return Column( - children: [ - keyTimeLimitWidget(), - perpetualKeyWidget( - false, - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - state.nameController), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr) - ], + return SingleChildScrollView( + child: Column( + children: [ + keyTimeLimitWidget(), + perpetualKeyWidget( + false, + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + state.nameController), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr) + ], + ), ); } case 2: { // 单次 - return Column( - children: [ - perpetualKeyWidget( - false, - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - state.nameController), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr) - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + false, + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + state.nameController), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr) + ], + ), ); } case 3: { // 自定义 - return Column( - children: [ - keyIfPerpetualWidget(), - state.isPermanent.value == false - ? keyTimeLimitWidget() - : Container(), - perpetualKeyWidget( - false, - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - state.nameController), - perpetualKeyWidget( - false, - TranslationLoader.lanKeys!.password!.tr, - "请输入6-9位数字", state.pwdController - ), - keyIfAdministratorWidget(), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr) - ], + return SingleChildScrollView( + child: Column( + children: [ + keyIfPerpetualWidget(), + state.isPermanent.value == false + ? keyTimeLimitWidget() + : Container(), + perpetualKeyWidget( + false, + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + state.nameController), + perpetualKeyWidget( + false, + TranslationLoader.lanKeys!.password!.tr, + "请输入6-9位数字", state.pwdController + ), + keyIfAdministratorWidget(), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr) + ], + ), ); } case 4: { // 循环 - return Column( - children: [ - keyCirculationWidget(), - perpetualKeyWidget( - true, - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - state.nameController), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr) - ], + return SingleChildScrollView( + child: Column( + children: [ + keyCirculationWidget(), + perpetualKeyWidget( + true, + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + state.nameController), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr) + ], + ), ); } case 5: { // 清空 - return Column( - children: [ - perpetualKeyWidget( - false, - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - state.nameController), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr) - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + false, + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + state.nameController), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr) + ], + ), ); } default: @@ -365,7 +386,7 @@ class _PasswordKeyPerpetualPageState extends State wit height: 20.h, ), SubmitBtn( - btnName: widget.type == "3" ? "设置密码":TranslationLoader.lanKeys!.getPassword!.tr, + btnName: state.widgetType.value == 3 ? "设置密码":TranslationLoader.lanKeys!.getPassword!.tr, onClick: () async { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { @@ -568,6 +589,66 @@ class _PasswordKeyPerpetualPageState extends State wit }); } + TabBar _tabBar() { + return TabBar( + controller: state.tabController, + onTap: (index){ + FocusScope.of(context).requestFocus(FocusNode()); + }, + tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), + isScrollable: true, + indicatorColor: Colors.red, + unselectedLabelColor: Colors.black, + unselectedLabelStyle: TextStyle( + color: AppColors.mainColor, + fontSize: 24.sp, + ), + automaticIndicatorColorAdjustment: true, + labelColor: AppColors.mainColor, + labelStyle: TextStyle( + color: AppColors.mainColor, + fontSize: 24.sp, + fontWeight: FontWeight.w600), + indicator: CustomUnderlineTabIndicator( + borderSide: BorderSide(color: AppColors.mainColor, width: 4.w), + strokeCap: StrokeCap.round, + width: 30.w), + ); + } + + Tab _tab(ItemView item) { + return Tab( + // text: item.title, + child: Container( + // width: item.title.length > 2 ? 1.sw / 8 : 1.sw / 12, + // margin: EdgeInsets.all(10.w), + // color: Colors.red, + child: Text( + item.title, + textAlign: TextAlign.center, + ), + ), + ); + } + + Widget _pageWidget() { + return Expanded( + child: TabBarView( + controller: state.tabController, + children: _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), + ), + ); + } + + final List _itemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: "0"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: "1"), + ItemView(title: TranslationLoader.lanKeys!.once!.tr, type: "2"), + ItemView(title: TranslationLoader.lanKeys!.custom!.tr, type: "3"), + ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: "4"), + ItemView(title: TranslationLoader.lanKeys!.clearAll!.tr, type: "5"), + ]; + List initBottomSheetList() { List widgetList = []; @@ -684,3 +765,10 @@ class _PasswordKeyPerpetualPageState extends State wit state.sureBtnState.value = 0; } } + +class ItemView { + const ItemView({required this.title, required this.type}); + + final String title; + final String type; +} diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart index 6cd4e82b..ea1dab13 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart @@ -1,4 +1,5 @@ +import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; @@ -32,4 +33,13 @@ class PasswordKeyPerpetualState { var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) var pwdNumber = 0.obs;// 密码编号 + late TabController tabController; + + PasswordKeyPerpetualState() { + Map map = Get.arguments; + if(map["keyInfo"] != null){ + keyInfo.value = map["keyInfo"]; + + } + } } diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index a00cf97f..bbebccce 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -38,10 +38,9 @@ class SaveLockLogic extends BaseGetXController { _replySenderCustomPasswords(reply); } - if (reply is ChangeAdministratorPasswordReply) { - _replyChangeAdministratorPassword(reply); - } - + // if (reply is ChangeAdministratorPasswordReply) { + // _replyChangeAdministratorPassword(reply); + // } }); } @@ -152,51 +151,51 @@ class SaveLockLogic extends BaseGetXController { } // 修改管理员密码 - Future _replyChangeAdministratorPassword(Reply reply) async { - var token = reply.data.sublist(5, 9); - var saveStrList = changeIntListToStringList(token); - Storage.setStringList(saveBlueToken, saveStrList); - - int status = reply.data[2]; - Get.log("status:$status"); - - switch (status) { - case 0x00: - //成功 - Get.log("${reply.commandType!.typeValue} 数据解析成功"); - cancelBlueConnetctToastTimer(); - addLockAdminPassword(false); - break; - case 0x06: - //无权限 - Get.log("${reply.commandType!.typeValue} 需要鉴权"); - - var signKey = await Storage.getStringList(saveBlueSignKey); - List signKeyDataList = changeStringListToIntList(signKey!); - - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); - - IoSenderManage.changeAdministratorPasswordCommand( - keyID: "1", - userID: await Storage.getUid(), - pwdNo: 254, - pwd:state.adminPasswordTF.text, - useCountLimit: 0xff, - startTime: 0x11223344, - endTime: 0x11223344, - needAuthor: 1, - isBeforeAddUser: true, - signKey: signKeyDataList, - privateKey: getPrivateKeyList, - token: token); - break; - default: - // 失败 - Get.log("${reply.commandType!.typeValue} 失败"); - break; - } - } + // Future _replyChangeAdministratorPassword(Reply reply) async { + // var token = reply.data.sublist(5, 9); + // var saveStrList = changeIntListToStringList(token); + // Storage.setStringList(saveBlueToken, saveStrList); + // + // int status = reply.data[2]; + // Get.log("status:$status"); + // + // switch (status) { + // case 0x00: + // //成功 + // Get.log("${reply.commandType!.typeValue} 数据解析成功"); + // cancelBlueConnetctToastTimer(); + // addLockAdminPassword(false); + // break; + // case 0x06: + // //无权限 + // Get.log("${reply.commandType!.typeValue} 需要鉴权"); + // + // var signKey = await Storage.getStringList(saveBlueSignKey); + // List signKeyDataList = changeStringListToIntList(signKey!); + // + // var privateKey = await Storage.getStringList(saveBluePrivateKey); + // List getPrivateKeyList = changeStringListToIntList(privateKey!); + // + // IoSenderManage.changeAdministratorPasswordCommand( + // keyID: "1", + // userID: await Storage.getUid(), + // pwdNo: 254, + // pwd:state.adminPasswordTF.text, + // useCountLimit: 0xff, + // startTime: 0x11223344, + // endTime: 0x11223344, + // needAuthor: 1, + // isBeforeAddUser: true, + // signKey: signKeyDataList, + // privateKey: getPrivateKeyList, + // token: token); + // break; + // default: + // // 失败 + // Get.log("${reply.commandType!.typeValue} 失败"); + // break; + // } + // } // 添加用户 Future addUserConnectBlue() async { @@ -284,45 +283,45 @@ class SaveLockLogic extends BaseGetXController { } // 修改管理员密码(同添加自定义开锁密码,指纹/密码/卡片前5个是管理员) - Future changeAdministratorPasswordCommand() async { - showEasyLoading(); - showBlueConnetctToastTimer(action: (){ - dismissEasyLoading(); - }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { - if (deviceConnectionState == BluetoothConnectionState.connected) { - var signKey = await Storage.getStringList(saveBlueSignKey); - List signKeyDataList = changeStringListToIntList(signKey!); - - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); - - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); - - IoSenderManage.changeAdministratorPasswordCommand( - keyID: "1", - userID: await Storage.getUid(), - pwdNo: 254, - pwd:state.adminPasswordTF.text, - useCountLimit: 0xff, - startTime: 0x11223344, - endTime: 0x11223344, - needAuthor: 1, - isBeforeAddUser: true, - signKey: signKeyDataList, - privateKey: getPrivateKeyList, - token: getTokenList); - } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { - dismissEasyLoading(); - cancelBlueConnetctToastTimer(); - state.saveBtnIsUsable.value = true; - if(state.ifCurrentScreen.value == true){ - showBlueConnetctToast(); - } - } - }, isAddEquipment: true); - } + // Future changeAdministratorPasswordCommand() async { + // showEasyLoading(); + // showBlueConnetctToastTimer(action: (){ + // dismissEasyLoading(); + // }); + // BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + // if (deviceConnectionState == BluetoothConnectionState.connected) { + // var signKey = await Storage.getStringList(saveBlueSignKey); + // List signKeyDataList = changeStringListToIntList(signKey!); + // + // var privateKey = await Storage.getStringList(saveBluePrivateKey); + // List getPrivateKeyList = changeStringListToIntList(privateKey!); + // + // var token = await Storage.getStringList(saveBlueToken); + // List getTokenList = changeStringListToIntList(token!); + // + // IoSenderManage.changeAdministratorPasswordCommand( + // keyID: "1", + // userID: await Storage.getUid(), + // pwdNo: 254, + // pwd:state.adminPasswordTF.text, + // useCountLimit: 0xff, + // startTime: 0x11223344, + // endTime: 0x11223344, + // needAuthor: 1, + // isBeforeAddUser: true, + // signKey: signKeyDataList, + // privateKey: getPrivateKeyList, + // token: getTokenList); + // } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + // dismissEasyLoading(); + // cancelBlueConnetctToastTimer(); + // state.saveBtnIsUsable.value = true; + // if(state.ifCurrentScreen.value == true){ + // showBlueConnetctToast(); + // } + // } + // }, isAddEquipment: true); + // } void bindBlueAdmin() async{ @@ -381,52 +380,52 @@ class SaveLockLogic extends BaseGetXController { adminPwd: state.adminPasswordTF.text, ); if (entity.errorCode!.codeIsSuccessful) { - if(isAddLockAdminPassword == true){ - showDeletPasswordAlertDialog(); - }else{ + // if(isAddLockAdminPassword == true){ + // showDeletPasswordAlertDialog(); + // }else{ backAction(); - } + // } } } - void showDeletPasswordAlertDialog() { - showDialog( - context: Get.context!, - builder: (BuildContext context) { - return ShowTFView( - title: "管理员密码", - tipTitle: "如需修改,请输入新的管理员密码(6位),点击确定即可修改", - leftBtnTitle: "确定".tr, - rightBtnTitle: "修改", - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp('[0-9]')), - LengthLimitingTextInputFormatter(6), - ], - controller: state.adminPasswordTF, - sureClick: () { - if(state.adminPasswordTF.text.length < 6){ - showToast("请输入6位管理员密码".tr); - return; - } - - if(state.adminPasswordTF.text == state.adminPassword){ - showToast("请输入新的管理员密码".tr); - return; - } - changeAdministratorPasswordCommand(); - }, - cancelClick: () { - backAction(); - }, - ); - }, - ); - } + // void showDeletPasswordAlertDialog() { + // showDialog( + // context: Get.context!, + // builder: (BuildContext context) { + // return ShowTFView( + // title: "管理员密码", + // tipTitle: "如需修改,请输入新的管理员密码(6位),点击确定即可修改", + // leftBtnTitle: "确定".tr, + // rightBtnTitle: "修改", + // keyboardType: TextInputType.number, + // inputFormatters: [ + // FilteringTextInputFormatter.allow(RegExp('[0-9]')), + // LengthLimitingTextInputFormatter(6), + // ], + // controller: state.adminPasswordTF, + // sureClick: () { + // if(state.adminPasswordTF.text.length < 6){ + // showToast("请输入6位管理员密码".tr); + // return; + // } + // + // if(state.adminPasswordTF.text == state.adminPassword){ + // showToast("请输入新的管理员密码".tr); + // return; + // } + // changeAdministratorPasswordCommand(); + // }, + // cancelClick: () { + // backAction(); + // }, + // ); + // }, + // ); + // } void backAction(){ BlueManage().disconnect(); - Get.close(state.isFromMap == 1 ? 6 : 7); + Get.close(state.isFromMap == 1 ? 5 : 6); } @override diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_page.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_page.dart index c1eafee8..9e68d2cd 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_page.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/blue/blue_manage.dart'; import '../../../app_settings/app_colors.dart'; import '../../../tools/appRouteObserver.dart'; @@ -134,6 +135,7 @@ class _SaveLockPageState extends State with RouteAware { /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); + BlueManage().stopScan(); } /// 从上级界面进入 当前界面即将出现 @@ -141,6 +143,7 @@ class _SaveLockPageState extends State with RouteAware { void didPush() { super.didPush(); + BlueManage().stopScan(); state.ifCurrentScreen.value = true; } @@ -149,6 +152,7 @@ class _SaveLockPageState extends State with RouteAware { void didPop() { super.didPop(); + BlueManage().stopScan(); state.ifCurrentScreen.value = false; logic.cancelBlueConnetctToastTimer(); }