diff --git a/star_lock/images/main/icon_main_normallyOpenMode_center.png b/star_lock/images/main/icon_main_normallyOpenMode_center.png index da4f8732..9e7c7963 100644 Binary files a/star_lock/images/main/icon_main_normallyOpenMode_center.png and b/star_lock/images/main/icon_main_normallyOpenMode_center.png differ diff --git a/star_lock/images/main/icon_main_openLockBtn_center.png b/star_lock/images/main/icon_main_openLockBtn_center.png index c71b3eda..5c976bc8 100644 Binary files a/star_lock/images/main/icon_main_openLockBtn_center.png and b/star_lock/images/main/icon_main_openLockBtn_center.png differ diff --git a/star_lock/lib/app_settings/app_colors.dart b/star_lock/lib/app_settings/app_colors.dart index 9e7a287d..2ac4e057 100644 --- a/star_lock/lib/app_settings/app_colors.dart +++ b/star_lock/lib/app_settings/app_colors.dart @@ -127,4 +127,7 @@ class AppColors { Color.fromRGBO(223, 237, 254, 1); //蓝色背景板 139 148 176 static const msgNoticeTextColor = Color.fromRGBO(139, 148, 176, 1); //消息提醒字体颜色 static const alphaBgViewColor = Color.fromRGBO(0, 0, 0, 0.2); //透明度背景 + + static Color openPassageModeColor = const Color(0xFFEB2A3B);// 首页开启常开模式颜色(红色) + static Color listTimeYellowColor = const Color(0xFFF3BA37);// 首页时间过期颜色(黄色) } diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index 02800e0d..215fe5bb 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -122,7 +122,7 @@ class BlueManage { stateCallBack(deviceConnectionState!); }); }else{ - stopScan(); + // stopScan(); stateCallBack(deviceConnectionState!); } }else{ @@ -151,7 +151,7 @@ class BlueManage { connectDeviceMacAddress = ""; connectStateCallBack(DeviceConnectionState.disconnected); completer.complete(); - await stopScan(); + stopScan(); timer.cancel(); // deviceConnectionState = DeviceConnectionState.disconnected; // print("timer index1:$index"); @@ -162,6 +162,7 @@ class BlueManage { if (knownDeviceIndex >= 0) { // 存在的时候销毁定时器,赋值 connectDeviceMacAddress = scanDevices[knownDeviceIndex].id; + stopScan(); completer.complete(); timer.cancel(); // print("timer index2:$index"); @@ -185,7 +186,7 @@ class BlueManage { await completer.future; } print("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName"); - await stopScan(); + // stopScan(); if (connectDeviceMacAddress.isEmpty) { return; } @@ -194,6 +195,7 @@ class BlueManage { _currentConnectionStream = _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 5)).listen((connectionStateUpdate) async { // 获取状态 deviceConnectionState = connectionStateUpdate.connectionState; + stopScan(); print('2 deviceConnectionState:$deviceConnectionState connectionStateUpdate.connectionState:${connectionStateUpdate.connectionState}'); if (connectionStateUpdate.connectionState == DeviceConnectionState.connected) { // 如果状态是连接的开始发现服务 @@ -326,7 +328,7 @@ class BlueManage { } // 停止扫描蓝牙设备 - Future stopScan() async { + void stopScan() { // print("444444444"); if(_scanSubscription != null){ // print("555555555555"); diff --git a/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart b/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart index 1bbaca9e..f0d272cf 100644 --- a/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart +++ b/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart @@ -23,7 +23,7 @@ class SenderCustomPasswordsCommand extends SenderProtocol { int? startTime; int? endTime; int? needAuthor; - List? publicKey; + List? signKey; List? privateKey; SenderCustomPasswordsCommand({ @@ -36,7 +36,7 @@ class SenderCustomPasswordsCommand extends SenderProtocol { this.startTime, this.endTime, this.needAuthor, - this.publicKey, + this.signKey, this.privateKey, }) : super(CommandType.generalExtendedCommond); @@ -102,16 +102,16 @@ class SenderCustomPasswordsCommand extends SenderProtocol { } else { List authCodeData = []; - //authUserID - authCodeData.addAll(utf8.encode(userID!)); - //KeyID authCodeData.addAll(utf8.encode(keyID!)); + //authUserID + authCodeData.addAll(utf8.encode(userID!)); + //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 authCodeData.addAll(token!); - authCodeData.addAll(publicKey!); + authCodeData.addAll(signKey!); print("${commandType!.typeValue}-authCodeData:$authCodeData"); diff --git a/star_lock/lib/blue/sender_manage.dart b/star_lock/lib/blue/sender_manage.dart index e1df2776..c479d474 100644 --- a/star_lock/lib/blue/sender_manage.dart +++ b/star_lock/lib/blue/sender_manage.dart @@ -268,7 +268,7 @@ class IoSenderManage { required int? startTime, required int? endTime, required int? needAuthor, - required List? publicKey, + required List? signKey, required List? privateKey, CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( @@ -282,7 +282,7 @@ class IoSenderManage { startTime: startTime, endTime: endTime, needAuthor: needAuthor, - publicKey: publicKey, + signKey: signKey, privateKey: privateKey, ), callBack:callBack); } diff --git a/star_lock/lib/login/login/starLock_login_logic.dart b/star_lock/lib/login/login/starLock_login_logic.dart index 4f237b02..24007d31 100644 --- a/star_lock/lib/login/login/starLock_login_logic.dart +++ b/star_lock/lib/login/login/starLock_login_logic.dart @@ -5,7 +5,6 @@ import 'package:star_lock/tools/baseGetXController.dart'; import '../../mine/mine/starLockMine_logic.dart'; import '../../network/api_repository.dart'; -import '../../tools/store_service.dart'; import 'starLock_login_state.dart'; class StarLockLoginLogic extends BaseGetXController { diff --git a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart index e8c8d868..b9cf2937 100644 --- a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart +++ b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; 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/tools/pickers/pickers.dart'; @@ -301,24 +302,35 @@ class _AddCardPageState extends State { // 接受者信息输入框 Widget getTFWidget(String tfStr) { return Container( - height: 50.h, + // color: Colors.red, + height: 65.h, width: 300.w, + padding: EdgeInsets.only(top: 5.h), child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: TextField( //输入框一行 maxLines: 1, + inputFormatters: [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(18), + ], controller: state.nameController, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, - hintStyle: TextStyle(fontSize: 24.sp), - //不需要输入框下划线 - border: InputBorder.none, + hintStyle: TextStyle(fontSize: 22.sp), + focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + contentPadding: const EdgeInsets.symmetric(vertical: 0), ), ), ), diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart index 545dc065..17110986 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart @@ -1,12 +1,14 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/dateTool.dart'; +import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/left_slide_actions.dart'; import '../../../../tools/noData.dart'; import '../../../../tools/showIosTipView.dart'; @@ -57,7 +59,12 @@ class _CardListPageState extends State { ), body: Column( children: [ - _searchWidget(), + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { + logic.getICCardListData(); + }, + ), SizedBox(height: 20.h), Expanded(child: _buildMainUI()), AddBottomWhiteBtn( @@ -82,49 +89,6 @@ class _CardListPageState extends State { ); } - Widget _searchWidget() { - return Container( - height: 60.h, - margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), - decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(5)), - child: TextField( - //输入框一行 - maxLines: 1, - controller: state.searchController, - autofocus: false, - onChanged: (value) { - print("onChanged:$value"); - }, - onEditingComplete: () { - print("onEditingComplete:"); - }, - onSubmitted: (value) { - logic.getICCardListData(); - }, - decoration: InputDecoration( - //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only( - top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), - hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, - hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), - //不需要输入框下划线 - border: InputBorder.none, - //左边图标设置 - icon: Padding( - padding: EdgeInsets.only( - top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), - child: Image.asset( - 'images/main/icon_main_search.png', - width: 40.w, - height: 40.w, - ), - ), - ), - ), - ); - } - Widget _buildMainUI() { return Obx(() => state.fingerprintItemListData.value.isNotEmpty ? ListView.separated( diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 8d14efb5..27ffd7ed 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -11,6 +11,7 @@ import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/toast.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/left_slide_actions.dart'; import '../../../../tools/showIosTipView.dart'; import '../../../../tools/submitBtn.dart'; @@ -73,7 +74,13 @@ class _ElectronicKeyListPageState extends State { ), body: Column( children: [ - _searchWidget(), + // _searchWidget(), + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { + logic.mockNetworkDataRequest(); + }, + ), SizedBox( height: 20.h, ), @@ -128,45 +135,45 @@ class _ElectronicKeyListPageState extends State { _refreshController.refreshCompleted(); } - Widget _searchWidget() { - return Container( - height: 60.h, - margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), - decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(5)), - child: TextField( - //输入框一行 - maxLines: 1, - // controller: _controller, - autofocus: false, - controller: state.searchController, - onSubmitted: (value) { - logic.mockNetworkDataRequest(); - }, - decoration: InputDecoration( - //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only( - top: 18.0, left: -19.0, right: -15.0, bottom: 2), - hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, - hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), - //不需要输入框下划线 - border: InputBorder.none, - //左边图标设置 - icon: Padding( - padding: EdgeInsets.only( - top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), - child: Image.asset( - 'images/main/icon_main_search.png', - width: 40.w, - height: 40.w, - ), - ), - ), - style: - TextStyle(fontSize: 22.sp, textBaseline: TextBaseline.alphabetic), - ), - ); - } + // Widget _searchWidget() { + // return Container( + // height: 60.h, + // margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), + // decoration: BoxDecoration( + // color: Colors.white, borderRadius: BorderRadius.circular(5)), + // child: TextField( + // //输入框一行 + // maxLines: 1, + // // controller: _controller, + // autofocus: false, + // controller: state.searchController, + // onSubmitted: (value) { + // logic.mockNetworkDataRequest(); + // }, + // decoration: InputDecoration( + // //输入里面输入文字内边距设置 + // contentPadding: const EdgeInsets.only( + // top: 18.0, left: -19.0, right: -15.0, bottom: 2), + // hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, + // hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), + // //不需要输入框下划线 + // border: InputBorder.none, + // //左边图标设置 + // icon: Padding( + // padding: EdgeInsets.only( + // top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), + // child: Image.asset( + // 'images/main/icon_main_search.png', + // width: 40.w, + // height: 40.w, + // ), + // ), + // ), + // style: + // TextStyle(fontSize: 22.sp, textBaseline: TextBaseline.alphabetic), + // ), + // ); + // } Widget _buildMainUI(itemData) { List getItemData = itemData; diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index 442f4485..4a86c10c 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -431,7 +431,7 @@ class _SendElectronicKeyPageState extends State { // 接受者信息输入框 Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex) { return SizedBox( - height: 50.h, + height: 65.h, width: 320.w, child: Row( children: [ @@ -442,16 +442,31 @@ class _SendElectronicKeyPageState extends State { : state.keyNameController, //输入框一行 maxLines: 1, + inputFormatters: [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(18), + ], // controller: _controller, autofocus: false, textAlign: TextAlign.end, + // decoration: InputDecoration( + // //输入里面输入文字内边距设置 + // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + // hintText: tfStr, + // hintStyle: TextStyle(fontSize: 22.sp), + // //不需要输入框下划线 + // border: InputBorder.none, + // ), decoration: InputDecoration( //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, hintStyle: TextStyle(fontSize: 22.sp), - //不需要输入框下划线 - border: InputBorder.none, + focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + contentPadding: const EdgeInsets.symmetric(vertical: 0), ), style: TextStyle( fontSize: 22.sp, textBaseline: TextBaseline.alphabetic), 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 54ebb4e4..24e179f1 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart @@ -118,7 +118,7 @@ class AddFingerprintLogic extends BaseGetXController { print("${reply.commandType!.typeValue} 数据解析成功"); if(reply.data[5] == 255){ // 注册指纹失败 - print("${reply.commandType!.typeValue} 注册指纹失败"); + // print("${reply.commandType!.typeValue} 注册指纹失败"); Toast.show(msg: "添加失败"); Get.close(2); }else{ diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSeletType/addFingerprintType_page.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSeletType/addFingerprintType_page.dart index 2dd6c869..5b88da2f 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSeletType/addFingerprintType_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSeletType/addFingerprintType_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; // import 'package:flutter_pickers/pickers.dart'; // import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -284,24 +285,35 @@ class _AddFingerprintTypePageState extends State { // 接受者信息输入框 Widget getTFWidget(String tfStr) { return Container( - height: 50.h, + // color: Colors.red, + height: 65.h, width: 300.w, + padding: EdgeInsets.only(top: 5.h), child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: TextField( //输入框一行 maxLines: 1, + inputFormatters: [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(18), + ], controller: state.nameController, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, - hintStyle: TextStyle(fontSize: 24.sp), - //不需要输入框下划线 - border: InputBorder.none, + hintStyle: TextStyle(fontSize: 22.sp), + focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + contentPadding: const EdgeInsets.symmetric(vertical: 0), ), ), ), diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart index 4816167e..a742b38f 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart @@ -32,7 +32,7 @@ class _FingerprintDetailPageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: "${TranslationLoader.lanKeys!.fingerprint!.tr}${TranslationLoader.lanKeys!.number!.tr}", + barTitle: "指纹详情", haveBack: true, backgroundColor: AppColors.mainColor, // actionsList: [ diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index a4f18282..c6e862b3 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -1,12 +1,14 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/dateTool.dart'; +import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/left_slide_actions.dart'; import '../../../../tools/noData.dart'; import '../../../../tools/showIosTipView.dart'; @@ -57,7 +59,12 @@ class _FingerprintListPageState extends State { ), body: Column( children: [ - _searchWidget(), + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { + logic.getFingerprintsListData(); + }, + ), SizedBox( height: 20.h, ), @@ -81,49 +88,6 @@ class _FingerprintListPageState extends State { ); } - Widget _searchWidget() { - return Container( - height: 60.h, - margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), - decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(5)), - child: TextField( - //输入框一行 - maxLines: 1, - controller: state.searchController, - autofocus: false, - onChanged: (value) { - print("onChanged:$value"); - }, - onEditingComplete: () { - print("onEditingComplete:"); - }, - onSubmitted: (value) { - logic.getFingerprintsListData(); - }, - decoration: InputDecoration( - //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only( - top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), - hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, - hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), - //不需要输入框下划线 - border: InputBorder.none, - //左边图标设置 - icon: Padding( - padding: EdgeInsets.only( - top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), - child: Image.asset( - 'images/main/icon_main_search.png', - width: 40.w, - height: 40.w, - ), - ), - ), - ), - ); - } - Widget _buildMainUI() { return Obx(() => state.fingerprintItemListData.value.isNotEmpty ? ListView.separated( diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart index ee6a22b5..d071c8a7 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart @@ -316,6 +316,7 @@ class LockBasicInfo { String? mac; int? keyRight; int? senderUserId; + int? lockUserNo; LockBasicInfo( {this.keyId, @@ -332,7 +333,8 @@ class LockBasicInfo { this.endDate, this.mac, this.keyRight, - this.senderUserId}); + this.senderUserId, + this.lockUserNo}); LockBasicInfo.fromJson(Map json) { keyId = json['keyId']; @@ -355,7 +357,7 @@ class LockBasicInfo { mac = json['mac']; keyRight = json['keyRight']; senderUserId = json['senderUserId']; - + lockUserNo = json['lockUserNo']; } Map toJson() { @@ -377,6 +379,7 @@ class LockBasicInfo { data['mac'] = mac; data['keyRight'] = keyRight; data['senderUserId'] = senderUserId; + data['lockUserNo'] = lockUserNo; return data; } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart index 3296a4c1..3b0af070 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart @@ -449,7 +449,11 @@ class LockSetLogic extends BaseGetXController { if (entity.errorCode!.codeIsSuccessful) { BlueManage().connectDeviceMacAddress = ""; eventBus.fire(RefreshLockListInfoDataEvent()); - Get.close(2); + if(state.isOnlyOneData.value == true){ + Get.close(1); + }else{ + Get.close(2); + } } } @@ -462,7 +466,11 @@ class LockSetLogic extends BaseGetXController { if (entity.errorCode!.codeIsSuccessful) { BlueManage().connectDeviceMacAddress = ""; eventBus.fire(RefreshLockListInfoDataEvent()); - Get.close(2); + if(state.isOnlyOneData.value == true){ + Get.close(1); + }else{ + Get.close(2); + } // Get.offAllNamed(Routers.starLockMain); } } @@ -510,8 +518,14 @@ class LockSetLogic extends BaseGetXController { // 如果是锁拥有者直接删除锁,调用初始化协议 factoryDataResetAction(); } else { - // 不是锁拥有者,调用删除钥匙协议 - deletUserAction(); + // 不是锁拥有者 + if(state.lockSetInfoData.value.lockBasicInfo!.lockUserNo != 0){ + // 如果已经创建了用户调用协议删除 + deletUserAction(); + }else{ + // 如果没有创建用户 调用接口删除 + deletKeyData(); + } } return; } @@ -573,8 +587,14 @@ class LockSetLogic extends BaseGetXController { // 如果是锁拥有者直接删除锁,调用初始化协议 factoryDataResetAction(); } else { - // 不是锁拥有者,调用删除钥匙协议 - deletUserAction(); + // 不是锁拥有者 + if(state.lockSetInfoData.value.lockBasicInfo!.lockUserNo != 0){ + // 如果已经创建了用户调用协议删除 + deletUserAction(); + }else{ + // 如果没有创建用户 调用接口删除 + deletKeyData(); + } } }else if(state.currentDeviceUUid.value[31] == "0"){ // 未配对 表示这把锁已被强制初始化 处于可添加状态 直接弹窗删除即可 diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart index 911d89da..76184d19 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -107,8 +107,8 @@ class _LockSetPageState extends State with RouteAware { }))), // 常开模式 Obx(() => Visibility( - visible: state.lockFeature.value.passageMode == 1 ? true : false, - // visible:true, + // visible: state.lockFeature.value.passageMode == 1 ? true : false, + visible:true, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.normallyOpenMode!.tr, rightTitle: (state.lockSettingInfo.value.passageMode ?? 0) == 1 @@ -287,8 +287,8 @@ class _LockSetPageState extends State with RouteAware { SizedBox(height: 10.h), // 常开模式 Obx(() => Visibility( - // visible: state.lockFeature.value.passageMode == 1 ? true : false, - visible:true, + visible: state.lockFeature.value.passageMode == 1 ? true : false, + // visible:true, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.normallyOpenMode!.tr, rightTitle: (state.lockSettingInfo.value.passageMode ?? 0) == 1 diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart index 7215221c..5bae118a 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart @@ -13,7 +13,9 @@ class LockSetState { final lockBasicInfo = LockBasicInfo().obs; final lockId = 0.obs; + // var lockCount = 1; + var isOnlyOneData = false.obs; var isAttendance = 0.obs;// 是否开启考勤 var currentDeviceUUid = "".obs;// 当前设备的uuid var isOpenLockNeedOnline = 0.obs;// APP开锁时是否需联网 @@ -34,7 +36,7 @@ class LockSetState { LockSetState() { Map map = Get.arguments; lockId.value = map["lockId"]; - + isOnlyOneData.value = map["isOnlyOneData"]; // getKeyInfosData.value = Get.arguments as KeyInfos; // isAttendance.value = getKeyInfosData.value.isAttendance!; // isLockPickingReminder.value = getKeyInfosData.value.monitorFlag!; diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart index be5637d6..613a681e 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart @@ -29,7 +29,7 @@ class LockSoundSetLogic extends BaseGetXController { if(entity.errorCode!.codeIsSuccessful){ // eventBus.fire(RefreshLockListInfoDataEvent()); - state.lockSetInfoData.value.lockSettingInfo!.lockSound = state.isOpenLockSound.value == true ? 1 :2; + state.lockSetInfoData.value.lockSettingInfo!.lockSound = state.isOpenLockSound.value == true ? 1 :0; state.lockSetInfoData.value.lockSettingInfo!.lockSoundVolume = state.lockSoundLevel.value; eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); Toast.show(msg: "操作成功"); diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart index b354be0b..f303a931 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart @@ -25,7 +25,7 @@ class NormallyOpenModeLogic extends BaseGetXController{ // 配置锁的常开模式设置 void configPassageMode() async{ - if(state.weekDays.value.isNotEmpty){ + if(state.weekDays.value.isEmpty){ Toast.show(msg:"请选择常开日期"); return; } @@ -35,24 +35,27 @@ class NormallyOpenModeLogic extends BaseGetXController{ return; } + var passageModeConfig = []; var map = { "isAllDay":state.isAllDay.value, "weekDays":state.weekDays.value, "startDate":state.beginTimeMinute.value, "endDate":state.endTimeMinute.value, }; + passageModeConfig.add(map); // print("state.isOpenNormallyOpenMode.value:${state.isOpenNormallyOpenMode.value}"); var entity = await ApiRepository.to.setNormallyModeData( lockId: state.lockSetInfoData.value.lockId!, passageMode:state.isOpenNormallyOpenMode.value == true ? 1:0, - passageModeConfig: map, + passageModeConfig: passageModeConfig, ); if(entity.errorCode!.codeIsSuccessful){ eventBus.fire(RefreshLockListInfoDataEvent()); - state.lockSetInfoData.value.lockSettingInfo!.passageMode = state.isOpenNormallyOpenMode.value == true ? 1:2; + state.lockSetInfoData.value.lockSettingInfo!.passageMode = state.isOpenNormallyOpenMode.value == true ? 1:0; eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); + eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(2, state.lockSetInfoData.value.lockSettingInfo!.passageMode!)); Toast.show(msg: "操作成功"); } } @@ -218,7 +221,7 @@ class NormallyOpenModeLogic extends BaseGetXController{ list.add(state.isAllDay.value == 1 ? 1:0); list.add(number); list.add(0); - print("listlistlistlist:$list"); + // print("listlistlistlist:$list"); IoSenderManage.setSupportFunctionsWithParametersCommand( keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart index 2be632c1..9fd3bed0 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart @@ -193,7 +193,7 @@ class _NormallyOpenModePageState extends State with RouteA } state.weekDays.value.sort(); setState(() {}); - // print("index:$index data:${state.normallyOpenPeriod.value}"); + print("index:$index data:${state.weekDays.value}"); }, child: Obx(() => Container( width: 40.w, diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart index 6cd3f0f6..8095b856 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart @@ -8,7 +8,7 @@ class NormallyOpenModeState{ var isJustForShow = false.obs;// 是否只是作为展示作用,因为普通用户只是展示,不可修改 // var getPassageModeConfigData = GetPassageModeConfigEntity().obs; - var isOpenNormallyOpenMode = false.obs;// 是否开启常开模式 常开模式:1-开启、2-关闭 + var isOpenNormallyOpenMode = false.obs;// 是否开启常开模式 常开模式:1-开启、0-关闭 // var isOpenAutomaticUnLock = false.obs;// 是否开启自动开锁模式 自动开锁:1-开启、2-关闭,开启后锁将在常开模式开始时自动打开 var isAllDay = 0.obs;// 是否开启全天模式 是否全天常开:1-是、2-否, 如果全天常开,startDate和endDate参数将被忽略. var weekDays = [].obs;// 常开时期 diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 520529ce..d62981f1 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -653,6 +653,10 @@ class LockDetailLogic extends BaseGetXController { // 1 开锁时是否需联网 state.isOpenLockNeedOnline.value = event.setResult; state.keyInfos.value.lockSetting!.appUnlockOnline = event.setResult; + } else if (event.type == 2) { + // 2 常开模式 + state.isOpenPassageMode.value = event.setResult; + state.keyInfos.value.passageMode = event.setResult; } }); } diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart index aafce16f..2391ef3a 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart @@ -25,7 +25,7 @@ class _LockDetailMainPageState extends State { @override Widget build(BuildContext context) { - final bool isFrist; + final bool isOnlyOneData; LockListInfoItemEntity keyInfos = LockListInfoItemEntity(); // LockMainEntity lockEntity = LockMainEntity(); @@ -36,13 +36,15 @@ class _LockDetailMainPageState extends State { if (obj != null && (obj["keyInfo"] != null)) { keyInfos = obj["keyInfo"]; } + isOnlyOneData = obj["isOnlyOneData"]; + return Scaffold( backgroundColor: Colors.white, appBar: TitleAppBar( barTitle: TranslationLoader.lanKeys!.starLock!.tr, haveBack: true, backgroundColor: AppColors.mainColor), - body: LockDetailPage(isFrist:true, lockListInfoItemEntity: keyInfos), + body: LockDetailPage(isOnlyOneData:isOnlyOneData, lockListInfoItemEntity: keyInfos), // body: Container(), ); } diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 43a82fe6..5dbcc3b0 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -16,11 +16,11 @@ import '../../lockMian/entity/lockListInfo_entity.dart'; import 'lockDetail_logic.dart'; class LockDetailPage extends StatefulWidget { - final bool isFrist; + final bool isOnlyOneData; final LockListInfoItemEntity lockListInfoItemEntity; const LockDetailPage( - {Key? key, required this.isFrist, required this.lockListInfoItemEntity}) + {Key? key, required this.isOnlyOneData, required this.lockListInfoItemEntity}) : super(key: key); @override @@ -38,7 +38,7 @@ class _LockDetailPageState extends State void initState() { // TODO: implement initState super.initState(); - + print("LockDetailPage isOnlyOneData==${widget.isOnlyOneData}"); state.keyInfos.value = widget.lockListInfoItemEntity; state.lockUserNo = state.keyInfos.value.lockUserNo!; state.senderUserId = state.keyInfos.value.senderUserId!; @@ -46,6 +46,7 @@ class _LockDetailPageState extends State state.isOpenLockNeedOnline.value = state.keyInfos.value.lockSetting!.appUnlockOnline!; state.electricQuantity.value = state.keyInfos.value.electricQuantity!; + state.isOpenPassageMode.value = state.keyInfos.value.passageMode!; BlueManage().connectDeviceName = state.keyInfos.value.bluetooth!.bluetoothDeviceName!; @@ -119,12 +120,13 @@ class _LockDetailPageState extends State children: [ SizedBox( width: 1.sw - 120.w * 2, - child: Center( + child: Obx(() => Center( child: Text( - widget.lockListInfoItemEntity.lockAlias!, - style: - TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400), - ))), + widget.lockListInfoItemEntity.lockAlias!, + style: + TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400, color: state.isOpenPassageMode.value == 1 ? AppColors.openPassageModeColor : AppColors.darkGrayTextColor), + ))) + ), Positioned( child: Obx(() => Row( mainAxisAlignment: MainAxisAlignment.end, @@ -156,7 +158,7 @@ class _LockDetailPageState extends State children: [ Image.asset( // state.connectState.value == 0 ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png', - 'images/main/icon_main_openLockBtn_center.png', + state.isOpenPassageMode.value == 1 ? 'images/main/icon_main_normallyOpenMode_center.png' : 'images/main/icon_main_openLockBtn_center.png', width: 330.w, height: 330.w, ), @@ -164,7 +166,8 @@ class _LockDetailPageState extends State ? buildRotationTransition() : Positioned( child: Image.asset( - 'images/main/icon_main_openLockBtn_circle.png', + // 'images/main/icon_main_openLockBtn_circle.png', + state.isOpenPassageMode.value == 1 ? 'images/main/icon_main_normallyOpenMode_circle.png' : 'images/main/icon_main_openLockBtn_circle.png', width: 330.w, height: 330.w, )), @@ -203,13 +206,13 @@ class _LockDetailPageState extends State Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( - TranslationLoader.lanKeys!.clickUnlockAndHoldDownClose!.tr, + Obx(() => Text( + state.isOpenPassageMode.value == 1 ? "常开模式启动!长按闭锁" : TranslationLoader.lanKeys!.clickUnlockAndHoldDownClose!.tr, style: TextStyle( fontSize: 22.sp, color: AppColors.btnDisableColor, fontWeight: FontWeight.w500), - ), + )), ], ), SizedBox( @@ -222,43 +225,32 @@ class _LockDetailPageState extends State 'images/icon_electronicKey_admin.png', width: 24.w, height: 20.w, - color: AppColors.mainColor, //应根据状态显示(当前角色为超级管理员 应显示蓝色图标) - ), - SizedBox( - width: 6.w, + color: AppColors.blackColor, //应根据状态显示(当前角色为超级管理员 应显示蓝色图标) ), + SizedBox(width: 6.w), Text( state.keyInfos.value.isLockOwner == 1 ? TranslationLoader.lanKeys!.superAdmin!.tr - : (state.keyInfos.value.keyRight == 1 - ? TranslationLoader.lanKeys!.authorizedAdmin!.tr - : TranslationLoader.lanKeys!.normalUser!.tr), + : (state.keyInfos.value.keyRight == 1 ? TranslationLoader.lanKeys!.authorizedAdmin!.tr : TranslationLoader.lanKeys!.normalUser!.tr), style: TextStyle( fontSize: 20.sp, color: AppColors.darkGrayTextColor), ), - SizedBox( - width: 80.w, - ), + SizedBox(width: 80.w), Image.asset( - state.keyInfos.value.remoteEnable == 1 - ? 'images/main/icon_main_remoteUnlocking.png' - : 'images/main/icon_main_remoteUnlocking_grey.png', + state.keyInfos.value.remoteEnable == 1 ? 'images/main/icon_main_remoteUnlocking.png' : 'images/main/icon_main_remoteUnlocking_grey.png', width: 24.w, height: 20.w, // color: state.keyInfos.value.remoteEnable == 1 // ? AppColors.btnDisableColor // : AppColors.mainColor, ), - SizedBox( - width: 6.w, - ), + SizedBox(width: 6.w), Text( TranslationLoader.lanKeys!.gatewayDevice!.tr, style: TextStyle( fontSize: 20.sp, - color: state.keyInfos.value.remoteEnable == 1 - ? AppColors.mainColor - : AppColors.btnDisableColor), + color: state.keyInfos.value.remoteEnable == 1 ? AppColors.mainColor : AppColors.btnDisableColor + ), ), ], ), @@ -285,7 +277,7 @@ class _LockDetailPageState extends State turns: state.animationController, //将要执行动画的子view child: Image.asset( - 'images/main/icon_main_openLockBtn_circle.png', + state.isOpenPassageMode.value == 1 ? 'images/main/icon_main_normallyOpenMode_circle.png' : 'images/main/icon_main_openLockBtn_circle.png', width: 330.w, height: 330.w, ), @@ -322,19 +314,16 @@ class _LockDetailPageState extends State List getNormalWidget() { var showWidgetArr = [ // 操作记录 - bottomItem('images/main/icon_main_operatingRecord.png', - TranslationLoader.lanKeys!.operatingRecord!.tr, () { - Get.toNamed(Routers.lockOperatingRecordPage, - arguments: {"keyInfo": widget.lockListInfoItemEntity}); + bottomItem('images/main/icon_main_operatingRecord.png', TranslationLoader.lanKeys!.operatingRecord!.tr, () { + Get.toNamed(Routers.lockOperatingRecordPage, arguments: {"keyInfo": widget.lockListInfoItemEntity}); }), // 设置 - bottomItem( - 'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, - () { - // BlueManage().stopScan(); - Get.toNamed(Routers.lockSetPage, - arguments: {"lockId": widget.lockListInfoItemEntity.lockId}); + bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, () { + Get.toNamed(Routers.lockSetPage, arguments: { + "lockId": widget.lockListInfoItemEntity.lockId, + "isOnlyOneData": widget.isOnlyOneData, + }); }), ]; return showWidgetArr; @@ -455,8 +444,10 @@ class _LockDetailPageState extends State 'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, () { // BlueManage().stopScan(); - Get.toNamed(Routers.lockSetPage, - arguments: {"lockId": widget.lockListInfoItemEntity.lockId}); + Get.toNamed(Routers.lockSetPage, arguments: { + "lockId": widget.lockListInfoItemEntity.lockId, + "isOnlyOneData": widget.isOnlyOneData, + }); }), ]; showWidgetArr.addAll(endWiddget); diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart index 6070f132..74d851a3 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart @@ -25,6 +25,7 @@ class LockDetailState { var isAttendance = 0.obs;// 是否开启考勤 var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网 var electricQuantity = 0.obs; // 电量 + var isOpenPassageMode = 0.obs; // 是否开启了常开模式 var currentDeviceUUid = "".obs;// 当前设备的uuid @@ -38,4 +39,9 @@ class LockDetailState { // var lockState = 0.obs;// 0未连接普通状态 1连接开锁中(展示动画) 2已连接开锁成功 3检测可用性 4连接失败 5连接失败重连中 var openLockBtnState = 0.obs;// 0普通状态(未转动) 1连接中(转动状态) // var connectState = 0.obs;// 0未连接 1连接 + + // LockDetailState() { + // Map map = Get.arguments; + // lockCount = map["lockCount"]; + // } } \ No newline at end of file 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 2086be85..faebdda0 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -10,6 +10,7 @@ import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/toast.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/left_slide_actions.dart'; import '../../../../tools/showIosTipView.dart'; import '../../../../tools/submitBtn.dart'; @@ -71,7 +72,13 @@ class _PasswordKeyListPageState extends State { ), body: Column( children: [ - _searchWidget(), + // _searchWidget(), + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { + logic.mockNetworkDataRequest(); + }, + ), SizedBox( height: 20.h, ), diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index 71de3f8c..1177b345 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -178,17 +178,16 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { case 0x00: //成功 print("${reply.commandType!.typeValue} 数据解析成功"); - + addKeyboardPwdRequest(); break; case 0x06: //无权限 print("${reply.commandType!.typeValue} 需要鉴权"); var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = - changeStringListToIntList(privateKey!); + List getPrivateKeyList = changeStringListToIntList(privateKey!); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); print('得到的开始时间时间戳$getStartDate'); @@ -201,7 +200,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { startTime: 0x11223344, endTime: 0x11223344, needAuthor: 1, - publicKey: publicKeyDataList, + signKey: signKeyDataList, privateKey: getPrivateKeyList, token: token); break; @@ -231,11 +230,10 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { // 设置自定义密码 Future senderCustomPasswords() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, - (DeviceConnectionState state) async { - if (state == DeviceConnectionState.connected) { - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + if (deviceConnectionState == DeviceConnectionState.connected) { + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -248,12 +246,12 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { keyID: "1", userID: await Storage.getUid(), pwdNo: 1, - pwd: "123456", + pwd:state.pwdController.text, useCountLimit: 0xff, startTime: 0x11223344, endTime: 0x11223344, needAuthor: 1, - publicKey: publicKeyDataList, + signKey: signKeyDataList, privateKey: getPrivateKeyList, token: getTokenList); } 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 ebae5be7..79eaca9a 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 @@ -430,7 +430,7 @@ class _PasswordKeyPerpetualPageState extends State { } } - logic.addKeyboardPwdRequest(); + logic.senderCustomPasswords(); } else { if (state.nameController.text.isEmpty) { Toast.show(msg: '请输入姓名'); @@ -539,7 +539,7 @@ class _PasswordKeyPerpetualPageState extends State { // 接受者信息输入框 Widget getTFWidget(String tfStr, TextEditingController editController) { return SizedBox( - height: 50.h, + height: 65.h, width: 300.w, child: Row( children: [ @@ -547,16 +547,31 @@ class _PasswordKeyPerpetualPageState extends State { child: TextField( //输入框一行 maxLines: 1, + inputFormatters: [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(18), + ], controller: editController, autofocus: false, textAlign: TextAlign.end, + // decoration: InputDecoration( + // //输入里面输入文字内边距设置 + // contentPadding: EdgeInsets.only(top: 24.h, bottom: 16.h), + // hintText: tfStr, + // hintStyle: TextStyle(fontSize: 22.sp), + // //不需要输入框下划线 + // border: InputBorder.none, + // ), decoration: InputDecoration( //输入里面输入文字内边距设置 - contentPadding: EdgeInsets.only(top: 24.h, bottom: 16.h), + // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, hintStyle: TextStyle(fontSize: 22.sp), - //不需要输入框下划线 - border: InputBorder.none, + focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + contentPadding: const EdgeInsets.symmetric(vertical: 0), ), ), ), diff --git a/star_lock/lib/main/lockMian/lockList/lockList_logic.dart b/star_lock/lib/main/lockMian/lockList/lockList_logic.dart index b95a6300..ebd8d2c6 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_logic.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_logic.dart @@ -1,5 +1,76 @@ import 'package:star_lock/tools/baseGetXController.dart'; -class LockListLogic extends BaseGetXController{ +import '../../../common/XSConstantMacro/XSConstantMacro.dart'; +import '../entity/lockListInfo_entity.dart'; +import 'lockList_state.dart'; +class LockListLogic extends BaseGetXController{ + LockListState state = LockListState(); + + String getUseKeyTypeStr(LockListInfoItemEntity indexEntity) { + String useDateStr = ''; + if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { + //限期 + DateTime startDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); + DateTime endDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); + useDateStr = + '${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)}'; + } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { + //永久 + // DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + // useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n永久'; + useDateStr = '永久'; + } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { + //单次 + // DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + // useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} \n单次'; + useDateStr = '单次'; + } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { + //循环 + useDateStr = '循环'; + } + + return useDateStr; + } + + String showElectricIcon (int electricnumber){ + if(electricnumber >= 100){ + return 'images/main/icon_lockElectricLevel_5.png'; + }else if((electricnumber > 50) && (electricnumber < 100)){ + return 'images/main/icon_lockElectricLevel_4.png'; + }else if((electricnumber > 25) && (electricnumber <= 50)){ + return 'images/main/icon_lockElectricLevel_3.png'; + }else if((electricnumber > 5) && (electricnumber <= 25)){ + return 'images/main/icon_lockElectricLevel_2.png'; + }else if(electricnumber <= 5){ + return 'images/main/icon_lockElectricLevel_1.png'; + } + return 'images/main/icon_lockElectricLevel_5.png'; + } + + /// 获取是否超过现在的时间 + bool compareTimeIsOvertime(int endTiem){ + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(endTiem); // 将时间戳转换为 DateTime + DateTime now = DateTime.now(); // 获取当前时间 + if (now.isAfter(dateTime)) { + print('The timestamp is after the current time.'); + // 过期 + return true; + } else { + print('The timestamp is not after the current time.'); + return false; + } + } + + /// 获取两个距离当前时间相差几天 1705132260000 + int compareTimeGetDaysFromNow(int endTiem){ + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(endTiem); // 将时间戳转换为 DateTime + DateTime now = DateTime.now(); // 获取当前时间 + Duration difference = dateTime.difference(now); // 计算两个日期之间的差异 + int days = difference.inDays; // 获取差异的天数 + print('dateTime:$dateTime now:$now The difference is $days days.'); + return days; + } } \ No newline at end of file diff --git a/star_lock/lib/main/lockMian/lockList/lockList_page.dart b/star_lock/lib/main/lockMian/lockList/lockList_page.dart index 4be593ed..d372a7d6 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_page.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_page.dart @@ -6,9 +6,9 @@ import 'package:get/get.dart'; import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; import '../../../common/XSConstantMacro/XSConstantMacro.dart'; -import '../../../tools/ExpandedListView.dart'; import '../entity/lockListInfo_entity.dart'; import 'lockListGroup_page.dart'; +import 'lockList_logic.dart'; class LockListPage extends StatefulWidget { final LockListInfoGroupEntity lockListInfoGroupEntity; @@ -20,6 +20,9 @@ class LockListPage extends StatefulWidget { } class _LockListPageState extends State { + final logic = Get.put(LockListLogic()); + final state = Get.find().state; + var groupDataList = []; @override @@ -95,9 +98,18 @@ class _LockListPageState extends State { } // print("lockItemList.length:${lockItemList.length} == ${index+1} $isLast"); return lockInfoListItem(keyInfo, isLast, () { + if(logic.compareTimeIsOvertime(keyInfo.endDate!) && keyInfo.keyType == XSConstantMacro.keyTypeTime){ + logic.showToast("钥匙已过期"); + return; + } + // var lockCount = 0; + // for(GroupList itemData in groupDataList){ + // lockCount+=itemData.lockList!.length; + // } Get.toNamed(Routers.lockDetailMainPage, arguments: { // "lockMainEntity": widget.lockMainEntity, - "keyInfo": keyInfo + "keyInfo": keyInfo, + "isOnlyOneData": false, }); }); }), @@ -111,7 +123,7 @@ class _LockListPageState extends State { // height: 122.h, margin: isLast ? EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w, bottom: 20.w) : EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), decoration: BoxDecoration( - color: Colors.white, + color: (logic.compareTimeIsOvertime(keyInfo.endDate!) && keyInfo.keyType == XSConstantMacro.keyTypeTime) ? AppColors.greyBackgroundColor : Colors.white, borderRadius: BorderRadius.circular(20.w), ), child: Column( @@ -131,7 +143,7 @@ class _LockListPageState extends State { Text( keyInfo.lockAlias!, style: TextStyle( - fontSize: 24.sp, fontWeight: FontWeight.w500), + fontSize: 24.sp, fontWeight: FontWeight.w500, color: keyInfo.passageMode == 1 ? AppColors.openPassageModeColor : AppColors.darkGrayTextColor), ), ], ), @@ -144,21 +156,53 @@ class _LockListPageState extends State { ), SizedBox(width: 2.w), Image.asset( - showElectricIcon(keyInfo.electricQuantity!), + logic.showElectricIcon(keyInfo.electricQuantity!), width: 30.w, height: 24.w, ), SizedBox(width: 30.w), ], ), + SizedBox( + height: 5.h, + ), + Visibility( + visible: keyInfo.remoteEnable == 1 ? true : false, + child:Row( + children: [ + SizedBox(width: 30.w), + Text( + "远程开锁", style: TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor), + ), + ], + )), SizedBox( height: 20.h, ), + Visibility( + visible: keyInfo.keyType == XSConstantMacro.keyTypeTime ? true : false, + // visible: true, + child:Row( + children: [ + SizedBox(width: 30.w), + Container( + padding: EdgeInsets.only(right: 5.w, left: 5.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.w), + color: logic.compareTimeIsOvertime(keyInfo.endDate!) ? AppColors.listTimeYellowColor : AppColors.mainColor, + ), + child: Text( + logic.compareTimeIsOvertime(keyInfo.endDate!) ? "已过期" : "余${logic.compareTimeGetDaysFromNow(keyInfo.endDate!)}天", style: TextStyle(fontSize: 18.sp, color: Colors.white) + ), + ), + ], + )), + SizedBox(height: 5.h), Row( children: [ SizedBox(width: 30.w), Text( - "${getUseDateStr(keyInfo)}/${keyInfo.isLockOwner == 1 ? '超级管理员' : (keyInfo.keyRight == 1 ? "授权管理员" : "普通用户")}", + "${logic.getUseKeyTypeStr(keyInfo)}/${keyInfo.isLockOwner == 1 ? '超级管理员' : (keyInfo.keyRight == 1 ? "授权管理员" : "普通用户")}", style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor), ), @@ -173,47 +217,4 @@ class _LockListPageState extends State { ); } - String getUseDateStr(LockListInfoItemEntity indexEntity) { - String useDateStr = ''; - if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { - //限期 - DateTime startDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); - DateTime endDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); - useDateStr = - '${startDateStr.toLocal().toString().substring(0, 16)} ${endDateStr.toLocal().toString().substring(0, 16)}'; - } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { - //永久 - // DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); - // useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n永久'; - useDateStr = '永久'; - } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { - //单次 - // DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); - // useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} \n单次'; - useDateStr = '单次'; - } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { - //循环 - useDateStr = '循环'; - } - - return useDateStr; - } - - String showElectricIcon (int electricnumber){ - if(electricnumber >= 100){ - return 'images/main/icon_lockElectricLevel_5.png'; - }else if((electricnumber > 50) && (electricnumber < 100)){ - return 'images/main/icon_lockElectricLevel_4.png'; - }else if((electricnumber > 25) && (electricnumber <= 50)){ - return 'images/main/icon_lockElectricLevel_3.png'; - }else if((electricnumber > 5) && (electricnumber <= 25)){ - return 'images/main/icon_lockElectricLevel_2.png'; - }else if(electricnumber <= 5){ - return 'images/main/icon_lockElectricLevel_1.png'; - } - return 'images/main/icon_lockElectricLevel_5.png'; - } - } diff --git a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart index c2d2c15e..94edfc5b 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart @@ -83,7 +83,7 @@ class _StarLockMainPageState extends State with BaseWidget { case 1: // 只有一条数据 Storage.setBool(ifIsDemoModeOrNot, false); - returnWidget = LockDetailPage(isFrist: true, lockListInfoItemEntity: state.lockListInfoEntity.value.data!.groupList![0].lockList![0]); + returnWidget = LockDetailPage(isOnlyOneData: true, lockListInfoItemEntity: state.lockListInfoEntity.value.data!.groupList![0].lockList![0]); break; case 2: // 有多条数据 diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index 95e819e9..49bc5f53 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -3,10 +3,8 @@ import 'dart:async'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:get/get.dart'; -import '../../../appRouters.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_addUser.dart'; -import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart'; import '../../../blue/io_reply.dart'; import '../../../blue/io_tool/io_tool.dart'; import '../../../blue/io_tool/manager_event_bus.dart'; @@ -49,7 +47,7 @@ class SaveLockLogic extends BaseGetXController { case 0x00: //成功 print("添加用户数据解析成功"); - state.lockUserNo = reply.data[47] + 1; + state.lockUserNo = reply.data[47]; cancelBlueConnetctToastTimer(); dismissEasyLoading(); diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 8985e9ee..f48312cb 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -640,7 +640,7 @@ class ApiProvider extends BaseProvider { })); // 设置常开模式 - Future setNormallyModeData(int lockId, int passageMode, Map passageModeConfig) => + Future setNormallyModeData(int lockId, int passageMode, List passageModeConfig) => post( updateLockSettingUrl.toUrl, jsonEncode({ diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 63117620..e30190dc 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -676,7 +676,7 @@ class ApiRepository { Future setNormallyModeData({ required int lockId, required int passageMode, - required Map passageModeConfig, + required List passageModeConfig, }) async { final res = await apiProvider.setNormallyModeData(lockId, passageMode, passageModeConfig); diff --git a/star_lock/lib/tools/baseGetXController.dart b/star_lock/lib/tools/baseGetXController.dart index fc1182c1..68504bf1 100644 --- a/star_lock/lib/tools/baseGetXController.dart +++ b/star_lock/lib/tools/baseGetXController.dart @@ -1,13 +1,10 @@ import 'dart:async'; -import 'package:async/async.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; -import '../login/login/entity/LoginEntity.dart'; -import '../translations/trans_lib.dart'; import 'manager/client_manager.dart'; class BaseGetXController extends GetxController{ diff --git a/star_lock/lib/tools/eventBusEventManage.dart b/star_lock/lib/tools/eventBusEventManage.dart index 740d77e1..21c7bab3 100644 --- a/star_lock/lib/tools/eventBusEventManage.dart +++ b/star_lock/lib/tools/eventBusEventManage.dart @@ -45,7 +45,7 @@ class LockGroupEditGroupLockRefreshEvent { /// 锁设置里面开启关闭刷新锁详情 class LockSetChangeSetRefreshLockDetailWithType { - int type; // 0 考勤 1开锁时是否需联网 + int type; // 0 考勤 1开锁时是否需联网 2常开模式 int setResult; LockSetChangeSetRefreshLockDetailWithType(this.type, this.setResult); } diff --git a/star_lock/lib/tools/keySearchWidget.dart b/star_lock/lib/tools/keySearchWidget.dart new file mode 100644 index 00000000..b5f38af9 --- /dev/null +++ b/star_lock/lib/tools/keySearchWidget.dart @@ -0,0 +1,86 @@ + + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; + +import '../translations/trans_lib.dart'; + +class KeySearchWidget extends StatelessWidget { + TextEditingController editingController; + Function() onSubmittedAction; + + KeySearchWidget( + {Key? key, + required this.editingController, + required this.onSubmittedAction}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + height: 60.h, + margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), + padding: EdgeInsets.only(top: 5.h,right: 10.w), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(5)), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.only( + top: 15.h, bottom: 15.h, right: 5.w, left: 10.w), + child: Image.asset( + 'images/main/icon_main_search.png', + width: 40.w, + height: 40.w, + ), + ), + Expanded( + child: Container( + height: 60.h, + // width: 1.sw, + // color: Colors.red, + child: TextField( + //输入框一行 + maxLines: 1, + inputFormatters: [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(18), + ], + controller: editingController, + autofocus: false, + textAlign: TextAlign.start, + onChanged: (value) { + print("onChanged:$value"); + }, + onEditingComplete: () { + print("onEditingComplete:"); + }, + onSubmitted: (value) { + onSubmittedAction!(); + }, + decoration: InputDecoration( + //输入里面输入文字内边距设置 + // contentPadding: const EdgeInsets.only( + // top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), + // hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, + hintText:"搜索", + hintStyle: TextStyle(fontSize: 22.sp), + // border: InputBorder.none, + focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + contentPadding: const EdgeInsets.symmetric(vertical: 0), + ), + ), + ), + ), + ], + ), + ); + } +} \ No newline at end of file