From ab1ab37cbdc143a3d98ced6551292a4a2881a218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Thu, 31 Oct 2024 17:09:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201=E3=80=81=E5=8F=96=E6=B6=88=E9=94=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E8=BF=9B=E5=85=A5=E6=93=8D=E4=BD=9C=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E7=95=8C=E9=9D=A2=E5=B0=B1=E4=BB=8E=E9=94=81=E4=B8=8A?= =?UTF-8?q?=E9=9D=A2=E6=8B=89=E5=8F=96=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E3=80=822=E3=80=81=E4=BF=AE=E5=A4=8D=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E9=A2=91=E7=B9=81=E8=B0=83=E7=94=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../doorLockLog/doorLockLog_logic.dart | 33 +- .../doorLockLog/doorLockLog_page.dart | 13 +- .../doorLockLog/doorLockLog_state.dart | 1 + .../lockOperatingRecord_logic.dart | 318 +++++++++--------- .../lockOperatingRecord_page.dart | 83 ++--- lib/tools/advancedCalendar/src/widget.dart | 6 +- 6 files changed, 236 insertions(+), 218 deletions(-) diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index c9733078..3634ad62 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; @@ -47,6 +48,7 @@ class DoorLockLogLogic extends BaseGetXController { upload: true ); + state.isLockReceiveResponse = true; cancelBlueConnetctToastTimer(); final int status = reply.data[2]; @@ -86,8 +88,8 @@ class DoorLockLogLogic extends BaseGetXController { (0xff & indexList[4]) << 16 | (0xff & indexList[5]) << 8 | (0xFF & indexList[6]); - final operateDate = time * 1000; - final serverTime = state.currentDate; + final int operateDate = time * 1000; + final int serverTime = state.currentDate; if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter( DateTime.fromMillisecondsSinceEpoch(serverTime*1000))) { // AppLog.log('operateDate:$operateDate state.currentDate:${state.currentDate}'); @@ -110,6 +112,7 @@ class DoorLockLogLogic extends BaseGetXController { break; default: //失败 + dismissEasyLoading(); break; } } @@ -138,7 +141,8 @@ class DoorLockLogLogic extends BaseGetXController { privateKey: getPrivateKeyList, ).toString(); - showBlueConnetctToastTimer(isShowBlueConnetctToast:false, action: () async { + showEasyLoading(); + showBlueConnetctToastTimer(isShowBlueConnetctToast:true, action: () async { cancelBlueConnetctToastTimer(); final String getMobile = (await Storage.getMobile())!; @@ -155,6 +159,9 @@ class DoorLockLogLogic extends BaseGetXController { eventStr: '查询锁记录事件超时', upload: true ); + if(state.isLockReceiveResponse == false){ + dismissEasyLoading(); + } }); BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async { if (connectionStateState == BluetoothConnectionState.connected) { @@ -180,6 +187,9 @@ class DoorLockLogLogic extends BaseGetXController { privateKey: getPrivateKeyList, ); } else if (connectionStateState == BluetoothConnectionState.disconnected) { + if (state.ifCurrentScreen.value == true) { + showBlueConnetctToast(); + } cancelBlueConnetctToastTimer(); final String getMobile = (await Storage.getMobile())!; @@ -225,19 +235,18 @@ class DoorLockLogLogic extends BaseGetXController { /// 刷新门锁日志列表 StreamSubscription? _getDoorLockLogListRefreshUIEvent; - void _getDoorLockLogListRefreshUIAction() { - _getDoorLockLogListRefreshUIEvent = eventBus - .on() - .listen((DoorLockLogListRefreshUI event) { + _getDoorLockLogListRefreshUIEvent = eventBus.on().listen((DoorLockLogListRefreshUI event) { state.currentSelectDate.value = event.getDoorLockLogTime; -// 设置startDate为当天的0点 + + // 设置startDate为当天的0点 state.startDate.value = DateTime( state.currentSelectDate.value.year, state.currentSelectDate.value.month, state.currentSelectDate.value.day) .millisecondsSinceEpoch; -// 设置endDate为下一天的0点,然后减去1毫秒 + + // 设置endDate为下一天的0点,然后减去1毫秒 state.endDate.value = DateTime( state.currentSelectDate.value.year, state.currentSelectDate.value.month, @@ -246,7 +255,6 @@ class DoorLockLogLogic extends BaseGetXController { .millisecondsSinceEpoch; pageNo = 1; - AppLog.log('_getDoorLockLogListRefreshUIAction'); mockNetworkDataRequest(isRefresh: true); }); } @@ -275,6 +283,7 @@ class DoorLockLogLogic extends BaseGetXController { final String getMobile = (await Storage.getMobile())!; if (entity.errorCode!.codeIsSuccessful) { if (state.ifHaveNext == true) { + showEasyLoading(); getLockRecordLastUploadDataTime(); } else { UmengCommonSdk.onEvent('check_doorLockLog', { @@ -285,6 +294,7 @@ class DoorLockLogLogic extends BaseGetXController { }); mockNetworkDataRequest(isRefresh: true); } + dismissEasyLoading(); }else{ UmengCommonSdk.onEvent('check_doorLockLog', { 'lockName':state.keyInfos.value.lockName!, @@ -292,6 +302,7 @@ class DoorLockLogLogic extends BaseGetXController { 'date':DateTool().getNowDateWithType(1), 'open_lock_result':'上传数据接口失败', }); + dismissEasyLoading(); } } @@ -331,7 +342,7 @@ class DoorLockLogLogic extends BaseGetXController { if (isDemoMode == false) { mockNetworkDataRequest(isRefresh: true); - getLockRecordLastUploadDataTime(); + // getLockRecordLastUploadDataTime(); _initReplySubscription(); } } diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart index 9775feda..ba3b94d9 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart @@ -1,3 +1,4 @@ + import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -19,7 +20,6 @@ import 'package:timelines/timelines.dart'; import '../../../app_settings/app_colors.dart'; import '../../../tools/appRouteObserver.dart'; import '../../../tools/titleAppBar.dart'; -import '../../../translations/trans_lib.dart'; class DoorLockLogPage extends StatefulWidget { const DoorLockLogPage({Key? key}) : super(key: key); @@ -88,7 +88,7 @@ class _DoorLockLogPageState extends State with RouteAware { body: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ topAdvancedCalendarWidget(), Divider( height: 1, @@ -124,6 +124,7 @@ class _DoorLockLogPageState extends State with RouteAware { switch (value) { case '读取记录': { + state.isLockReceiveResponse = false; logic.getLockRecordLastUploadDataTime(); } break; @@ -177,7 +178,7 @@ class _DoorLockLogPageState extends State with RouteAware { disabledColor: Colors.grey, ), child: Stack( - children: [ + children: [ AdvancedCalendar( controller: state.calendarControllerCustom, events: state.events, @@ -338,7 +339,6 @@ class _DoorLockLogPageState extends State with RouteAware { @override void didChangeDependencies() { - // TODO: implement didChangeDependencies super.didChangeDependencies(); /// 路由订阅 @@ -347,7 +347,6 @@ class _DoorLockLogPageState extends State with RouteAware { @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); @@ -365,7 +364,9 @@ class _DoorLockLogPageState extends State with RouteAware { void didPop() { super.didPop(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; } diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart index e4ff3970..7f9e5534 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart @@ -67,4 +67,5 @@ class DoorLockLogState { bool ifHaveNext = false; // 页码 int logCountPage = 10; // 蓝牙记录一页多少个 Rx currentSelectDate = DateTime.now().obs; + bool isLockReceiveResponse = false; // 是否收到回复 } diff --git a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart index 41b51807..c2d17472 100755 --- a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart +++ b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart @@ -21,129 +21,129 @@ class LockOperatingRecordLogic extends BaseGetXController { LockOperatingRecordState state = LockOperatingRecordState(); // 获取解析后的数据 - late StreamSubscription _replySubscription; + // late StreamSubscription _replySubscription; - void _initReplySubscription() { - _replySubscription = - EventBusManager().eventBus!.on().listen((Reply reply) { - if (reply is SenderReferEventRecordTimeReply) { - _replyReferEventRecordTime(reply); - } - }); - } + // void _initReplySubscription() { + // _replySubscription = + // EventBusManager().eventBus!.on().listen((Reply reply) { + // if (reply is SenderReferEventRecordTimeReply) { + // _replyReferEventRecordTime(reply); + // } + // }); + // } // 根据时间查解析数据 - Future _replyReferEventRecordTime(Reply reply) async { - cancelBlueConnetctToastTimer(); - final int status = reply.data[2]; - switch (status) { - case 0x00: - //成功 - final int dataLength = (reply.data[5] << 8) + reply.data[6]; - AppLog.log('dataLength:$dataLength'); - // var dataLength = reply.data[5]; - if (dataLength > 0) { - reply.data.removeRange(0, 7); - // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 - if (reply.data.length < 17) { - return; - } - final List> getList = splitList(reply.data, 17); - // AppLog.log("getList:$getList"); - final List uploadList = []; - for (int i = 0; i < getList.length; i++) { - final List indexList = getList[i]; - // AppLog.log("indexList:$indexList"); - final Map indexMap = {}; - - indexMap['type'] = indexList[0].toString(); - - final int userNo = (indexList[1] * 256) + indexList[2]; - indexMap['user'] = userNo.toString(); - AppLog.log('userNouserNouserNouserNo:$userNo'); - - final List passwordData = indexList.sublist(7, 17); - final String password = utf8String(passwordData); - indexMap['password'] = password.toString(); - AppLog.log('passwordpasswordpassword:$password'); - - indexMap['success'] = '1'; - - final int time = (0xff & indexList[3]) << 24 | - (0xff & indexList[4]) << 16 | - (0xff & indexList[5]) << 8 | - (0xFF & indexList[6]); - final operateDate = time * 1000; - final serverTime = state.currentDate; - if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter( - DateTime.fromMillisecondsSinceEpoch(serverTime*1000))) { - continue; - } - indexMap['date'] = '$operateDate'; - uploadList.add(indexMap); - } - if (dataLength == state.logCountPage) { - state.ifHaveNext = true; - } else { - state.ifHaveNext = false; - } - lockRecordUploadData(uploadList); - } - break; - case 0x06: - //无权限 需要鉴权 - - break; - default: - //失败 - break; - } - } + // Future _replyReferEventRecordTime(Reply reply) async { + // cancelBlueConnetctToastTimer(); + // final int status = reply.data[2]; + // switch (status) { + // case 0x00: + // //成功 + // final int dataLength = (reply.data[5] << 8) + reply.data[6]; + // AppLog.log('dataLength:$dataLength'); + // // var dataLength = reply.data[5]; + // if (dataLength > 0) { + // reply.data.removeRange(0, 7); + // // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 + // if (reply.data.length < 17) { + // return; + // } + // final List> getList = splitList(reply.data, 17); + // // AppLog.log("getList:$getList"); + // final List uploadList = []; + // for (int i = 0; i < getList.length; i++) { + // final List indexList = getList[i]; + // // AppLog.log("indexList:$indexList"); + // final Map indexMap = {}; + // + // indexMap['type'] = indexList[0].toString(); + // + // final int userNo = (indexList[1] * 256) + indexList[2]; + // indexMap['user'] = userNo.toString(); + // AppLog.log('userNouserNouserNouserNo:$userNo'); + // + // final List passwordData = indexList.sublist(7, 17); + // final String password = utf8String(passwordData); + // indexMap['password'] = password.toString(); + // AppLog.log('passwordpasswordpassword:$password'); + // + // indexMap['success'] = '1'; + // + // final int time = (0xff & indexList[3]) << 24 | + // (0xff & indexList[4]) << 16 | + // (0xff & indexList[5]) << 8 | + // (0xFF & indexList[6]); + // final operateDate = time * 1000; + // final serverTime = state.currentDate; + // if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter( + // DateTime.fromMillisecondsSinceEpoch(serverTime*1000))) { + // continue; + // } + // indexMap['date'] = '$operateDate'; + // uploadList.add(indexMap); + // } + // if (dataLength == state.logCountPage) { + // state.ifHaveNext = true; + // } else { + // state.ifHaveNext = false; + // } + // lockRecordUploadData(uploadList); + // } + // break; + // case 0x06: + // //无权限 需要鉴权 + // + // break; + // default: + // //失败 + // break; + // } + // } // 查询事件记录(时间查询) - Future senderReferEventRecordTime() async { - showEasyLoading(); - showBlueConnetctToastTimer(action: () { - dismissEasyLoading(); - }); - BlueManage().blueSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState connectionStateState) async { - if (connectionStateState == BluetoothConnectionState.connected) { - final List? privateKey = - await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = - changeStringListToIntList(privateKey!); - - final List? token = await Storage.getStringList(saveBlueToken); - final List getTokenList = changeStringListToIntList(token!); - - final List? publicKey = - await Storage.getStringList(saveBluePublicKey); - final List getPublicKeyList = - changeStringListToIntList(publicKey!); - - IoSenderManage.senderReferEventRecordTimeCommand( - keyID: BlueManage().connectDeviceName, - userID: await Storage.getUid(), - logsCount: state.logCountPage, - // time:DateTime.now().millisecondsSinceEpoch~/1000, - time: state.operateDate, - currentDate: state.currentDate, - token: getTokenList, - needAuthor: 1, - publicKey: getPublicKeyList, - privateKey: getPrivateKeyList, - ); - } else if (connectionStateState == - BluetoothConnectionState.disconnected) { - dismissEasyLoading(); - cancelBlueConnetctToastTimer(); - if (state.ifCurrentScreen.value == true) { - showBlueConnetctToast(); - } - } - }); - } + // Future senderReferEventRecordTime() async { + // showEasyLoading(); + // showBlueConnetctToastTimer(action: () { + // dismissEasyLoading(); + // }); + // BlueManage().blueSendData(BlueManage().connectDeviceName, + // (BluetoothConnectionState connectionStateState) async { + // if (connectionStateState == BluetoothConnectionState.connected) { + // final List? privateKey = + // await Storage.getStringList(saveBluePrivateKey); + // final List getPrivateKeyList = + // changeStringListToIntList(privateKey!); + // + // final List? token = await Storage.getStringList(saveBlueToken); + // final List getTokenList = changeStringListToIntList(token!); + // + // final List? publicKey = + // await Storage.getStringList(saveBluePublicKey); + // final List getPublicKeyList = + // changeStringListToIntList(publicKey!); + // + // IoSenderManage.senderReferEventRecordTimeCommand( + // keyID: BlueManage().connectDeviceName, + // userID: await Storage.getUid(), + // logsCount: state.logCountPage, + // // time:DateTime.now().millisecondsSinceEpoch~/1000, + // time: state.operateDate, + // currentDate: state.currentDate, + // token: getTokenList, + // needAuthor: 1, + // publicKey: getPublicKeyList, + // privateKey: getPrivateKeyList, + // ); + // } else if (connectionStateState == + // BluetoothConnectionState.disconnected) { + // dismissEasyLoading(); + // cancelBlueConnetctToastTimer(); + // if (state.ifCurrentScreen.value == true) { + // showBlueConnetctToast(); + // } + // } + // }); + // } //请求操作记录列表 Future mockNetworkDataRequest() async { @@ -180,48 +180,48 @@ class LockOperatingRecordLogic extends BaseGetXController { } // 查询锁记录最后时间 - Future getLockRecordLastUploadDataTime() async { - final LockOperatingRecordGetLastRecordTimeEntity entity = - await ApiRepository.to.getLockRecordLastUploadDataTime( - lockId: CommonDataManage().currentKeyInfo.lockId.toString()); - if (entity.errorCode!.codeIsSuccessful) { - state.operateDate = entity.data!.operateDate! ~/ 1000; - state.currentDate = entity.data!.currentDate! ~/ 1000; - senderReferEventRecordTime(); - } - } + // Future getLockRecordLastUploadDataTime() async { + // final LockOperatingRecordGetLastRecordTimeEntity entity = + // await ApiRepository.to.getLockRecordLastUploadDataTime( + // lockId: CommonDataManage().currentKeyInfo.lockId.toString()); + // if (entity.errorCode!.codeIsSuccessful) { + // state.operateDate = entity.data!.operateDate! ~/ 1000; + // state.currentDate = entity.data!.currentDate! ~/ 1000; + // senderReferEventRecordTime(); + // } + // } // 操作记录上传 - Future lockRecordUploadData(List list) async { - if(list.isEmpty){ - return; - } - final KeyOperationRecordEntity entity = await ApiRepository.to - .lockRecordUploadData( - lockId: CommonDataManage().currentKeyInfo.lockId.toString(), - records: list); - if (entity.errorCode!.codeIsSuccessful) { - if (state.ifHaveNext == true) { - getLockRecordLastUploadDataTime(); - } else { - pageNo = 1; - mockNetworkDataRequest(); - } - } - } + // Future lockRecordUploadData(List list) async { + // if(list.isEmpty){ + // return; + // } + // final KeyOperationRecordEntity entity = await ApiRepository.to + // .lockRecordUploadData( + // lockId: CommonDataManage().currentKeyInfo.lockId.toString(), + // records: list); + // if (entity.errorCode!.codeIsSuccessful) { + // if (state.ifHaveNext == true) { + // getLockRecordLastUploadDataTime(); + // } else { + // pageNo = 1; + // mockNetworkDataRequest(); + // } + // } + // } //清空操作记录 - Future clearOperationRecordRequest() async { - final KeyOperationRecordEntity entity = await ApiRepository.to - .clearOperationRecord( - CommonDataManage().currentKeyInfo.lockId.toString()); - if (entity.errorCode!.codeIsSuccessful) { - showToast('清除数据成功', something: () { - pageNo = 1; - mockNetworkDataRequest(); - }); - } - } + // Future clearOperationRecordRequest() async { + // final KeyOperationRecordEntity entity = await ApiRepository.to + // .clearOperationRecord( + // CommonDataManage().currentKeyInfo.lockId.toString()); + // if (entity.errorCode!.codeIsSuccessful) { + // showToast('清除数据成功', something: () { + // pageNo = 1; + // mockNetworkDataRequest(); + // }); + // } + // } @override Future onReady() async { @@ -244,10 +244,10 @@ class LockOperatingRecordLogic extends BaseGetXController { // 获取是否是演示模式 演示模式不获取接口 final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - getLockRecordLastUploadDataTime(); + // getLockRecordLastUploadDataTime(); // senderReferEventRecordTime(); // senderReferEventRecordNumber(); - _initReplySubscription(); + // _initReplySubscription(); } } @@ -258,7 +258,7 @@ class LockOperatingRecordLogic extends BaseGetXController { //获取是否是演示模式 演示模式不获取接口 final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - _replySubscription.cancel(); + // _replySubscription.cancel(); // _getDoorLockLogListRefreshUIEvent?.cancel(); } } diff --git a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart index 17752fd5..57a246a4 100755 --- a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart +++ b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart @@ -1,7 +1,9 @@ + 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/lockOperatingRecord/lockOperatingRecord_state.dart'; import '../../../app_settings/app_colors.dart'; import '../../../tools/EasyRefreshTool.dart'; @@ -25,11 +27,11 @@ class LockOperatingRecordPage extends StatefulWidget { } class _LockOperatingRecordPageState extends State with RouteAware{ - final logic = Get.put(LockOperatingRecordLogic()); - final state = Get.find().state; + final LockOperatingRecordLogic logic = Get.put(LockOperatingRecordLogic()); + final LockOperatingRecordState state = Get.find().state; Future getHttpData() async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { logic.mockNetworkDataRequest().then((KeyOperationRecordEntity value){ if (mounted) { @@ -85,7 +87,7 @@ class _LockOperatingRecordPageState extends State with getHttpData(); }, child: Column( - children: [ + children: [ // (CommonDataManage().currentKeyInfo.isLockOwner == 1 || // CommonDataManage().currentKeyInfo.keyRight == 1) // ? Column( @@ -120,13 +122,13 @@ class _LockOperatingRecordPageState extends State with return Obx(() => state.lockOperatingRecordListData.value.isNotEmpty ? ListView.separated( itemCount: state.lockOperatingRecordListData.length, - itemBuilder: (c, index) { - KeyRecordDataItem dataItem = + itemBuilder: (BuildContext c, int index) { + final KeyRecordDataItem dataItem = state.lockOperatingRecordListData[index]; - int? operateDate = dataItem.operateDate; - DateTime dateStr = + final int? operateDate = dataItem.operateDate; + final DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!); - String operateDateStr = + final String operateDateStr = '${dateStr.toLocal().toString().substring(0, 16)} '; // return _operatingRecordItem(getTypeIcon(dataItem.recordType!), // dataItem.recordTypeName!, operateDateStr, () {}); @@ -181,7 +183,7 @@ class _LockOperatingRecordPageState extends State with ), child: Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Icon(Icons.access_time, size: 35.w), SizedBox(width: 10.w,), Text( @@ -196,7 +198,7 @@ class _LockOperatingRecordPageState extends State with child:Container( margin: EdgeInsets.only(bottom: 3.w), child: Row( - children: [ + children: [ Flexible( child: Text( userNameStr, @@ -273,43 +275,40 @@ class _LockOperatingRecordPageState extends State with // ); // } - Future _openModalBottomSheet() async { - showModalBottomSheet( - context: context, - shape: RoundedRectangleBorder( - borderRadius: BorderRadiusDirectional.circular(10)), - builder: (BuildContext context) { - return AlertBottomWidget( - topTitle: '', - // items: const ['读取记录', '清空记录', '导出记录'], - items: const ['清空记录'], - chooseCallback: (value) { - int getSelectIndex = value; - // if (getSelectIndex == 0) { - // logic.mockNetworkDataRequest(); - // } else if (getSelectIndex == 1) { - // logic.clearOperationRecordRequest(); - // } - if (getSelectIndex == 0) { - logic.clearOperationRecordRequest(); - } - }, - ); - }); - } + // Future _openModalBottomSheet() async { + // showModalBottomSheet( + // context: context, + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadiusDirectional.circular(10)), + // builder: (BuildContext context) { + // return AlertBottomWidget( + // topTitle: '', + // // items: const ['读取记录', '清空记录', '导出记录'], + // items: const ['清空记录'], + // chooseCallback: (value) { + // int getSelectIndex = value; + // // if (getSelectIndex == 0) { + // // logic.mockNetworkDataRequest(); + // // } else if (getSelectIndex == 1) { + // // logic.clearOperationRecordRequest(); + // // } + // if (getSelectIndex == 0) { + // logic.clearOperationRecordRequest(); + // } + // }, + // ); + // }); + // } @override void didChangeDependencies() { - // TODO: implement didChangeDependencies super.didChangeDependencies(); - /// 路由订阅 AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); } @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); @@ -327,7 +326,9 @@ class _LockOperatingRecordPageState extends State with void didPop() { super.didPop(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; } @@ -343,7 +344,9 @@ class _LockOperatingRecordPageState extends State with void didPushNext() { super.didPushNext(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; } diff --git a/lib/tools/advancedCalendar/src/widget.dart b/lib/tools/advancedCalendar/src/widget.dart index 468f8fe8..dff01e79 100755 --- a/lib/tools/advancedCalendar/src/widget.dart +++ b/lib/tools/advancedCalendar/src/widget.dart @@ -232,8 +232,7 @@ class _AdvancedCalendarState extends State child: ValueListenableBuilder( valueListenable: _controller, builder: (_, selectedDate, __) { - AppLog.log('****selectedDate: $selectedDate'); - eventBus.fire(DoorLockLogListRefreshUI(selectedDate)); + // AppLog.log('****selectedDate: $selectedDate'); return Stack( alignment: Alignment.center, children: [ @@ -252,6 +251,7 @@ class _AdvancedCalendarState extends State ); } _monthViewCurrentPage.value = pageIndex; + AppLog.log('调用onPageChanged'); }, controller: _monthPageController, physics: _animationController.value == 1.0 @@ -389,6 +389,8 @@ class _AdvancedCalendarState extends State void _handleDateChanged(DateTime date) { _controller.value = date; + AppLog.log('点击日期了'); + eventBus.fire(DoorLockLogListRefreshUI(date)); } void _handleFinishDrag() async {