diff --git a/star_lock/android/app/build.gradle b/star_lock/android/app/build.gradle index 20f27d80..3d910105 100644 --- a/star_lock/android/app/build.gradle +++ b/star_lock/android/app/build.gradle @@ -107,7 +107,7 @@ android { dimension "flavor-type" applicationId "com.xhjcn.lock" signingConfig signingConfigs.xhj - resValue "string", "app_name", "星星锁" + resValue "string", "app_name", "鑫锁" manifestPlaceholders.JPUSH_PKGNAME = "com.xhjcn.lock" } } diff --git a/star_lock/flavorizr.yaml b/star_lock/flavorizr.yaml index e19dbf97..76789a5d 100644 --- a/star_lock/flavorizr.yaml +++ b/star_lock/flavorizr.yaml @@ -95,7 +95,7 @@ flavors: bundleId: "com.skychip.lock" xhj: app: - name: "星星锁" + name: "鑫锁" icon: "assets/icon/xhj.png" android: applicationId: "com.xhjcn.lock" diff --git a/star_lock/ios/Flutter/xhjDebug.xcconfig b/star_lock/ios/Flutter/xhjDebug.xcconfig index e73372b3..daeff916 100644 --- a/star_lock/ios/Flutter/xhjDebug.xcconfig +++ b/star_lock/ios/Flutter/xhjDebug.xcconfig @@ -2,5 +2,5 @@ FLUTTER_TARGET=lib/main_xhj_full.dart ASSET_PREFIX=xhj -BUNDLE_NAME=星星锁 -BUNDLE_DISPLAY_NAME=星星锁 +BUNDLE_NAME=鑫锁 +BUNDLE_DISPLAY_NAME=鑫锁 diff --git a/star_lock/ios/Flutter/xhjProfile.xcconfig b/star_lock/ios/Flutter/xhjProfile.xcconfig index e73372b3..daeff916 100644 --- a/star_lock/ios/Flutter/xhjProfile.xcconfig +++ b/star_lock/ios/Flutter/xhjProfile.xcconfig @@ -2,5 +2,5 @@ FLUTTER_TARGET=lib/main_xhj_full.dart ASSET_PREFIX=xhj -BUNDLE_NAME=星星锁 -BUNDLE_DISPLAY_NAME=星星锁 +BUNDLE_NAME=鑫锁 +BUNDLE_DISPLAY_NAME=鑫锁 diff --git a/star_lock/ios/Flutter/xhjRelease.xcconfig b/star_lock/ios/Flutter/xhjRelease.xcconfig index 1aa5f0c3..327db43b 100644 --- a/star_lock/ios/Flutter/xhjRelease.xcconfig +++ b/star_lock/ios/Flutter/xhjRelease.xcconfig @@ -2,5 +2,5 @@ FLUTTER_TARGET=lib/main_xhj_lite.dart ASSET_PREFIX=xhj -BUNDLE_NAME=星星锁 -BUNDLE_DISPLAY_NAME=星星锁 +BUNDLE_NAME=鑫锁 +BUNDLE_DISPLAY_NAME=鑫锁 diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index 4366b083..2a22e31a 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -76,7 +76,7 @@ import 'main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkin import 'main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart'; import 'main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicManageKey/massSendElectronicKeyManage_page.dart'; import 'main/lockDetail/face/addFace/addFace_page.dart'; -import 'main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_page.dart'; +import 'main/lockDetail/face/addFaceType/addFaceType_page.dart'; import 'main/lockDetail/face/faceList/faceList_page.dart'; import 'main/lockDetail/fingerprint/addFingerprint/addFingerprint_page.dart'; import 'main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart'; @@ -115,9 +115,9 @@ 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/addRemoteControlManage/addRemoteControlManage_page.dart'; +import 'main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart'; import 'main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart'; import 'main/lockDetail/videoLog/editVideoLog/editVideoLog_page.dart'; import 'main/lockDetail/videoLog/videoLog/videoLog_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'; // 卡、指纹、遥控钥匙详情 @@ -412,8 +412,7 @@ abstract class Routers { static const videoLogDownLoadPage = '/VideoLogDownLoadPage'; // 视频下载列表 static const remoteControlListPage = '/RemoteControlListPage'; // 遥控列表 - static const addRemoteControlManagePage = - '/AddRemoteControlManagePage'; // 添加遥控 + static const addRemoteControlPage = '/AddRemoteControlPage'; // 添加遥控 static const cardListPage = '/CardListPage'; // 卡列表 // static const addCardTypeManagePage = '/AddCardTypeManagePage'; // 添加卡 @@ -423,7 +422,7 @@ abstract class Routers { static const addFingerprintTypePage = '/AddFingerprintTypePage'; // 添加指纹 static const fingerprintDetailPage = '/FingerprintDetailPage'; // 指纹详情 static const faceListPage = '/FaceListPage'; // 人脸列表 - static const addFaceTypeManagePage = '/AddFaceTypeManagePage'; // 添加人脸 + static const addFaceTypePage = '/AddFaceTypePage'; // 添加人脸 static const faceDetailPage = '/faceDetailPage'; // 人脸详情 static const irisListPage = '/IrisListPage'; // 虹膜列表 @@ -520,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, @@ -1006,8 +1005,8 @@ abstract class AppRouters { name: Routers.remoteControlListPage, page: () => const RemoteControlListPage()), GetPage( - name: Routers.addRemoteControlManagePage, - page: () => const AddRemoteControlManagePage()), + name: Routers.addRemoteControlPage, + page: () => const AddRemoteControlPage()), GetPage(name: Routers.cardListPage, page: () => const CardListPage()), // GetPage( // name: Routers.addCardTypeManagePage, @@ -1027,8 +1026,8 @@ abstract class AppRouters { page: () => const FingerprintDetailPage()), GetPage(name: Routers.faceListPage, page: () => const FaceListPage()), GetPage( - name: Routers.addFaceTypeManagePage, - page: () => const AddFaceTypeManagePage()), + name: Routers.addFaceTypePage, + page: () => const AddFaceTypePage()), GetPage( name: Routers.passwordKeyDetailChangeDatePage, page: () => const PasswordKeyDetailChangeDatePage()), diff --git a/star_lock/lib/blue/io_protocol/io_otaUpgrade.dart b/star_lock/lib/blue/io_protocol/io_otaUpgrade.dart index b7396a5e..679213be 100644 --- a/star_lock/lib/blue/io_protocol/io_otaUpgrade.dart +++ b/star_lock/lib/blue/io_protocol/io_otaUpgrade.dart @@ -55,53 +55,78 @@ class OTAUpgradeCommand extends SenderProtocol { data.add(type1); data.add(type2); + print('---> 指令 : $type1 $type2' ); + // 锁id 40 int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); + print('---> 锁id :' + utf8.encode(lockID!).toString()); + //userID 20 int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); + print('---> userID :' + utf8.encode(userID!).toString()); + //platform 2 int platform0 = (platform! & 0xFF00) >> 8; int platform1 = platform! & 0xFF; data.add(platform0); data.add(platform1); + print('---> platform : $platform0 $platform1'); + //product 2 - int product0 = (product! & 0xFF00) >> 8; - int product1 = product! & 0xFF; - data.add(product0); - data.add(product1); + // int product0 = (product! & 0xFF00) >> 8; + // int product1 = product! & 0xFF; + // data.add(product0); + // data.add(product1); + data.addAll([0,1]);//先默认是 01 + + print('---> platform : ${[0,1]}'); //HwVersion 20 int hwVersionLength = utf8.encode(hwVersion!).length; data.addAll(utf8.encode(hwVersion!)); data = getFixedLengthList(data, 20 - hwVersionLength); + print('---> hwVersion : ${utf8.encode(hwVersion!)}'); + //FwVersion 20 int fwVersionLength = utf8.encode(fwVersion!).length; data.addAll(utf8.encode(fwVersion!)); data = getFixedLengthList(data, 20 - fwVersionLength); + print('---> FwVersion : ${utf8.encode(fwVersion!)}'); + //fwSize 4 ByteData bytes = ByteData(4); // 创建一个长度为4的字节数据 bytes.setInt32(0, fwSize!); List byteList = bytes.buffer.asUint8List(); data.addAll(byteList); - //fwMD5 16 - int fwMD5Length = utf8.encode(fwMD5!).length; - data.addAll(utf8.encode(fwMD5!)); - data = getFixedLengthList(data, 16 - fwMD5Length); + print('---> fwSize : ${byteList}'); + + // 创建一个16字节的字节数组 + Uint8List result = Uint8List(16); + // 将每个十六进制字符转换为4位二进制数据,并将其存储到结果字节数组中 + for (int i = 0; i < fwMD5!.length; i += 2) { + String hex = fwMD5!.substring(i, i + 2); + int byteValue = int.parse(hex, radix: 16); + result[i ~/ 2] = byteValue; + } + data.addAll(result); + print('---> fwMD5 : ${result}'); // token 长度4 首次请求 Token 填 0,如果锁需要鉴权 操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 当token失效或者第一次发送的时候token为0 data.addAll(token!); - print('--->1'+data.toString()); + print('---> token : ${token}'); + + print('--->1' + data.toString()); if (needAuthor == 0) { //AuthCodeLen 1 @@ -120,6 +145,8 @@ class OTAUpgradeCommand extends SenderProtocol { authCodeData.addAll(signKey!); + print('---> ${utf8.encode(keyID!)} ${utf8.encode(userID!)} $token $signKey'); + // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -149,7 +176,7 @@ class OTAUpgradeReply extends Reply { data = dataDetail; token = data.sublist(2, 6); status = data[6]; - print('--->2'+data.toString()); + print('--->2' + data.toString()); errorWithStstus(status); } } diff --git a/star_lock/lib/blue/io_type.dart b/star_lock/lib/blue/io_type.dart index 491bf6d9..c2cd45f8 100644 --- a/star_lock/lib/blue/io_type.dart +++ b/star_lock/lib/blue/io_type.dart @@ -13,8 +13,8 @@ enum CommandType { calibrationTime, // 校时 = 0x30f0 readStarLockStatusInfo, //读星锁状态信息 0x3040 startOATUpgrade, //OTA升级开始 0x30E0 - confirmationOTAUpgrade, //OTA升级开始 0x30E1 - processOTAUpgrade, //OTA升级过程 0x30E2 + confirmationOTAUpgrade, //OTA升级开始 0x30E2 + processOTAUpgrade, //OTA升级过程 0x30E1 generalExtendedCommond, // 通用扩展指令 = 0x3030 gecChangeAdministratorPassword, // 通用扩展指令子命令-修改管理员密码 = 2 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/blue/sender_manage.dart b/star_lock/lib/blue/sender_manage.dart index 83eb71d6..bcb1612e 100644 --- a/star_lock/lib/blue/sender_manage.dart +++ b/star_lock/lib/blue/sender_manage.dart @@ -86,6 +86,7 @@ class IoSenderManage { List? publicKey, List? privateKey, List? token, + bool? isBeforeAddUser, CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: AddUserCommand( @@ -103,7 +104,7 @@ class IoSenderManage { publicKey: publicKey, privateKey: privateKey, token: token), - isBeforeAddUser: true, + isBeforeAddUser: isBeforeAddUser!, callBack: callBack); } @@ -214,6 +215,7 @@ class IoSenderManage { {String? lockID, String? userID, List? privateKey, + bool? isBeforeAddUser, CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: GetStarLockStatuInfoCommand( @@ -221,6 +223,7 @@ class IoSenderManage { userID: userID, privateKey: privateKey, ), + isBeforeAddUser: isBeforeAddUser!, callBack: callBack); } diff --git a/star_lock/lib/flavors.dart b/star_lock/lib/flavors.dart index 734a2c63..ec6cf242 100644 --- a/star_lock/lib/flavors.dart +++ b/star_lock/lib/flavors.dart @@ -74,7 +74,7 @@ class F { case Flavor.sky: return '锁通通'; case Flavor.xhj: - return '星星锁'; + return '鑫锁'; default: throw Exception('flavor[$name] title not found'); } @@ -91,7 +91,7 @@ class F { case Flavor.sky: return '锁通通'; case Flavor.xhj: - return '星星锁'; + return '鑫锁'; default: throw Exception('flavor[$name] title not found'); } diff --git a/star_lock/lib/main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_page.dart b/star_lock/lib/main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_page.dart deleted file mode 100644 index 533b5110..00000000 --- a/star_lock/lib/main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_page.dart +++ /dev/null @@ -1,45 +0,0 @@ - -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/titleAppBar.dart'; -import '../../../../../translations/trans_lib.dart'; -import 'addCardTypeManage_tabbar.dart'; - -class AddCardTypeManagePage extends StatefulWidget { - const AddCardTypeManagePage({Key? key}) : super(key: key); - - @override - State createState() => _AddCardTypeManagePageState(); -} - -class _AddCardTypeManagePageState extends State { - var index = 0; - - @override - Widget build(BuildContext context) { - Map map = Get.arguments; - var lockId = map["lockId"]; - var fromType = map["fromType"]??1; // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - var fromTypeTwoStaffName = ""; - if(fromType == 2){ - fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字 - } - - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: - "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.card!.tr}", - haveBack: true, - backgroundColor: AppColors.mainColor), - body: Column( - children: [ - AddCardManageTabbar(initialIndex: index, lockId: lockId, fromType: fromType, fromTypeTwoStaffName:fromTypeTwoStaffName), - ], - ), - ); - } - -} diff --git a/star_lock/lib/main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_tabbar.dart b/star_lock/lib/main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_tabbar.dart deleted file mode 100644 index 12d283e2..00000000 --- a/star_lock/lib/main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_tabbar.dart +++ /dev/null @@ -1,123 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; - -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/CustomUnderlineTabIndicator.dart'; -import '../../../../../translations/trans_lib.dart'; -import '../addCardType_page.dart'; - -class AddCardManageTabbar extends StatefulWidget { - var initialIndex = 1; - var lockId = 0; - var fromType = 0; // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - var fromTypeTwoStaffName = ""; // 从添加员工进入 传入员工名字 - - AddCardManageTabbar( - {Key? key, - required this.initialIndex, - required this.lockId, - required this.fromType, - required this.fromTypeTwoStaffName}) - : super(key: key); - - @override - State createState() => _AddCardManageTabbarState(); -} - -class _AddCardManageTabbarState extends State - with SingleTickerProviderStateMixin { - late TabController _tabController; - - final List _itemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), - ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), - ]; - - final List _fromCheckInTypeItemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), - ]; - - @override - void initState() { - // TODO: implement initState - super.initState(); - - _tabController = TabController( - vsync: this, - length: widget.fromType == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, - initialIndex: widget.initialIndex); - _tabController.addListener(() { - print("_tabController.indexIsChanging:${_tabController.indexIsChanging} _tabController.index:${_tabController.index}"); - if (_tabController.animation!.value == _tabController.index) { - FocusScope.of(context).requestFocus(FocusNode()); - } - }); - } - - @override - Widget build(BuildContext context) { - return Expanded( - child: Column( - children: [ - _tabBar(), - _pageWidget(), - ], - )); - } - - TabBar _tabBar() { - return TabBar( - controller: _tabController, - onTap: (index) { - FocusScope.of(context).requestFocus(FocusNode()); - }, - tabs: widget.fromType == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.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( - child: SizedBox( - width: 1.sw / 5, - child: Text(item.title, textAlign: TextAlign.center))); - } - - Widget _pageWidget() { - return Expanded( - child: TabBarView( - controller: _tabController, - children: - widget.fromType == 1 - ? _itemTabs.map((ItemView item) => AddCardPage()).toList() - : _fromCheckInTypeItemTabs.map((ItemView item) => AddCardPage()).toList(), - ), - ); - } -} - -class ItemView { - const ItemView({required this.title, required this.selectType}); - - final String title; - final String selectType; -} 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/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index d8749f88..1948cf27 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -180,7 +180,7 @@ class _CheckingInAddStaffPageState extends State { } break; case 5: - Get.toNamed(Routers.addFaceTypeManagePage, arguments: { + Get.toNamed(Routers.addFaceTypePage, arguments: { "lockId": state.getKeyInfosData.value.lockId, "fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 "fromTypeTwoStaffName": state.staffNameController.text 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/face/addFaceType/addFaceTypeManage/addFaceTypeManage_page.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_page.dart deleted file mode 100644 index 8ed2b3f2..00000000 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_page.dart +++ /dev/null @@ -1,44 +0,0 @@ - -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/titleAppBar.dart'; -import '../../../../../translations/trans_lib.dart'; -import 'addFaceTypeManage_tabbar.dart'; - -class AddFaceTypeManagePage extends StatefulWidget { - const AddFaceTypeManagePage({Key? key}) : super(key: key); - - @override - State createState() => _AddFaceTypeManagePageState(); -} - -class _AddFaceTypeManagePageState extends State { - var index = 0; - - @override - Widget build(BuildContext context) { - Map map = Get.arguments; - var lockId = map["lockId"]; - var fromType = map["fromType"]; // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - var fromTypeTwoStaffName = ""; - if(fromType == 2){ - fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字 - } - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: - "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}", - haveBack: true, - backgroundColor: AppColors.mainColor), - body: Column( - children: [ - AddFaceTypeManageTabbar(lockId: lockId, fromType: fromType, fromTypeTwoStaffName: fromTypeTwoStaffName, initialIndex: index), - ], - ), - ); - } - -} diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_tabbar.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_tabbar.dart deleted file mode 100644 index 34b0ae91..00000000 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_tabbar.dart +++ /dev/null @@ -1,114 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; - -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/CustomUnderlineTabIndicator.dart'; -import '../../../../../translations/trans_lib.dart'; -import '../addFaceType_page.dart'; - -class AddFaceTypeManageTabbar extends StatefulWidget { - var initialIndex = 1; - var lockId = 0; - var fromType = 1; // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - var fromTypeTwoStaffName = "";// 从添加员工进入 传入员工名字 - AddFaceTypeManageTabbar({Key? key, required this.lockId, required this.fromType, required this.fromTypeTwoStaffName, required this.initialIndex}) : super(key: key); - - @override - State createState() => _AddFaceTypeManageTabbarState(); -} - -class _AddFaceTypeManageTabbarState extends State with SingleTickerProviderStateMixin { - late TabController _tabController; - - final List _itemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), - ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), - ]; - - final List _fromCheckInTypeItemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), - ]; - - @override - void initState() { - // TODO: implement initState - super.initState(); - _tabController = TabController( - vsync: this, - length: _itemTabs.length, - initialIndex: widget.initialIndex); - - _tabController.addListener(() { - // print("_tabController.animation!.value:${_tabController.animation!.value} _tabController.index:${_tabController.index}"); - if (_tabController.animation!.value == _tabController.index) { - FocusScope.of(context).requestFocus(FocusNode()); - } - }); - } - - @override - Widget build(BuildContext context) { - return Expanded( - child: Column( - children: [ - _tabBar(), - _pageWidget(), - ], - )); - } - - TabBar _tabBar() { - return TabBar( - controller: _tabController, - tabs: widget.fromType == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.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( - child: SizedBox( - width: 1.sw / 5, - child: Text(item.title, textAlign: TextAlign.center))); - } - - Widget _pageWidget() { - return Expanded( - child: TabBarView( - controller: _tabController, - children: - widget.fromType == 1 - ? _itemTabs.map((ItemView item) => AddFaceTypePage(selectType: item.selectType, lockId: widget.lockId, fromType: widget.fromType, fromTypeTwoStaffName:widget.fromTypeTwoStaffName)).toList() - :_itemTabs.map((ItemView item) => AddFaceTypePage(selectType: item.selectType, lockId: widget.lockId, fromType: widget.fromType, fromTypeTwoStaffName:widget.fromTypeTwoStaffName)).toList(), - - // _itemTabs.map((ItemView item) => AddFaceTypePage(selectType: item.selectType, lockId: widget.lockId, fromType: widget.fromType, fromTypeTwoStaffName:widget.fromTypeTwoStaffName)).toList(), - ), - ); - } -} - -class ItemView { - const ItemView({required this.title, required this.selectType}); - - final String title; - final String selectType; -} diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart index d02c47c9..b791b9c6 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart @@ -16,16 +16,17 @@ class AddFaceTypeLogic extends BaseGetXController { var startTime = ""; var endTime = ""; if (state.selectType.value == "0") { + print("永久卡永久卡永久卡"); faceType = 1; startDate = "0"; endDate = "0"; startTime = "0"; endTime = "0"; } else if (state.selectType.value == "1") { + print("限时卡限时卡限时卡"); faceType = 2; - startDate = - DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); - endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); + startDate = DateTool().dateToTimestamp(state.timeLimitBeginTime.value, 1).toString(); + endDate = DateTool().dateToTimestamp(state.timeLimitEndTime.value, 1).toString(); startTime = "0"; endTime = "0"; @@ -48,16 +49,18 @@ class AddFaceTypeLogic extends BaseGetXController { return; } } else if (state.selectType.value == "2") { - if (state.beginTime.value.isEmpty) { + print("循环卡循环卡循环卡"); + if (state.cycleBeginTime.value.isEmpty) { showToast("请选择有效期".tr); return; } - startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); - endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); + startDate = DateTool().dateToTimestamp(state.cycleBeginTime.value, 1).toString(); + endDate = DateTool().dateToTimestamp(state.cycleEndTime.value, 1).toString(); startTime = DateTool().dateToTimestamp(state.effectiveDateTime.value, 0).toString(); endTime = DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString(); faceType = 4; } + // 人脸 Get.toNamed(Routers.addFacePage, arguments: { "lockId": state.lockId.value, diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart index fd5d2787..fd745afb 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart @@ -9,106 +9,111 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/CustomUnderlineTabIndicator.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/storage.dart'; import '../../../../tools/submitBtn.dart'; +import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; import 'addFaceType_logic.dart'; class AddFaceTypePage extends StatefulWidget { - final String selectType; // 永久限时循环下标 - final int lockId; - final int fromType; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - final String fromTypeTwoStaffName; // 从添加员工进入 传入员工名字 - - const AddFaceTypePage( - {Key? key, - required this.selectType, - required this.lockId, - required this.fromType, - required this.fromTypeTwoStaffName}) - : super(key: key); + const AddFaceTypePage({Key? key}) : super(key: key); @override State createState() => _AddFaceTypePageState(); } -class _AddFaceTypePageState extends State { +class _AddFaceTypePageState extends State with SingleTickerProviderStateMixin { final logic = Get.put(AddFaceTypeLogic()); final state = Get.find().state; - @override - Widget build(BuildContext context) { - state.selectType.value = widget.selectType; - state.lockId.value = widget.lockId; - if (widget.fromTypeTwoStaffName.isNotEmpty) { - state.nameController.text = widget.fromTypeTwoStaffName; - } - state.fromType.value = widget.fromType; - - return indexChangeWidget(); - } - @override void initState() { // TODO: implement initState super.initState(); - WidgetsBinding.instance.addPostFrameCallback((_) { - if (state.selectType.value == "1") { - state.beginTime.value = DateTool().dateToYMDHNString( - DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间 - state.endTime.value = DateTool().dateToYMDHNString( - DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间 - } else { - state.beginTime.value = ""; //默认为当前时间 - state.endTime.value = ""; //默认为当前时间 + state.tabController = TabController( + vsync: this, + length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, + initialIndex: 0); + state.tabController.addListener(() { + WidgetsBinding.instance.addPostFrameCallback((_) { + state.selectType.value = state.tabController.index.toString(); + }); + + if (state.tabController.animation!.value == state.tabController.index) { + FocusScope.of(context).requestFocus(FocusNode()); } }); } + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: + "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}", + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + _tabBar(), + _pageWidget(), + ], + ), + ); + } + Widget indexChangeWidget() { - switch (int.parse(widget.selectType)) { + switch (int.parse(state.selectType.value)) { case 0: { // 永久 - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, - state.nameController), - keyBottomWidget() - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.nameController), + keyBottomWidget() + ], + ), ); } case 1: { // 限时 - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, - state.nameController), - keyTimeLimitWidget(), - keyBottomWidget() - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.nameController), + keyTimeLimitWidget(), + keyBottomWidget() + ], + ), ); } case 2: { // 循环 - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, - state.nameController), - keyCyclicDate(), - SizedBox(height: 10.h), - keyBottomWidget() - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.nameController), + keyCyclicDate(), + SizedBox(height: 10.h), + keyBottomWidget() + ], + ), ); } default: @@ -138,24 +143,24 @@ class _AddFaceTypePageState extends State { children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: state.beginTime.value, + rightTitle: state.timeLimitBeginTime.value, isHaveLine: true, isHaveDirection: true, action: () async { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.beginTime.value = DateTool().getYMDHNDateString(p, 1); - }); + state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: state.endTime.value, + rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.endTime.value = DateTool().getYMDHNDateString(p, 1); - }); + state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Container(height: 10.h), ], @@ -168,47 +173,44 @@ class _AddFaceTypePageState extends State { children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle: "${state.beginTime.value}\n${state.endTime.value}", + rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", isHaveDirection: true, isHaveLine: true, action: () async { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, 'starTime': state.effectiveDateTime.value, 'endTime': state.failureDateTime.value }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; - Get.log( - '得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}'); } })), Obx(() => Visibility( visible: state.weekdaysList.isNotEmpty ? true : false, child: CommonItem( - leftTitel: "有效日", + leftTitel: "有效日".tr, rightTitle: state.weekdaysList.value.join(",").toString(), isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; } @@ -217,25 +219,22 @@ class _AddFaceTypePageState extends State { visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( leftTitel: "有效时间".tr, - rightTitle: - "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", isHaveDirection: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; - Get.back(result: result); } }))), ], @@ -338,4 +337,69 @@ class _AddFaceTypePageState extends State { }, ); } + + final List _itemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), + ]; + + final List _fromCheckInTypeItemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ]; + + TabBar _tabBar() { + return TabBar( + controller: state.tabController, + onTap: (index) { + FocusScope.of(context).requestFocus(FocusNode()); + }, + tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.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( + child: SizedBox( + width: 1.sw / 5, + child: Text(item.title, textAlign: TextAlign.center))); + } + + Widget _pageWidget() { + return Expanded( + child: TabBarView( + controller: state.tabController, + children: + state.fromType.value == 1 + ? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() + : _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), + ), + ); + } + +} + +class ItemView { + const ItemView({required this.title, required this.selectType}); + + final String title; + final String selectType; } diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart index 3ee24ba5..a5abea0e 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart @@ -1,30 +1,33 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import '../../../../tools/dateTool.dart'; + class AddFaceTypeState { final lockId = 0.obs; final selectType = "0".obs; // 0永久 1显示 2循环 final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - var fromTypeTwoStaffName = "".obs; // 考勤添加人脸员工名字 final isStressFingerprint = false.obs; final isAdministrator = false.obs; // 是否是管理员 - var beginTime = "".obs; // 开始时间 - var endTime = "".obs; // 结束时间 - var effectiveDateTime = "".obs; // 生效时间 - var failureDateTime = "".obs; // 失效时间 + var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时开始时间 + var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时结束时间 + var cycleBeginTime = "".obs;// 循环开始时间 + var cycleEndTime = "".obs;// 循环结束时间 + var effectiveDateTime = "".obs;// 生效时间 + var failureDateTime = "".obs;// 失效时间 var weekdaysList = [].obs; + var fromTypeTwoStaffName = "".obs; // 从添加员工进入 传入员工名字 final TextEditingController nameController = TextEditingController(); + late TabController tabController; AddFaceTypeState() { - // Map map = Get.arguments; - // lockId.value = map["lockId"]; - // fromType.value = map["fromType"]; - // if(fromType.value == 2){ - // fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字 - // // nameController.text = fromTypeTwoStaffName.value; - // } - - // print("lockId:${lockId.value} fromType:${fromType.value}"); + Map map = Get.arguments; + lockId.value = map["lockId"]; + fromType.value = map["fromType"]; + // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + if(fromType.value == 2){ + fromTypeTwoStaffName.value = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字 + } } } diff --git a/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart b/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart index 39b4ac16..96c43b4a 100644 --- a/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart +++ b/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart @@ -79,7 +79,7 @@ class _FaceListPageState extends State { '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.face!.tr}', onClick: () async { var data = - await Get.toNamed(Routers.addFaceTypeManagePage, arguments: { + await Get.toNamed(Routers.addFaceTypePage, arguments: { "lockId": state.lockId.value, "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 }); 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/fingerprint/addFingerprintSelectType/addFingerprintManage/addFingerprintTypeManage_page.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintManage/addFingerprintTypeManage_page.dart deleted file mode 100644 index c9578bab..00000000 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintManage/addFingerprintTypeManage_page.dart +++ /dev/null @@ -1,45 +0,0 @@ - -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/titleAppBar.dart'; -import '../../../../../translations/trans_lib.dart'; -import 'addFingerprintTypeManage_tabbar.dart'; - -class AddFingerprintTypeManagePage extends StatefulWidget { - const AddFingerprintTypeManagePage({Key? key}) : super(key: key); - - @override - State createState() => _AddFingerprintTypeManagePageState(); -} - -class _AddFingerprintTypeManagePageState extends State { - var index = 0; - - @override - Widget build(BuildContext context) { - Map map = Get.arguments; - var lockId = map["lockId"]; - var fromType = map["fromType"]; // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - var fromTypeTwoStaffName = ""; - if(fromType == 2){ - fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字 - } - - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: - "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}", - haveBack: true, - backgroundColor: AppColors.mainColor), - body: Column( - children: [ - AddFingerprintTypeManageTabbar(initialIndex: index, lockId: lockId, fromType: fromType, fromTypeTwoStaffName:fromTypeTwoStaffName), - ], - ), - ); - } -} - diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintManage/addFingerprintTypeManage_tabbar.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintManage/addFingerprintTypeManage_tabbar.dart deleted file mode 100644 index b3c51930..00000000 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintManage/addFingerprintTypeManage_tabbar.dart +++ /dev/null @@ -1,117 +0,0 @@ - -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; - -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/CustomUnderlineTabIndicator.dart'; -import '../../../../../translations/trans_lib.dart'; -import '../addFingerprintType_page.dart'; - -class AddFingerprintTypeManageTabbar extends StatefulWidget { - var initialIndex = 1; - var lockId = 0; - var fromType = 0; // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - var fromTypeTwoStaffName = "";// 从添加员工进入 传入员工名字 - - AddFingerprintTypeManageTabbar( - {Key? key, required this.initialIndex, required this.lockId, required this.fromType, required this.fromTypeTwoStaffName}) : super(key: key); - - @override - State createState() => _AddFingerprintTypeManageTabbarState(); -} - -class _AddFingerprintTypeManageTabbarState extends State with SingleTickerProviderStateMixin { - late TabController _tabController; - - final List _itemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), - ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), - ]; - - final List _fromCheckInTypeItemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), - ]; - - @override - void initState() { - // TODO: implement initState - super.initState(); - - _tabController = TabController( - vsync: this, - length: _itemTabs.length, - initialIndex: widget.initialIndex); - _tabController.addListener(() { - if (_tabController.animation!.value==_tabController.index){ - FocusScope.of(context).requestFocus(FocusNode()); - } - }); - } - - @override - Widget build(BuildContext context) { - return Expanded( - child: Column( - children: [ - _tabBar(), - _pageWidget(), - ], - )); - } - - TabBar _tabBar() { - return TabBar( - controller: _tabController, - onTap: (index){ - FocusScope.of(context).requestFocus(FocusNode()); - }, - tabs: widget.fromType == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.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(child: SizedBox( - width: 1.sw / 5, - child: Text(item.title, textAlign: TextAlign.center))); - } - - Widget _pageWidget() { - return Expanded( - child: TabBarView( - controller: _tabController, - children: - widget.fromType == 1 - ? _itemTabs.map((ItemView item) => const AddFingerprintTypePage()).toList() - :_itemTabs.map((ItemView item) => const AddFingerprintTypePage()).toList(), - ), - ); - } - -} - -class ItemView { - const ItemView({required this.title, required this.selectType}); - - final String title; - final String selectType; -} diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart index d591bdf9..8a8a76a0 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart @@ -72,44 +72,50 @@ class _AddFingerprintTypePageState extends State with Si { // 永久 // return sendElectronicKeySucceed(); - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, - state.nameController), - keyBottomWidget() - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.nameController), + keyBottomWidget() + ], + ), ); } case 1: { // 限时 - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, - state.nameController), - keyTimeLimitWidget(), - SizedBox(height: 10.h), - keyBottomWidget() - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.nameController), + keyTimeLimitWidget(), + SizedBox(height: 10.h), + keyBottomWidget() + ], + ), ); } case 2: { // 循环 - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, - state.nameController), - keyCyclicDate(), - SizedBox(height: 10.h), - keyBottomWidget() - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.nameController), + keyCyclicDate(), + SizedBox(height: 10.h), + keyBottomWidget() + ], + ), ); } default: diff --git a/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart b/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart index 79174f46..e25119da 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart @@ -14,6 +14,8 @@ import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart'; import 'package:star_lock/blue/io_reply.dart'; import 'package:star_lock/blue/io_tool/io_tool.dart'; import 'package:star_lock/blue/io_tool/manager_event_bus.dart'; +import 'package:star_lock/blue/sender_manage.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSet_logic.dart'; import 'package:star_lock/permission/permission_dialog.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/commonDataManage.dart'; @@ -64,7 +66,7 @@ class LockEscalationLogic extends BaseGetXController { } String md5Str = md5.convert(otaBin!).toString(); headJson!['fwMd5'] = md5Str; - blueOTAUpgrade(headJson!, [0,0,0,0]); + blueOTAUpgrade(headJson!, [0, 0, 0, 0]); } //蓝牙操作 ota 升级 @@ -76,18 +78,11 @@ class LockEscalationLogic extends BaseGetXController { List getPrivateKeyList = changeStringListToIntList(privateKey!); var signKey = await Storage.getStringList(saveBlueSignKey); List signKeyDataList = changeStringListToIntList(signKey!); - String lockID = CommonDataManage.shareManager() - ?.currentLockSetInfoData - .lockId - ?.toString() ?? - ''; - String keyID = - CommonDataManage.shareManager()?.currentKeyInfo.keyId?.toString() ?? - ''; + String uid = await Storage.getUid() ?? ''; BlueManage().writeCharacteristicWithResponse(OTAUpgradeCommand( - lockID: lockID, - userID: await Storage.getUid(), - keyID: keyID, + lockID: BlueManage().connectDeviceName, + userID: uid, + keyID: BlueManage().connectDeviceName, platform: int.tryParse(data['platform']) ?? 0, product: int.tryParse(data['product']) ?? 0, hwVersion: data['hwVersion'], @@ -96,7 +91,7 @@ class LockEscalationLogic extends BaseGetXController { fwMD5: data['fwMd5'], needAuthor: 1, token: token, - signKey: signKeyDataList, + signKey: signKeyDataList, privateKey: getPrivateKeyList) .packageData()); } else if (deviceConnectionState == @@ -119,10 +114,11 @@ class LockEscalationLogic extends BaseGetXController { } if (otaCount <= otaIndex) { int now = DateTime.now().millisecondsSinceEpoch ~/ 1000; - String msg = '传输完成 时间:${now - startSecond}秒'; + String msg = + '传输完成 时间:${now - startSecond}秒 otaCount:$otaCount otaIndex:$otaIndex '; closeOTADAta(); print(msg); - showToast(msg); + // showToast(msg); return; } int star = otaIndex * 240; @@ -130,10 +126,11 @@ class LockEscalationLogic extends BaseGetXController { if (end > length) { end = length; } + int size = end - star; List data = otaBin!.sublist(star, end); state.otaProgress.value = otaIndex / otaCount; await BlueManage().writeCharacteristicWithResponse( - ProcessOtaUpgradeCommand(index: otaIndex, size: length, data: data) + ProcessOtaUpgradeCommand(index: otaIndex, size: size, data: data) .packageData()); } @@ -173,7 +170,7 @@ class LockEscalationLogic extends BaseGetXController { Uint8List metaLenList = data.sublist(12, 16); int metaLen = ByteData.sublistView(metaLenList).getUint32(0); if (metaLen < 2 || metaLen > 10240) { - showToast('元数据长度错误'); + showToast('文件校验失败 0x01'); return null; } // 读取和解析元数据 @@ -190,13 +187,14 @@ class LockEscalationLogic extends BaseGetXController { // 获取固件数据部分 Uint8List bin = data.sublist(binOffset.toInt(), data.length); //md5 校验有问题,暂时不解析 - // String md5Str = md5.convert(bin).toString(); - // if (md5Str != meta['fwMd5']) { - // showToast('固件MD5校验失败'); - // return false; - // } + String md5Str = md5.convert(bin).toString().toUpperCase(); + print('---> $md5Str ${meta['fwMd5']}'); + if (md5Str != meta['fwMd5']) { + showToast('文件校验失败 0x02'); + return null; + } if (bin.length != meta['fwSize']) { - showToast('固件校验失败'); + showToast('文件校验失败 0x03'); return null; } return bin; @@ -216,6 +214,7 @@ class LockEscalationLogic extends BaseGetXController { if (reply is OTAUpgradeReply) { if (reply.status == 0x00) { //验证通过,开始发送数据包 + startOTAData(); processOtaUpgrade(); } else if (reply.status == 0x06) { blueOTAUpgrade(headJson!, reply.token); 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/main/lockDetail/remoteControl/addRemoteControl/addRemoteControlManage/addRemoteControlManage_page.dart b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControlManage/addRemoteControlManage_page.dart deleted file mode 100644 index c2c5b95a..00000000 --- a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControlManage/addRemoteControlManage_page.dart +++ /dev/null @@ -1,38 +0,0 @@ - -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/titleAppBar.dart'; -import '../../../../../translations/trans_lib.dart'; -import 'addRemoteControlManage_tabbar.dart'; - -class AddRemoteControlManagePage extends StatefulWidget { - const AddRemoteControlManagePage({Key? key}) : super(key: key); - - @override - State createState() => _AddRemoteControlManagePageState(); -} - -class _AddRemoteControlManagePageState extends State { - var index = 0; - - @override - Widget build(BuildContext context) { - - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: - "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.remoteControl!.tr}", - haveBack: true, - backgroundColor: AppColors.mainColor), - body: Column( - children: [ - AddRemoteControlManageTabbar(initialIndex: index), - ], - ), - ); - } - -} diff --git a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControlManage/addRemoteControlManage_tabbar.dart b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControlManage/addRemoteControlManage_tabbar.dart deleted file mode 100644 index 537ced04..00000000 --- a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControlManage/addRemoteControlManage_tabbar.dart +++ /dev/null @@ -1,100 +0,0 @@ - - -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; - -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/CustomUnderlineTabIndicator.dart'; -import '../../../../../translations/trans_lib.dart'; -import '../addRemoteControl_page.dart'; - -class AddRemoteControlManageTabbar extends StatefulWidget { - var initialIndex = 1; - - AddRemoteControlManageTabbar({Key? key, required this.initialIndex}) : super(key: key); - - @override - State createState() => _AddRemoteControlManageTabbarState(); -} - -class _AddRemoteControlManageTabbarState extends State with SingleTickerProviderStateMixin { - late TabController _tabController; - - final List _itemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), - ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), - ]; - - @override - void initState() { - // TODO: implement initState - super.initState(); - _tabController = TabController( - vsync: this, - length: _itemTabs.length, - initialIndex: widget.initialIndex); - } - - @override - Widget build(BuildContext context) { - return Expanded( - child: Column( - children: [ - _tabBar(), - _pageWidget(), - ], - )); - } - - TabBar _tabBar() { - return TabBar( - controller: _tabController, - 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( - child: SizedBox( - width: 1.sw / 5, - child: Text(item.title, textAlign: TextAlign.center))); - } - - Widget _pageWidget() { - return Expanded( - child: TabBarView( - controller: _tabController, - children: _itemTabs - .map((ItemView item) => AddRemoteControlPage(selectType: item.selectType,)) - .toList(), - ), - ); - } -} - -class ItemView { - const ItemView({required this.title, required this.selectType}); - - final String title; - final String selectType; -} - diff --git a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart index e9b094ae..0bf6b189 100644 --- a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart +++ b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart @@ -8,34 +8,67 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/CustomUnderlineTabIndicator.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/dateTool.dart'; import '../../../../tools/storage.dart'; import '../../../../tools/submitBtn.dart'; +import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; import 'addRemoteControl_logic.dart'; class AddRemoteControlPage extends StatefulWidget { - final String selectType; - - const AddRemoteControlPage({Key? key, required this.selectType}) + const AddRemoteControlPage({Key? key}) : super(key: key); @override State createState() => _AddRemoteControlPageState(); } -class _AddRemoteControlPageState extends State { +class _AddRemoteControlPageState extends State with SingleTickerProviderStateMixin { final logic = Get.put(AddRemoteControlLoigc()); final state = Get.find().state; + @override + void initState() { + // TODO: implement initState + super.initState(); + + state.tabController = TabController( + vsync: this, + length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, + initialIndex: 0); + state.tabController.addListener(() { + WidgetsBinding.instance.addPostFrameCallback((_) { + state.selectType.value = state.tabController.index.toString(); + }); + + if (state.tabController.animation!.value == state.tabController.index) { + FocusScope.of(context).requestFocus(FocusNode()); + } + }); + } + @override Widget build(BuildContext context) { - return indexChangeWidget(); + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: + "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}", + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + _tabBar(), + _pageWidget(), + ], + ), + ); } Widget indexChangeWidget() { - switch (int.parse(widget.selectType)) { + switch (int.parse(state.selectType.value)) { case 0: { // 永久 @@ -68,37 +101,18 @@ class _AddRemoteControlPageState extends State { case 2: { // 循环 - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseEnter!.tr, - state.nameController), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle: "", - isHaveDirection: true, - action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); - if(result != null && result.isNotEmpty){ - state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; - state.effectiveDateTime.value = result['starTime']; - state.failureDateTime.value = result['endTime']; - Get.log('得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}'); - } - }), - SizedBox(height: 10.h), - keyBottomWidget() - ], + return SingleChildScrollView( + child: Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseEnter!.tr, + state.nameController), + keyCyclicDate(), + SizedBox(height: 10.h), + keyBottomWidget() + ], + ), ); } default: @@ -127,29 +141,104 @@ class _AddRemoteControlPageState extends State { children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: state.beginTime.value, + rightTitle: state.timeLimitBeginTime.value, isHaveLine: true, isHaveDirection: true, action: () async { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.beginTime.value = DateTool().getYMDHNDateString(p, 1); - }); + state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: state.endTime.value, + rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.endTime.value = DateTool().getYMDHNDateString(p, 1); - }); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Container(height: 10.h), ], ); } + // 循环顶部选择日期 + Widget keyCyclicDate() { + return Column( + children: [ + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, + rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", + isHaveDirection: true, + isHaveLine: true, + action: () async { + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { + state.weekdaysList.value = result['validityValue']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; + state.effectiveDateTime.value = result['starTime']; + state.failureDateTime.value = result['endTime']; + } + })), + Obx(() => Visibility( + visible: state.weekdaysList.isNotEmpty ? true : false, + child: CommonItem( + leftTitel: "有效日".tr, + rightTitle: state.weekdaysList.value.join(",").toString(), + isHaveDirection: true, + isHaveLine: true, + action: () async { + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { + state.weekdaysList.value = result['validityValue']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; + state.effectiveDateTime.value = result['starTime']; + state.failureDateTime.value = result['endTime']; + } + }))), + Obx(() => Visibility( + visible: state.effectiveDateTime.value.isNotEmpty, + child: CommonItem( + leftTitel: "有效时间".tr, + rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + isHaveDirection: true, + action: () async { + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { + state.weekdaysList.value = result['validityValue']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; + state.effectiveDateTime.value = result['starTime']; + state.failureDateTime.value = result['endTime']; + } + }))), + ], + ); + } + Widget keyBottomWidget() { return Column( children: [ @@ -310,4 +399,69 @@ class _AddRemoteControlPageState extends State { }, ); } + + final List _itemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), + ]; + + final List _fromCheckInTypeItemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ]; + + TabBar _tabBar() { + return TabBar( + controller: state.tabController, + onTap: (index) { + FocusScope.of(context).requestFocus(FocusNode()); + }, + tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.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( + child: SizedBox( + width: 1.sw / 5, + child: Text(item.title, textAlign: TextAlign.center))); + } + + Widget _pageWidget() { + return Expanded( + child: TabBarView( + controller: state.tabController, + children: + state.fromType.value == 1 + ? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() + : _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), + ), + ); + } + +} + +class ItemView { + const ItemView({required this.title, required this.selectType}); + + final String title; + final String selectType; } diff --git a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart index 433df90a..6f7ba940 100644 --- a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart +++ b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart @@ -2,13 +2,39 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; -class AddRemoteControlState{ +import '../../../../tools/dateTool.dart'; - var beginTime = "".obs;// 开始时间 - var endTime = "".obs;// 结束时间 +class AddRemoteControlState{ + final lockId = 0.obs; + final selectType = "0".obs;// 0永久 1显示 2循环 + final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + final isStressFingerprint = false.obs; + final isAdministrator = false.obs;// 是否是管理员 + + var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时开始时间 + var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时结束时间 + var cycleBeginTime = "".obs;// 循环开始时间 + var cycleEndTime = "".obs;// 循环结束时间 var effectiveDateTime = "".obs;// 生效时间 var failureDateTime = "".obs;// 失效时间 var weekdaysList = [].obs; + var fromTypeTwoStaffName = "".obs; // 从添加员工进入 传入员工名字 final TextEditingController nameController = TextEditingController(); + late TabController tabController; + AddRemoteControlState() { + Map map = Get.arguments; + if(map["lockId"]!=null){ + lockId.value = map["lockId"]; + } + + if(map["fromType"]!=null){ + fromType.value = map["fromType"]; + // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + if(fromType.value == 2){ + fromTypeTwoStaffName.value = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字 + } + } + } + } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart b/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart index 41cf9980..b5527846 100644 --- a/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart +++ b/star_lock/lib/main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart @@ -6,6 +6,7 @@ import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/commonDataManage.dart'; import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/noData.dart'; import '../../../../tools/showIosTipView.dart'; @@ -69,7 +70,10 @@ class _RemoteControlListPageState extends State { '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.remoteControl!.tr}', onClick: () async { var data = - await Get.toNamed(Routers.addRemoteControlManagePage); + await Get.toNamed(Routers.addRemoteControlPage, arguments: { + "lockId": CommonDataManage().currentLockSetInfoData.lockId, + "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + }); if (data != null) { // 遥控添加 diff --git a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index 09f14344..6821a58f 100644 --- a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -298,6 +298,7 @@ class NearbyLockLogic extends BaseGetXController { IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), + isBeforeAddUser: true, privateKey: getPrivateKeyList, ); @@ -343,6 +344,7 @@ class NearbyLockLogic extends BaseGetXController { IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), + isBeforeAddUser: true, privateKey: getPrivateKeyList, ); } else if (state == BluetoothConnectionState.disconnected) { diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index 7313befe..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); + // } }); } @@ -86,7 +85,8 @@ class SaveLockLogic extends BaseGetXController { needAuthor: 1, publicKey: publicKeyDataList, privateKey: getPrivateKeyList, - token: token); + token: token, + isBeforeAddUser: true); break; case 0x07: //无权限 @@ -151,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 { @@ -234,7 +234,8 @@ class SaveLockLogic extends BaseGetXController { needAuthor:1, publicKey:publicKeyDataList, privateKey:getPrivateKeyList, - token: getTokenList + token: getTokenList, + isBeforeAddUser: true ); } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { dismissEasyLoading(); @@ -282,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{ @@ -379,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(); } diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index 611d3013..31a9e45f 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -32,9 +32,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.27+2024041101:打包提审 # 1.0.27+2024041102:打包预发布环境给田总测试 # 1.0.28+2024041702:打包给欧阳回归测试 -# 1.0.27+2024041702 打包星星锁提审华为 -# 1.0.27+2024041703 打包星星锁提审ios -# 1.0.27+2024042204 打包星星锁提审ios与 android +# 1.0.27+2024041702 打包鑫锁提审华为 +# 1.0.27+2024041703 打包鑫锁提审ios +# 1.0.27+2024042204 打包鑫锁提审ios与 android version: 1.0.27+2024042204