From d4bb24e516d5bbf1b25fa5504ecff262b7455ec5 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Thu, 16 May 2024 11:59:37 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E9=94=81=E6=93=8D=E4=BD=9C=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=96=B0=E5=A2=9E=E6=B8=85=E7=A9=BA=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5=E5=8F=8A=E7=9B=B8=E5=BA=94?= =?UTF-8?q?=E9=80=BB=E8=BE=91=202=EF=BC=8C=E4=BF=AE=E5=A4=8Dbug=EF=BC=9AID?= =?UTF-8?q?1002068=203=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=9B=B4=E6=8D=A2=E7=B1=BB=E5=9E=8B=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/images/lan/lan_en.json | 13 +- star_lock/images/lan/lan_keys.json | 12 +- star_lock/images/lan/lan_zh.json | 12 +- .../doorLockLog/doorLockLog_logic.dart | 14 +- .../doorLockLog/doorLockLog_page.dart | 165 +++++++++--------- .../doorLockLog/doorLockLog_state.dart | 12 +- .../openDoorNotify/openDoorNotify_page.dart | 2 +- .../lib/tools/showCupertinoAlertView.dart | 32 ++++ 8 files changed, 163 insertions(+), 99 deletions(-) diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index 36e779a9..b4a2320f 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -712,7 +712,7 @@ "请输入手机号": "Please enter mobile phone number", "家人到家": "Family gets home", "添加家人": "Add family", - "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择": "If the lock is not connected to the Internet, in addition to the electronic key, the password, card, fingerprint and other door reminders can not be sent in time, please choose according to your actual situation", + "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。": "If the lock is not connected to the Internet, in addition to the electronic key, the password, card, fingerprint and other door reminders can not be sent in time, please choose according to your actual situation", "消息提醒": "Message reminder", "开门通知": "Opening notice", "N天未开门": "N days without opening the door", @@ -844,5 +844,14 @@ "钥匙无效": "The key is invalid", "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。": "The operation failed. Please confirm whether the lock is nearby, or restart your phone's Bluetooth and try again.", "如果是全自动锁,请使屏幕变亮": "If it is a fully automatic lock, please make the screen brighter", - "正在尝试闭锁……": "Attempting to lock..." + "正在尝试闭锁……": "Attempting to lock...", + "清空记录":"Clear record", + "是否要删除操作记录?":"Do you want to delete the operation record?", + "被删除的记录不能恢复":"The deleted record cannot be restored", + "全部事件":"All events", + "开锁事件":"Unlock event", + "异常事件":"Abnormal event", + "门铃事件":"Doorbell event", + "视频事件":"Video event" + } diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index 4236badc..348e09a2 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -740,7 +740,7 @@ "请输入手机号":"请输入手机号", "家人到家":"家人到家", "添加家人":"添加家人", - "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择":"若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择", + "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。":"若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。", "消息提醒":"消息提醒", "开门通知":"开门通知", "N天未开门":"N天未开门", @@ -872,5 +872,13 @@ "钥匙无效": "钥匙无效", "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。": "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。", "如果是全自动锁,请使屏幕变亮": "如果是全自动锁,请使屏幕变亮", - "正在尝试闭锁……": "正在尝试闭锁……" + "正在尝试闭锁……": "正在尝试闭锁……", + "清空记录":"清空记录", + "是否要删除操作记录?":"是否要删除操作记录?", + "被删除的记录不能恢复":"被删除的记录不能恢复", + "全部事件":"全部事件", + "开锁事件":"开锁事件", + "异常事件":"异常事件", + "门铃事件":"门铃事件", + "视频事件":"视频事件" } diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index f0ce5803..d741f82b 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -712,7 +712,7 @@ "请输入手机号": "请输入手机号", "家人到家": "家人到家", "添加家人": "添加家人", - "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择": "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择", + "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。": "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。", "消息提醒": "消息提醒", "开门通知": "开门通知", "N天未开门": "N天未开门", @@ -842,5 +842,13 @@ "钥匙无效": "钥匙无效", "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。": "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。", "如果是全自动锁,请使屏幕变亮": "如果是全自动锁,请使屏幕变亮", - "正在尝试闭锁……": "正在尝试闭锁……" + "正在尝试闭锁……": "正在尝试闭锁……", + "清空记录":"清空记录", + "是否要删除操作记录?":"是否要删除操作记录?", + "被删除的记录不能恢复":"被删除的记录不能恢复", + "全部事件":"全部事件", + "开锁事件":"开锁事件", + "异常事件":"异常事件", + "门铃事件":"门铃事件", + "视频事件":"视频事件" } diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index d58f7011..cfa7ba5c 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -1,14 +1,13 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; -import 'package:get_storage/get_storage.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/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; +import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; -import '../../../app_settings/app_settings.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_referEventRecordTime.dart'; import '../../../blue/io_reply.dart'; @@ -137,6 +136,7 @@ class DoorLockLogLogic extends BaseGetXController { //请求操作记录列表(门锁日志) void mockNetworkDataRequest() async { + state.lockLogItemList.clear(); DoorLockLogEntity entity = await ApiRepository.to.lockEventList( lockId: state.keyInfos.value.lockId!, lockEventType: state.dropdownValue.value, @@ -210,10 +210,14 @@ class DoorLockLogLogic extends BaseGetXController { //清空操作记录 void clearOperationRecordRequest() async { - KeyOperationRecordEntity entity = - await ApiRepository.to.clearOperationRecord('28'); + KeyOperationRecordEntity entity = await ApiRepository.to + .clearOperationRecord( + CommonDataManage().currentKeyInfo.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { - showToast("清除数据成功"); + showToast("清除数据成功", something: () { + pageNo = 1; + mockNetworkDataRequest(); + }); } } diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart index 7350085e..220d60b6 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart @@ -9,6 +9,7 @@ import 'package:star_lock/tools/EasyRefreshTool.dart'; import 'package:star_lock/tools/advancedCalendar/src/widget.dart'; import 'package:star_lock/tools/menuItem/xsDropDownWidget.dart'; import 'package:star_lock/tools/noData.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:timelines/timelines.dart'; import '../../../app_settings/app_colors.dart'; @@ -27,11 +28,6 @@ class _DoorLockLogPageState extends State with RouteAware { final logic = Get.put(DoorLockLogLogic()); final state = Get.find().state; - @override - void initState() { - super.initState(); - } - @override Widget build(BuildContext context) { return Scaffold( @@ -40,6 +36,19 @@ class _DoorLockLogPageState extends State with RouteAware { barTitle: TranslationLoader.lanKeys!.operatingRecord!.tr, haveBack: true, backgroundColor: AppColors.mainColor, + actionsList: [ + TextButton( + onPressed: () { + ShowCupertinoAlertView().showClearOperationRecordAlert( + clearClick: () { + logic.clearOperationRecordRequest(); + }); + }, + child: Text( + '清空记录'.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + )), + ], ), body: Column( mainAxisSize: MainAxisSize.max, @@ -53,17 +62,7 @@ class _DoorLockLogPageState extends State with RouteAware { endIndent: 30.w, ), eventDropDownWidget(), - Expanded( - child: EasyRefreshTool( - onRefresh: () { - logic.pageNo = 1; - logic.mockNetworkDataRequest(); - }, - onLoad: () { - logic.mockNetworkDataRequest(); - }, - child: Obx(() => timeLineView(state.lockLogItemList)), - )) + Expanded(child: timeLineView()) ], ), ); @@ -144,77 +143,16 @@ class _DoorLockLogPageState extends State with RouteAware { } //时间轴组件 - Widget timeLineView(List timelineDataList) { + Widget timeLineView() { return Container( margin: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 20.h, top: 20.h), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16.w), ), - child: timelineDataList.isNotEmpty + child: Obx(() => state.lockLogItemList.isNotEmpty ? Timeline.tileBuilder( - builder: TimelineTileBuilder.fromStyle( - contentsAlign: ContentsAlign.basic, - itemCount: timelineDataList.length, - contentsBuilder: (context, index) { - DoorLockLogDataItem timelineData = timelineDataList[index]; - DateTime dateTime = DateTime.fromMillisecondsSinceEpoch( - timelineData.operateDate!); - String formattedTime = - '${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}'; - - return Padding( - padding: EdgeInsets.only(left: 20.w, top: 20.h), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - '$formattedTime ${timelineData.recordTypeName}', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 24.sp, - fontWeight: FontWeight.w600, - ), - ), - SizedBox( - height: 10.h, - ), - GestureDetector( - onTap: () { - Get.toNamed(Routers.videoLogDetailPage); - }, - child: Stack( - children: [ - timelineData.imagesUrl!.isNotEmpty - ? Image.network( - timelineData.imagesUrl!, - width: 260.w, - height: 260.h, - ) - : Container(), - Positioned( - top: 150.h, - left: 10.w, - child: Image( - image: const AssetImage( - 'images/main/icon_lockLog_play.png'), - width: 24.w, - height: 20.w, - ), - ), - ], - ), - ), - SizedBox( - height: 20.h, - ), - ], - ), - ); - }, - ), + builder: _timelineBuilderWidget(), theme: TimelineThemeData( nodePosition: 0.04, //居左侧距离 connectorTheme: const ConnectorThemeData( @@ -229,7 +167,72 @@ class _DoorLockLogPageState extends State with RouteAware { ), ), ) - : NoData(), + : NoData()), + ); + } + + TimelineTileBuilder _timelineBuilderWidget() { + return TimelineTileBuilder.fromStyle( + contentsAlign: ContentsAlign.basic, + itemCount: state.lockLogItemList.length, + contentsBuilder: (context, index) { + DoorLockLogDataItem timelineData = state.lockLogItemList[index]; + DateTime dateTime = + DateTime.fromMillisecondsSinceEpoch(timelineData.operateDate!); + String formattedTime = + '${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}'; + + return Padding( + padding: EdgeInsets.only(left: 20.w, top: 20.h), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '$formattedTime ${timelineData.username!.isNotEmpty ? "${timelineData.username}用" : ""}${timelineData.recordTypeName}', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 24.sp, + fontWeight: FontWeight.w600, + ), + ), + SizedBox( + height: 10.h, + ), + GestureDetector( + onTap: () { + Get.toNamed(Routers.videoLogDetailPage); + }, + child: Stack( + children: [ + timelineData.imagesUrl!.isNotEmpty + ? Image.network( + timelineData.imagesUrl!, + width: 260.w, + height: 260.h, + ) + : Container(), + Positioned( + top: 150.h, + left: 10.w, + child: Image( + image: const AssetImage( + 'images/main/icon_lockLog_play.png'), + width: 24.w, + height: 20.w, + ), + ), + ], + ), + ), + SizedBox( + height: 20.h, + ), + ], + ), + ); + }, ); } diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart index 0fd6d1a7..5cfeda59 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart @@ -27,28 +27,28 @@ class DoorLockLogState { .millisecondsSinceEpoch .obs; - var dropdownTitle = '全部事件'.obs; + var dropdownTitle = '全部事件'.tr.obs; var dropdownValue = XSConstantMacro.lockEventTypeAll.obs; List getDropDownItemList = [ DropDownItem( - itemTitle: "全部事件", + itemTitle: "全部事件".tr, itemValue: XSConstantMacro.lockEventTypeAll.toString(), isCheked: false), DropDownItem( - itemTitle: "开锁事件", + itemTitle: "开锁事件".tr, itemValue: XSConstantMacro.lockEventTypeOpenDoor.toString(), isCheked: false), DropDownItem( - itemTitle: "异常事件", + itemTitle: "异常事件".tr, itemValue: XSConstantMacro.lockEventTypeAbnormal.toString(), isCheked: false), DropDownItem( - itemTitle: "门铃事件", + itemTitle: "门铃事件".tr, itemValue: XSConstantMacro.lockEventTypeDoorbell.toString(), isCheked: false), DropDownItem( - itemTitle: "视频事件", + itemTitle: "视频事件".tr, itemValue: XSConstantMacro.lockEventTypeVideo.toString(), isCheked: false), ]; diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart index a05f19b8..009619ad 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart @@ -72,7 +72,7 @@ class _OpenDoorNotifyPageState extends State { alignment: Alignment.centerLeft, margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), child: Text( - '若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择'.tr, + '若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。'.tr, style: TextStyle(color: AppColors.darkGrayTextColor, fontSize: 20.sp), )); } diff --git a/star_lock/lib/tools/showCupertinoAlertView.dart b/star_lock/lib/tools/showCupertinoAlertView.dart index dd9f7336..09ee39a7 100644 --- a/star_lock/lib/tools/showCupertinoAlertView.dart +++ b/star_lock/lib/tools/showCupertinoAlertView.dart @@ -364,4 +364,36 @@ class ShowCupertinoAlertView { }, ); } + + //清空操作记录弹窗 + void showClearOperationRecordAlert({required Function clearClick}) { + showCupertinoDialog( + context: Get.context!, + builder: (context) { + return CupertinoAlertDialog( + title: Text('是否要删除操作记录?'.tr), + content: Text('被删除的记录不能恢复'.tr), + actions: [ + CupertinoDialogAction( + child: Text( + '取消'.tr, + style: TextStyle(color: AppColors.mainColor), + ), + onPressed: () { + Get.back(); + }, + ), + CupertinoDialogAction( + child: + Text('删除'.tr, style: TextStyle(color: AppColors.mainColor)), + onPressed: () { + Get.back(); + clearClick(); + }, + ), + ], + ); + }, + ); + } }