diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index a91cb89f..c82faf0e 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -2,6 +2,7 @@ import 'package:get/get.dart'; import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart'; import 'package:star_lock/login/register/starLock_register_binding.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_page.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart'; @@ -59,7 +60,6 @@ import 'main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdayS import 'main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart'; import 'main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart'; import 'main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart'; -import 'main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart'; import 'main/lockDetail/face/addFace/addFace_page.dart'; import 'main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_page.dart'; import 'main/lockDetail/face/faceList/faceList_page.dart'; diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index 9d309a67..6230e790 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -6,6 +6,7 @@ import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import 'package:star_lock/main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; @@ -18,7 +19,6 @@ import '../../../blue/sender_manage.dart'; import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; import '../../../tools/storage.dart'; -import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; class DoorLockLogLogic extends BaseGetXController { DoorLockLogState state = DoorLockLogState(); diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart index 264675c3..91b5f918 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart @@ -1,6 +1,6 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -23,7 +23,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController { state.itemData.value.keyName = state.changeNameController.text; state.keyName.value = state.itemData.value.keyName!; Get.back(); - showToast("修改成功", something: (){ + showToast("修改成功", something: () { eventBus.fire(ElectronicKeyListRefreshUI()); }); } @@ -35,7 +35,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController { .deleteElectronicKey(state.itemData.value.keyId.toString()); if (entity.errorCode!.codeIsSuccessful) { print("删除电子钥匙成功"); - showToast("删除成功", something: (){ + showToast("删除成功", something: () { eventBus.fire(ElectronicKeyListRefreshUI()); Get.back(); }); diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart index 4a901cd5..53f1b231 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart @@ -1,6 +1,6 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_state.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -25,7 +25,7 @@ class ElectronicKeyDetailChangeDateLogic extends BaseGetXController { hoursEnd: state.hoursEnd.value, isCoerced: state.isCoerced.value); if (entity.errorCode!.codeIsSuccessful) { - showToast("修改成功", something: (){ + showToast("修改成功", something: () { eventBus.fire(ElectronicKeyListRefreshUI()); Get.back(); }); @@ -44,7 +44,7 @@ class ElectronicKeyDetailChangeDateLogic extends BaseGetXController { state.startDay.value, state.weekDays.value); if (entity.errorCode!.codeIsSuccessful) { - showToast("修改成功", something: (){ + showToast("修改成功", something: () { eventBus.fire(ElectronicKeyListRefreshUI()); Get.back(); }); diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart similarity index 100% rename from star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart rename to star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart new file mode 100644 index 00000000..53cb638b --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart @@ -0,0 +1,31 @@ +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_state.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; + +class KeyOperationRecordLogic extends BaseGetXController { + final KeyOperationRecordState state = KeyOperationRecordState(); + + //请求操作记录列表 + Future mockNetworkDataRequest() async { + KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordList( + '0', + state.keyId.value, + '0', + state.lockId.value, + '1', + '1', + '20', + '0', + '', + '', + '', + state.keyboardPwdId.value, + state.cardId.value, + state.fingerprintId.value); + if (entity.errorCode!.codeIsSuccessful) { + print("操作记录列表成功:${entity.data?.itemList}"); + state.dataList.value = entity.data!.itemList!; + } + } +} diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_page.dart similarity index 62% rename from star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart rename to star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_page.dart index 750329f2..05d7fdee 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_page.dart @@ -1,13 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; - -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; +import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart'; +import 'package:star_lock/tools/noData.dart'; +import 'package:star_lock/tools/titleAppBar.dart'; +import 'package:star_lock/translations/trans_lib.dart'; class KeyOperationRecordPage extends StatefulWidget { const KeyOperationRecordPage({Key? key}) : super(key: key); @@ -17,31 +16,11 @@ class KeyOperationRecordPage extends StatefulWidget { } class _KeyOperationRecordPageState extends State { - String _keyId = ''; - String _lockId = ''; - String _keyboardPwdId = ''; //密码ID - String _cardId = ''; //卡ID - String _fingerprintId = ''; //指纹ID + final logic = Get.put(KeyOperationRecordLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { - dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj["keyId"] != null)) { - _keyId = obj["keyId"]; - } - if (obj != null && (obj["lockId"] != null)) { - _lockId = obj["lockId"]; - } - if (obj != null && (obj["keyboardPwdId"] != null)) { - _keyboardPwdId = obj["keyboardPwdId"]; - } - if (obj != null && (obj["cardId"] != null)) { - _cardId = obj["cardId"]; - } - - if (obj != null && (obj["fingerprintId"] != null)) { - _fingerprintId = obj["fingerprintId"]; - } - return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( @@ -49,8 +28,12 @@ class _KeyOperationRecordPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor, ), - body: FutureBuilder>( - future: mockNetworkDataRequest(), + body: Obx(() => state.dataList.value.isEmpty + ? NoData() + : _buildMainUI(state.dataList.value)), + /* + FutureBuilder>( + future: logic.mockNetworkDataRequest(), builder: (BuildContext context, AsyncSnapshot> snapshot) { //请求结束 @@ -70,41 +53,19 @@ class _KeyOperationRecordPageState extends State { } } else { //请求未结束 显示loading - return Container(); + return Center( + child: Text( + '暂无数据', + style: + TextStyle(color: AppColors.blackColor, fontSize: 24.sp), + ), + ); } }), + */ ); } - //请求操作记录列表 - Future> mockNetworkDataRequest() async { - KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordList( - '0', - _keyId, - '0', - _lockId, - '1', - '1', - '20', - '0', - '', - '', - '', - _keyboardPwdId, - _cardId, - _fingerprintId); - if (entity.errorCode!.codeIsSuccessful) { - print("操作记录列表成功:${entity.data?.itemList}"); - } - final data = entity.data; - if (data != null) { - return data.itemList!; - } else { - List dataList = []; - return dataList; - } - } - Widget _buildMainUI(List itemDataList) { return ListView.separated( itemCount: itemDataList.length, diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_state.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_state.dart new file mode 100644 index 00000000..5a959946 --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_state.dart @@ -0,0 +1,32 @@ +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; + +class KeyOperationRecordState { + var dataList = [].obs; + final keyId = ''.obs; + final lockId = ''.obs; + final keyboardPwdId = ''.obs; //密码ID + final cardId = ''.obs; //卡ID + final fingerprintId = ''.obs; //指纹ID + + KeyOperationRecordState() { + Map map = Get.arguments; + // dynamic obj = ModalRoute.of(context)?.settings.arguments; + if ((map["keyId"] != null)) { + keyId.value = map["keyId"]; + } + if ((map["lockId"] != null)) { + lockId.value = map["lockId"]; + } + if ((map["keyboardPwdId"] != null)) { + keyboardPwdId.value = map["keyboardPwdId"]; + } + if ((map["cardId"] != null)) { + cardId.value = map["cardId"]; + } + + if ((map["fingerprintId"] != null)) { + fingerprintId.value = map["fingerprintId"]; + } + } +} 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 48c80968..2cac4ed1 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -40,7 +40,7 @@ class _ElectronicKeyListPageState extends State { // 获取是否是演示模式 演示模式不获取接口 var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value){ + logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value) { setState(() {}); }); } @@ -73,11 +73,11 @@ class _ElectronicKeyListPageState extends State { ], ), body: EasyRefreshTool( - onRefresh: (){ + onRefresh: () { logic.pageNo = 1; mockRequest(); }, - onLoad: (){ + onLoad: () { mockRequest(); }, child: Column( @@ -92,8 +92,7 @@ class _ElectronicKeyListPageState extends State { SizedBox( height: 20.h, ), - Expanded( - child: _buildMainUI()), + Expanded(child: _buildMainUI()), SizedBox( height: 20.h, ), @@ -123,65 +122,78 @@ class _ElectronicKeyListPageState extends State { Widget _buildMainUI() { return Obx(() => state.itemDataList.value.isEmpty - ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + ? NoData( + noDataHeight: 1.sh - + ScreenUtil().statusBarHeight - + ScreenUtil().bottomBarHeight - + 190.h - + 64.h) : SlidableAutoCloseBehavior( - child: ListView.separated( - shrinkWrap: true, - itemCount: state.itemDataList.value.length, - itemBuilder: (c, index) { - ElectronicKeyListItem indexEntity = state.itemDataList.value[index]; - String useDateStr = ''; //使用期限 - String keyStatus = ''; //钥匙状态 + child: ListView.separated( + shrinkWrap: true, + itemCount: state.itemDataList.value.length, + itemBuilder: (c, index) { + ElectronicKeyListItem indexEntity = + state.itemDataList.value[index]; + String useDateStr = ''; //使用期限 + String keyStatus = ''; //钥匙状态 - //使用期限 - useDateStr = getUseDateStr(indexEntity); + //使用期限 + useDateStr = getUseDateStr(indexEntity); - //钥匙状态 - keyStatus = getKeyStatus(indexEntity.keyStatus); + //钥匙状态 + keyStatus = getKeyStatus(indexEntity.keyStatus); - //是否为管理钥匙 - bool isAdminKey = false; - if (indexEntity.keyRight == 1) { - isAdminKey = true; - } else { - isAdminKey = false; - } + //是否为管理钥匙 + bool isAdminKey = false; + if (indexEntity.keyRight == 1) { + isAdminKey = true; + } else { + isAdminKey = false; + } - return Slidable( - key:ValueKey(indexEntity.keyId), - endActionPane: ActionPane( - extentRatio: 0.2, - motion: const ScrollMotion(), - children: [ - SlidableAction( - onPressed: (BuildContext context){ - showIosTipViewDialog(context, indexEntity.keyId!.toString()); - }, - backgroundColor: Colors.red, - foregroundColor: Colors.white, - label: '删除', - ), - ], + return Slidable( + key: ValueKey(indexEntity.keyId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context) { + showIosTipViewDialog( + context, indexEntity.keyId!.toString()); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + ), + ], + ), + child: _electronicKeyItem( + 'images/controls_user.png', + indexEntity.keyName!, + useDateStr, + keyStatus, + isAdminKey, () { + Navigator.pushNamed( + context, Routers.electronicKeyDetailPage, + arguments: {"itemData": indexEntity}).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + setState(() {}); + } + }); + }), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, ), - child: _electronicKeyItem('images/controls_user.png', indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () { - Navigator.pushNamed(context, Routers.electronicKeyDetailPage, - arguments: {"itemData": indexEntity}).then((val) { - if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); - } - }); - }), - ); - }, - separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ), - )); + )); } Widget _buildDeleteBtn(String keyId) { @@ -291,7 +303,11 @@ class _ElectronicKeyListPageState extends State { child: Row( children: [ SizedBox(width: 30.w), - Image.asset(avatarURL, width: 60.w, height: 60.w,), + Image.asset( + avatarURL, + width: 60.w, + height: 60.w, + ), SizedBox(width: 20.w), Expanded( child: Column( @@ -305,16 +321,20 @@ class _ElectronicKeyListPageState extends State { child: Row( children: [ Flexible( - child: Text( - receiveUser, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor) - ), + child: Text(receiveUser, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 24.sp, + color: AppColors.blackColor)), ), SizedBox(width: 10.w), isAdminKey - ? Image.asset('images/icon_electronicKey_admin.png', width: 24.w, height: 20.w,) + ? Image.asset( + 'images/icon_electronicKey_admin.png', + width: 24.w, + height: 20.w, + ) : Container(), ], ), 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 98ceb8d3..415e89c0 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 @@ -53,7 +53,8 @@ class _SendElectronicKeyPageState extends State { } Widget indexChangeWidget() { - if (state.isSendSuccess.value == true && state.sendSucceedType.value.toString() == widget.type) { + if (state.isSendSuccess.value == true && + state.sendSucceedType.value.toString() == widget.type) { return sendElectronicKeySucceed(); } else { switch (int.parse(widget.type)) { @@ -66,7 +67,7 @@ class _SendElectronicKeyPageState extends State { keyTimeWidget(), remoteUnlockingWidget(), keyRealNameWidget(), - keyBottomWidget() + keyBottomWidget(state.timeLimitTips) ], ); } @@ -78,7 +79,7 @@ class _SendElectronicKeyPageState extends State { keyInfoWidget(), remoteUnlockingWidget(), keyRealNameWidget(), - keyBottomWidget() + keyBottomWidget(state.permanentTips) ], ); } @@ -90,7 +91,7 @@ class _SendElectronicKeyPageState extends State { keyInfoWidget(), remoteUnlockingWidget(), keyRealNameWidget(), - keyBottomWidget() + keyBottomWidget(state.onceLimitTips) ], ); } @@ -103,7 +104,7 @@ class _SendElectronicKeyPageState extends State { keyPeriodValidityWidget(), remoteUnlockingWidget(), keyRealNameWidget(), - keyBottomWidget() + keyBottomWidget(state.cycleLimitTips) ], ); } @@ -144,7 +145,6 @@ class _SendElectronicKeyPageState extends State { result as Map; state.countryCode.value = result['code']; state.countryName.value = result['countryName']; - setState(() {}); } }, ), @@ -171,12 +171,10 @@ class _SendElectronicKeyPageState extends State { action: () { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - setState(() { - state.selectEffectiveDate.value = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - state.effectiveDateTime.value = - DateTime.parse(state.selectEffectiveDate.value); - }); + state.selectEffectiveDate.value = + '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; + state.effectiveDateTime.value = + DateTime.parse(state.selectEffectiveDate.value); }); }), CommonItem( @@ -186,12 +184,10 @@ class _SendElectronicKeyPageState extends State { action: () { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - setState(() { - state.selectFailureDate.value = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - state.failureDateTime.value = - DateTime.parse(state.selectFailureDate.value); - }); + state.selectFailureDate.value = + '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; + state.failureDateTime.value = + DateTime.parse(state.selectFailureDate.value); }); }), Container(height: 10.h), @@ -221,7 +217,7 @@ class _SendElectronicKeyPageState extends State { Widget keyPeriodValidityWidget() { return Column( children: [ - Obx(() => CommonItem( + CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, rightTitle: state.weekdaysList.value.isEmpty ? '' @@ -238,7 +234,7 @@ class _SendElectronicKeyPageState extends State { state.failureTimestamp.value = result['endDate'].millisecondsSinceEpoch; } - })), + }), SizedBox( height: 10.h, ) @@ -246,7 +242,7 @@ class _SendElectronicKeyPageState extends State { ); } - Widget keyBottomWidget() { + Widget keyBottomWidget(String sendElectronicKeyTips) { return Column( children: [ Container( @@ -256,7 +252,7 @@ class _SendElectronicKeyPageState extends State { children: [ Expanded( child: Text( - TranslationLoader.lanKeys!.sendKeyBottomTip!.tr, + sendElectronicKeyTips, textAlign: TextAlign.start, style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor), @@ -411,7 +407,6 @@ class _SendElectronicKeyPageState extends State { // if (entity.errorCode!.codeIsSuccessful) { // print("标记为已入住成功啦啦啦啦啦"); // Toast.show(msg: "标记成功"); - // setState(() {}); // } else { // Toast.show(msg: '操作失败'); // } @@ -423,7 +418,6 @@ class _SendElectronicKeyPageState extends State { if (entity.errorCode!.codeIsSuccessful) { print("标记为已入住成功啦啦啦啦啦"); logic.showToast("标记成功"); - setState(() {}); } } @@ -461,10 +455,18 @@ class _SendElectronicKeyPageState extends State { // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, 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)), + 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( @@ -489,17 +491,15 @@ class _SendElectronicKeyPageState extends State { onTap: () async { Contact? currentContact = await state.contactPicker.selectContact(); - setState(() { - state.contact = currentContact!; - if (currentContact.phoneNumbers!.isNotEmpty) { - state.emailOrPhoneController.text = currentContact - .phoneNumbers![0] - .replaceAll(RegExp(r"\s+\b|\b\s"), ""); - } - if (currentContact.fullName!.isNotEmpty) { - state.keyNameController.text = currentContact.fullName!; - } - }); + state.contact = currentContact!; + if (currentContact.phoneNumbers!.isNotEmpty) { + state.emailOrPhoneController.text = currentContact + .phoneNumbers![0] + .replaceAll(RegExp(r"\s+\b|\b\s"), ""); + } + if (currentContact.fullName!.isNotEmpty) { + state.keyNameController.text = currentContact.fullName!; + } }, ), ) @@ -512,15 +512,16 @@ class _SendElectronicKeyPageState extends State { // 远程开锁 Widget remoteUnlockingWidget() { return Visibility( - visible: state.keyInfo.value.lockSetting!.remoteUnlock == 1 ? true : false, + visible: + state.keyInfo.value.lockSetting!.remoteUnlock == 1 ? true : false, child: Column( children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr, rightTitle: "", isHaveRightWidget: true, - rightWidget: - SizedBox(width: 60.w, height: 50.h, child: _remoteSwitch(true)), + rightWidget: SizedBox( + width: 60.w, height: 50.h, child: _remoteSwitch(true)), action: () {}), Container(height: 10.h), ], @@ -537,13 +538,11 @@ class _SendElectronicKeyPageState extends State { value: isRemote ? state.isRemoteUnlock.value : state.isAuthentication.value, onChanged: (value) { - setState(() { - if (isRemote) { - state.isRemoteUnlock.value = !state.isRemoteUnlock.value; - } else { - state.isAuthentication.value = !state.isAuthentication.value; - } - }); + if (isRemote) { + state.isRemoteUnlock.value = !state.isRemoteUnlock.value; + } else { + state.isAuthentication.value = !state.isAuthentication.value; + } }, ); } @@ -639,14 +638,14 @@ class _SendElectronicKeyPageState extends State { //微信好友 { String pwdShareStr = '您好,您的电子钥匙生成成功'; - NativeInteractionTool.loadNativeShare(shareText:pwdShareStr); + NativeInteractionTool.loadNativeShare(shareText: pwdShareStr); } break; case 1: //短信 { String pwdShareStr = '您好,您的电子钥匙生成成功'; - NativeInteractionTool.loadNativeShare(shareText:pwdShareStr); + NativeInteractionTool.loadNativeShare(shareText: pwdShareStr); } break; case 2: @@ -659,7 +658,7 @@ class _SendElectronicKeyPageState extends State { //更多 { String pwdShareStr = '您好,您的电子钥匙生成成功'; - NativeInteractionTool.loadNativeShare(shareText:pwdShareStr); + NativeInteractionTool.loadNativeShare(shareText: pwdShareStr); } break; default: diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart index ca3f0db0..0985a55a 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart @@ -37,6 +37,11 @@ class SendElectronicKeyState { final sendSucceedType = 0.obs; + final timeLimitTips = '接收者在有效期内可以不限次数使用'; //限时 + final permanentTips = '接收者可以使用此App开关锁'; //永久 + final onceLimitTips = '单次钥匙有效期为1小时,只能使用一次'; //单次 + final cycleLimitTips = '接收者可以在有效期内的固定时间段里,不限次数使用'; //循环 + SendElectronicKeyState() { Map map = Get.arguments; keyInfo.value = map["keyInfo"]; diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index aa6cda64..852c6ad1 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -5,8 +5,8 @@ import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; -import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_addUser.dart'; @@ -21,7 +21,6 @@ import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/storage.dart'; -import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import '../lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; import 'lockDetail_state.dart'; import 'lockNetToken_entity.dart'; @@ -73,7 +72,7 @@ class LockDetailLogic extends BaseGetXController { // _showFullScreenOverlay(Get.context!); state.iSClosedUnlockSuccessfulPopup.value = true; - if(state.closedUnlockSuccessfulTimer != null){ + if (state.closedUnlockSuccessfulTimer != null) { state.closedUnlockSuccessfulTimer!.cancel(); state.closedUnlockSuccessfulTimer = null; } @@ -135,10 +134,10 @@ class LockDetailLogic extends BaseGetXController { break; case 0x16: - // 正在开锁中... + // 正在开锁中... print("${reply.commandType}正在开锁中..."); state.openLockBtnState.value = 0; - showToast("正在开锁中...", something: (){ + showToast("正在开锁中...", something: () { cancelBlueConnetctToastTimer(); }); break; @@ -370,13 +369,15 @@ class LockDetailLogic extends BaseGetXController { // 添加用户(普通用户接收电子钥匙) Future addUserConnectBlue() async { - showBlueConnetctToastTimer(action:() { + showBlueConnetctToastTimer(action: () { state.openLockBtnState.value = 0; // state.animationController.reset(); // state.animationController.forward(); }); - BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async { + BlueManage() + .bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, + (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected) { // 私钥 var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -390,7 +391,8 @@ class LockDetailLogic extends BaseGetXController { if (token != null) { getTokenList = changeStringListToIntList(token); } - print("BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}"); + print( + "BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}"); IoSenderManage.senderAddUser( lockID: BlueManage().connectDeviceName, authUserID: state.senderUserId.toString(), @@ -406,9 +408,9 @@ class LockDetailLogic extends BaseGetXController { publicKey: publicKeyDataList, privateKey: getPrivateKeyList, token: getTokenList); - }else if (deviceConnectionState == DeviceConnectionState.disconnected){ + } else if (deviceConnectionState == DeviceConnectionState.disconnected) { cancelBlueConnetctToastTimer(); - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } @@ -421,7 +423,7 @@ class LockDetailLogic extends BaseGetXController { // 点击开门事件 Future openDoorAction(int openMode) async { - showBlueConnetctToastTimer(action:() { + showBlueConnetctToastTimer(action: () { state.openLockBtnState.value = 0; BlueManage().stopScan(); @@ -437,7 +439,8 @@ class LockDetailLogic extends BaseGetXController { var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); - print("openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList"); + print( + "openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList"); // ListlistData = await IoSenderManage.senderOpenLock( // keyID: BlueManage().connectDeviceName, // userID: await Storage.getUid(), @@ -449,8 +452,10 @@ class LockDetailLogic extends BaseGetXController { // signKey: signKeyDataList, // privateKey: getPrivateKeyList, // ); - BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async { - if (deviceConnectionState == DeviceConnectionState.connected){ + BlueManage() + .bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, + (DeviceConnectionState deviceConnectionState) async { + if (deviceConnectionState == DeviceConnectionState.connected) { IoSenderManage.senderOpenLock( keyID: BlueManage().connectDeviceName, userID: await Storage.getUid(), @@ -462,9 +467,9 @@ class LockDetailLogic extends BaseGetXController { signKey: signKeyDataList, privateKey: getPrivateKeyList, ); - }else if (deviceConnectionState == DeviceConnectionState.disconnected){ + } else if (deviceConnectionState == DeviceConnectionState.disconnected) { cancelBlueConnetctToastTimer(); - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } @@ -537,10 +542,11 @@ class LockDetailLogic extends BaseGetXController { // 获取锁状态 更新电量 Future getStarLockStatus() async { showEasyLoading(); - showBlueConnetctToastTimer(action: (){ + showBlueConnetctToastTimer(action: () { dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, + (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -553,7 +559,7 @@ class LockDetailLogic extends BaseGetXController { } else if (deviceConnectionState == DeviceConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } } @@ -591,7 +597,7 @@ class LockDetailLogic extends BaseGetXController { // startOpenLock() { - if(state.openLockBtnState.value == 1){ + if (state.openLockBtnState.value == 1) { return; } state.iSOpenLock.value = true; @@ -614,7 +620,7 @@ class LockDetailLogic extends BaseGetXController { } startUnLock() { - if(state.openLockBtnState.value == 1){ + if (state.openLockBtnState.value == 1) { return; } state.iSOpenLock.value = false; @@ -672,7 +678,8 @@ class LockDetailLogic extends BaseGetXController { // 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口 void getLockNetToken() async { - LockNetTokenEntity entity = await ApiRepository.to.getLockNetToken(lockId: state.keyInfos.value.lockId.toString()); + LockNetTokenEntity entity = await ApiRepository.to + .getLockNetToken(lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { state.lockNetToken = entity.data!.token!; print("state.lockNetToken:${state.lockNetToken}"); @@ -698,7 +705,9 @@ class LockDetailLogic extends BaseGetXController { // 查询锁记录最后时间 void getLockRecordLastUploadDataTime() async { - LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString()); + LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to + .getLockRecordLastUploadDataTime( + lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { senderReferEventRecordTime(entity.data!.operateDate! ~/ 1000); } @@ -716,27 +725,34 @@ class LockDetailLogic extends BaseGetXController { //电量更新请求 Future uploadElectricQuantityRequest(String electricQuantity) async { - KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity(electricQuantity, state.keyInfos.value.lockId.toString()); + KeyOperationRecordEntity entity = await ApiRepository.to + .uploadElectricQuantity( + electricQuantity, state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { - showToast("电量更新成功", something: (){ + showToast("电量更新成功", something: () { eventBus.fire(RefreshLockListInfoDataEvent()); }); } } + /// 锁设置里面开启关闭考勤刷新锁详情 StreamSubscription? _lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent; void _initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus.on().listen((event) { + _lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus + .on() + .listen((event) { if (event.type == 0) { // 0考勤 state.isAttendance.value = int.parse(event.setResult); - state.keyInfos.value.lockSetting!.attendance = int.parse(event.setResult); + state.keyInfos.value.lockSetting!.attendance = + int.parse(event.setResult); } else if (event.type == 1) { // 1 开锁时是否需联网 state.isOpenLockNeedOnline.value = int.parse(event.setResult); - state.keyInfos.value.lockSetting!.appUnlockOnline = int.parse(event.setResult); + state.keyInfos.value.lockSetting!.appUnlockOnline = + int.parse(event.setResult); } else if (event.type == 2) { // 2 常开模式 state.isOpenPassageMode.value = int.parse(event.setResult); @@ -753,13 +769,22 @@ class LockDetailLogic extends BaseGetXController { }); } - late StreamSubscription>_scanListDiscoveredDeviceSubscription; + late StreamSubscription> + _scanListDiscoveredDeviceSubscription; void _scanListDiscoveredDeviceSubscriptionAction() { - _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on>().listen((List list) { - final knownDeviceIndex = list.indexWhere((d) => d.name == state.keyInfos.value.bluetooth!.bluetoothDeviceName!); + _scanListDiscoveredDeviceSubscription = EventBusManager() + .eventBus! + .on>() + .listen((List list) { + final knownDeviceIndex = list.indexWhere((d) => + d.name == state.keyInfos.value.bluetooth!.bluetoothDeviceName!); if (knownDeviceIndex >= 0) { // 存在的时候赋值 - state.currentDeviceUUid.value = (list[knownDeviceIndex].serviceUuids.isNotEmpty ? list[knownDeviceIndex].serviceUuids[0] : "").toString(); + state.currentDeviceUUid.value = + (list[knownDeviceIndex].serviceUuids.isNotEmpty + ? list[knownDeviceIndex].serviceUuids[0] + : "") + .toString(); } }); } @@ -767,7 +792,7 @@ class LockDetailLogic extends BaseGetXController { //开锁成功弹出的小界面 void _showFullScreenOverlay(BuildContext context) { Future.delayed(const Duration(seconds: 3), () { - if(state.iSClosedUnlockSuccessfulPopup.value != true){ + if (state.iSClosedUnlockSuccessfulPopup.value != true) { state.iSClosedUnlockSuccessfulPopup.value = true; Get.back(); } @@ -779,7 +804,7 @@ class LockDetailLogic extends BaseGetXController { builder: (BuildContext context) { return GestureDetector( onTap: () { - if(state.iSClosedUnlockSuccessfulPopup.value != true){ + if (state.iSClosedUnlockSuccessfulPopup.value != true) { state.iSClosedUnlockSuccessfulPopup.value = true; Get.back(); } diff --git a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart index 2bb2e546..b86c5c68 100644 --- a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart +++ b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_referEventRecordTime.dart'; @@ -12,7 +13,6 @@ import '../../../blue/sender_manage.dart'; import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; import '../../../tools/storage.dart'; -import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import 'lockOperatingRecordGetLastRecordTime_entity.dart'; import 'lockOperatingRecord_state.dart'; diff --git a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart index ded8cae4..bd429acc 100644 --- a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart +++ b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart @@ -1,8 +1,7 @@ - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import '../../../app_settings/app_colors.dart'; import '../../../tools/custom_bottom_sheet.dart'; @@ -26,7 +25,6 @@ class _LockOperatingRecordPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( @@ -34,38 +32,39 @@ class _LockOperatingRecordPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor, actionsList: [ - (state.keyInfos.value.isLockOwner == 1 || state.keyInfos.value.keyRight == 1) - ? IconButton( - icon: Image.asset( - 'images/icon_bar_more.png', - height: 30.h, - width: 10.w, - ), - onPressed: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ - // JhPopMenus.showLinePop(context, clickCallback: (index, selText) { - // print('选中index: $index'); - // print('选中text: $selText'); - // if (index == 0) { - // logic.mockNetworkDataRequest(); - // } else if (index == 1) { - // logic.clearOperationRecordRequest(); - // } - // }, listData: [ - // {'text': '读取记录'}, - // {'text': '清空记录'}, - // {'text': '导出记录'}, - // ]); + (state.keyInfos.value.isLockOwner == 1 || + state.keyInfos.value.keyRight == 1) + ? IconButton( + icon: Image.asset( + 'images/icon_bar_more.png', + height: 30.h, + width: 10.w, + ), + onPressed: () async { + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + // JhPopMenus.showLinePop(context, clickCallback: (index, selText) { + // print('选中index: $index'); + // print('选中text: $selText'); + // if (index == 0) { + // logic.mockNetworkDataRequest(); + // } else if (index == 1) { + // logic.clearOperationRecordRequest(); + // } + // }, listData: [ + // {'text': '读取记录'}, + // {'text': '清空记录'}, + // {'text': '导出记录'}, + // ]); - _openModalBottomSheet(); - }else{ - // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); - } - }, - ) - : Container(), + _openModalBottomSheet(); + } else { + // Get.toNamed(Routers.selectLockTypePage); + logic.showToast("演示模式"); + } + }, + ) + : Container(), ], ), body: Column( @@ -79,9 +78,7 @@ class _LockOperatingRecordPageState extends State { ), ), _searchWidget(), - SizedBox( - height: 10.h - ), + SizedBox(height: 10.h), Expanded(child: _buildMainUI()), ], ), @@ -124,24 +121,28 @@ class _LockOperatingRecordPageState extends State { } Widget _buildMainUI() { - return Obx(() => state.lockOperatingRecordListData.value.isNotEmpty ? ListView.separated( - itemCount: state.lockOperatingRecordListData.length, - itemBuilder: (c, index) { - KeyRecordDataItem dataItem = state.lockOperatingRecordListData[index]; - int? operateDate = dataItem.operateDate; - DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!); - String operateDateStr = '${dateStr.toLocal().toString().substring(0, 16)} '; - return _operatingRecordItem(getTypeIcon(dataItem.recordType!), dataItem.recordTypeName!, operateDateStr, () { - - }); - }, - separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ) : NoData()); + return Obx(() => state.lockOperatingRecordListData.value.isNotEmpty + ? ListView.separated( + itemCount: state.lockOperatingRecordListData.length, + itemBuilder: (c, index) { + KeyRecordDataItem dataItem = + state.lockOperatingRecordListData[index]; + int? operateDate = dataItem.operateDate; + DateTime dateStr = + DateTime.fromMillisecondsSinceEpoch(operateDate!); + String operateDateStr = + '${dateStr.toLocal().toString().substring(0, 16)} '; + return _operatingRecordItem(getTypeIcon(dataItem.recordType!), + dataItem.recordTypeName!, operateDateStr, () {}); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ) + : NoData()); } Widget _dateItem(String lockDate) { @@ -185,7 +186,8 @@ class _LockOperatingRecordPageState extends State { return title; } - Widget _operatingRecordItem(String userAvatarStr, String userNameStr, String unlockDescStr, Function() action) { + Widget _operatingRecordItem(String userAvatarStr, String userNameStr, + String unlockDescStr, Function() action) { return GestureDetector( onTap: action, child: Container( @@ -261,5 +263,4 @@ class _LockOperatingRecordPageState extends State { ); }); } - } diff --git a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart index ca96ce6e..5942df9f 100644 --- a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart +++ b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart @@ -1,14 +1,12 @@ - import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import '../../lockMian/entity/lockListInfo_entity.dart'; -import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; -class LockOperatingRecordState{ +class LockOperatingRecordState { final keyInfos = LockListInfoItemEntity().obs; final lockOperatingRecordListData = [].obs; LockOperatingRecordState() { keyInfos.value = Get.arguments["keyInfo"]; } - -} \ No newline at end of file +} diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_logic.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_logic.dart index 1e5b66a9..4fef0fe5 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_logic.dart @@ -1,31 +1,28 @@ - import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import '../../../../../network/api_repository.dart'; import '../../../../../tools/baseGetXController.dart'; import '../../../../../tools/eventBusEventManage.dart'; -import '../../../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import 'editLockName_state.dart'; -class EditLockNameLogic extends BaseGetXController{ +class EditLockNameLogic extends BaseGetXController { final EditLockNameState state = EditLockNameState(); //修改锁名称请求 Future modifyKeyNameRequest() async { KeyOperationRecordEntity entity = await ApiRepository.to.updateLockName( lockId: state.lockSetInfoData.value.lockId.toString(), - lockName:state.changeLockNameController.text); + lockName: state.changeLockNameController.text); if (entity.errorCode!.codeIsSuccessful) { state.lockBasicInfo.value.lockAlias = state.changeLockNameController.text; - showToast("修改成功", something: (){ - eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(3, state.lockBasicInfo.value.lockAlias!)); + showToast("修改成功", something: () { + eventBus.fire(LockSetChangeSetRefreshLockDetailWithType( + 3, state.lockBasicInfo.value.lockAlias!)); eventBus.fire(RefreshLockListInfoDataEvent()); }); - Get.back(result: { - "lockBasicInfo":state.lockBasicInfo.value - }); + Get.back(result: {"lockBasicInfo": state.lockBasicInfo.value}); } } - } diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart index 1daedf9c..334be6da 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart @@ -1,7 +1,7 @@ - import 'dart:async'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import '../../../../../blue/blue_manage.dart'; import '../../../../../blue/io_protocol/io_getStarLockStatusInfo.dart'; @@ -13,7 +13,6 @@ import '../../../../../network/api_repository.dart'; import '../../../../../tools/baseGetXController.dart'; import '../../../../../tools/eventBusEventManage.dart'; import '../../../../../tools/storage.dart'; -import '../../../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import 'uploadElectricQuantity_state.dart'; class UploadElectricQuantityLogic extends BaseGetXController { @@ -21,12 +20,15 @@ class UploadElectricQuantityLogic extends BaseGetXController { //电量更新请求 Future uploadElectricQuantityRequest(String electricQuantity) async { - KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity(electricQuantity, state.lockSetInfoData.value.lockId.toString()); + KeyOperationRecordEntity entity = await ApiRepository.to + .uploadElectricQuantity( + electricQuantity, state.lockSetInfoData.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { - - showToast("锁电量更新成功", something: (){ - eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); - eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, electricQuantity)); + showToast("锁电量更新成功", something: () { + eventBus + .fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); + eventBus.fire( + LockSetChangeSetRefreshLockDetailWithType(0, electricQuantity)); eventBus.fire(RefreshLockListInfoDataEvent()); }); } @@ -34,17 +36,18 @@ class UploadElectricQuantityLogic extends BaseGetXController { // 获取锁状态 Future getStarLockStatus() async { - if(state.sureBtnState.value == 1){ + if (state.sureBtnState.value == 1) { return; } state.sureBtnState.value = 1; showEasyLoading(); - showBlueConnetctToastTimer(action: (){ + showBlueConnetctToastTimer(action: () { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, + (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -58,7 +61,7 @@ class UploadElectricQuantityLogic extends BaseGetXController { dismissEasyLoading(); cancelBlueConnetctToastTimer(); state.sureBtnState.value = 0; - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } } @@ -68,7 +71,8 @@ class UploadElectricQuantityLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) { + _replySubscription = + EventBusManager().eventBus!.on().listen((reply) { // 获取锁状态信息 if (reply is GetStarLockStatuInfoReply) { _replyGetStarLockStatusInfo(reply); @@ -81,7 +85,7 @@ class UploadElectricQuantityLogic extends BaseGetXController { int status = reply.data[2]; switch (status) { case 0x00: - //成功 + //成功 print("${reply.commandType}数据解析成功"); state.sureBtnState.value = 0; dismissEasyLoading(); @@ -89,28 +93,31 @@ class UploadElectricQuantityLogic extends BaseGetXController { // 电池剩余电量 var battRemCap = reply.data[132]; - state.lockSetInfoData.value.lockBasicInfo!.electricQuantity = battRemCap; - state.uploadElectricQuantityDate.value = DateTime.now().millisecondsSinceEpoch; - state.lockSetInfoData.value.lockBasicInfo!.electricQuantityDate = DateTime.now().millisecondsSinceEpoch; + state.lockSetInfoData.value.lockBasicInfo!.electricQuantity = + battRemCap; + state.uploadElectricQuantityDate.value = + DateTime.now().millisecondsSinceEpoch; + state.lockSetInfoData.value.lockBasicInfo!.electricQuantityDate = + DateTime.now().millisecondsSinceEpoch; uploadElectricQuantityRequest(battRemCap.toString()); break; case 0x06: - //无权限 + //无权限 print("${reply.commandType}需要鉴权"); break; case 0x07: - //无权限 + //无权限 print("${reply.commandType}用户无权限"); break; case 0x09: - // 权限校验错误 + // 权限校验错误 print("${reply.commandType}权限校验错误"); break; default: - //失败 + //失败 print("${reply.commandType}失败"); break; @@ -139,5 +146,4 @@ class UploadElectricQuantityLogic extends BaseGetXController { super.onClose(); _replySubscription.cancel(); } - -} \ No newline at end of file +} diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockChangeDate_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockChangeDate_page.dart index 1e9bbb77..4d81ac9f 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockChangeDate_page.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockChangeDate_page.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockListEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -108,7 +108,7 @@ class _ExpireLockChangeDatePageState extends State { '', []); if (entity.errorCode!.codeIsSuccessful) { print("修改要是名称成功啦啦啦啦啦"); - EasyLoading.showToast('修改成功',duration: 2000.milliseconds); + EasyLoading.showToast('修改成功', duration: 2000.milliseconds); setState(() { Navigator.pop(context); }); diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index eb38101f..f2fb5e24 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -1,7 +1,7 @@ import 'package:get/get.dart'; import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; diff --git a/star_lock/lib/tools/menuItem/xsDropDownWidget.dart b/star_lock/lib/tools/menuItem/xsDropDownWidget.dart index 25ea1eb4..5fcc61d2 100644 --- a/star_lock/lib/tools/menuItem/xsDropDownWidget.dart +++ b/star_lock/lib/tools/menuItem/xsDropDownWidget.dart @@ -127,6 +127,7 @@ class _XSDropDownWidgetState extends State { child: Text( item.itemTitle, style: TextStyle( + fontSize: 24.sp, color: item.itemValue == currentValue ? Colors.white : Colors.black, // 设置选中项文字颜色为白色