fix:修复锁列表和锁页面没有显示钥匙过期的时间状态提示

This commit is contained in:
anfe 2024-07-01 17:46:33 +08:00
parent 1b97722657
commit 208dc9ff8a
4 changed files with 57 additions and 18 deletions

View File

@ -93,6 +93,18 @@ class _LockDetailPageState extends State<LockDetailPage>
//
Widget xhjWidget() {
final bool isShowTip = (state.keyInfos.value.keyType ==
XSConstantMacro.keyTypeTime ||
state.keyInfos.value.keyType ==
XSConstantMacro.keyTypeLoop) && //
(DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) <=
15 &&
DateTool()
.compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) >=
0) && // 030
(state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusNormalUse ||
state.keyInfos.value.keyStatus ==
XSConstantMacro.keyStatusWaitReceive);
return Scaffold(
backgroundColor: Colors.white,
body: Obx(() {
@ -103,7 +115,7 @@ class _LockDetailPageState extends State<LockDetailPage>
child: Column(
children: <Widget>[
SizedBox(
height: 10.h,
height: isShowTip ? 70.h : 10.h,
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
@ -144,6 +156,23 @@ class _LockDetailPageState extends State<LockDetailPage>
],
),
),
Visibility(
visible: isShowTip,
child: Container(
// height: 30.h,
color: const Color(0xFFFBEFD4),
padding: EdgeInsets.only(top: 8.h, bottom: 8.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"${"钥匙将在".tr}${DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!)}${"天后失效".tr}",
style: TextStyle(
color: const Color(0xffCBA74B), fontSize: 24.sp))
],
),
),
),
Visibility(
visible: state.iSClosedUnlockSuccessfulPopup.value,
child: Container(

View File

@ -1,5 +1,6 @@
import 'dart:async';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
@ -30,7 +31,8 @@ class LockListLogic extends BaseGetXController {
LockListInfoGroupEntity? entity;
List<GroupList> get groupDataList {
final List<GroupList> list = _groupDataList.map((e)=>e.copy()).toList();
final List<GroupList> list =
_groupDataList.map((GroupList e) => e.copy()).toList();
if (state.searchStr.value != '' && state.showSearch.value) {
list.forEach((GroupList element) {
element.lockList?.removeWhere((LockListInfoItemEntity element) =>
@ -141,6 +143,28 @@ class LockListLogic extends BaseGetXController {
return '';
}
//
bool getShowType(LockListInfoItemEntity keyInfo) {
final List<int> keyTypes = <int>[
XSConstantMacro.keyTypeTime,
XSConstantMacro.keyTypeLoop
];
final List<int> keyStatus = <int>[
XSConstantMacro.keyStatusWaitIneffective,
XSConstantMacro.keyStatusFrozen,
XSConstantMacro.keyStatusExpired,
];
final DateTime endDate =
DateTime.fromMillisecondsSinceEpoch(keyInfo.endDate ?? 0);
final DateTime now = DateTime.now();
final bool isKeyType = keyTypes.contains(keyInfo.keyType);
final bool isKeyStatus = keyStatus.contains(keyInfo.keyStatus);
final Duration difference = endDate.difference(now);
final bool isExpirationSoon = isKeyType && difference.inDays <= 15;
final bool isShow = isKeyType && isKeyStatus || isExpirationSoon;
return isShow;
}
///
void deleyLockLogicOfRoles() {
if (state.lockListInfoItemEntity.isLockOwner == 1) {

View File

@ -14,7 +14,6 @@ import 'lockListGroup_view.dart';
import 'lockList_logic.dart';
class LockListPage extends StatefulWidget {
const LockListPage({required this.lockListInfoGroupEntity, Key? key})
: super(key: key);
final LockListInfoGroupEntity lockListInfoGroupEntity;
@ -229,13 +228,7 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
)),
SizedBox(height: 20.h),
Visibility(
visible: (keyInfo.keyType == XSConstantMacro.keyTypeTime ||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective ||
keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen ||
keyInfo.keyStatus == XSConstantMacro.keyStatusExpired),
// visible: true,
visible: logic.getShowType(keyInfo),
child: Row(
children: <Widget>[
SizedBox(width: 30.w),

View File

@ -360,14 +360,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
],
),
Visibility(
visible: (keyInfo.keyType == XSConstantMacro.keyTypeTime ||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective ||
keyInfo.keyStatus ==
XSConstantMacro.keyStatusFrozen ||
keyInfo.keyStatus ==
XSConstantMacro.keyStatusExpired),
visible: logic.getShowType(keyInfo),
child: Padding(
padding: EdgeInsets.only(top: 5.h),
child: Row(