diff --git a/star_lock/images/icon_lock_circle.png b/star_lock/images/icon_lock_circle.png new file mode 100644 index 00000000..8ff61791 Binary files /dev/null and b/star_lock/images/icon_lock_circle.png differ diff --git a/star_lock/lib/main/lockMian/lockList/lockList_page.dart b/star_lock/lib/main/lockMian/lockList/lockList_page.dart index 214f898e..66f07890 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_page.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; +import 'package:star_lock/flavors.dart'; import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; @@ -37,17 +38,6 @@ class _LockListPageState extends State with RouteAware { widget.lockListInfoGroupEntity.groupList as Iterable); return Scaffold( - floatingActionButton: FloatingActionButton( - shape: const CircleBorder(), - onPressed: () { - Get.toNamed(Routers.addLockPage); - }, - backgroundColor: AppColors.mainColor, - child: const Icon( - Icons.add, - color: AppColors.darkGrayTextColor, - ), - ), body: ListView.separated( itemCount: groupDataList.length, itemBuilder: (context, index) { @@ -70,8 +60,6 @@ class _LockListPageState extends State with RouteAware { List lockItemList = itemData.lockList ?? []; return LockListGroupPage( onTap: () { - // selectGroupIdList.add(index); - // clickIndex = index; //是否选中组 if (itemData.isChecked) { } else {} diff --git a/star_lock/lib/main/lockMian/lockList/lockList_xhj_page.dart b/star_lock/lib/main/lockMian/lockList/lockList_xhj_page.dart new file mode 100644 index 00000000..b283e009 --- /dev/null +++ b/star_lock/lib/main/lockMian/lockList/lockList_xhj_page.dart @@ -0,0 +1,507 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/flavors.dart'; + +import '../../../appRouters.dart'; +import '../../../app_settings/app_colors.dart'; +import '../../../common/XSConstantMacro/XSConstantMacro.dart'; +import '../../../tools/appRouteObserver.dart'; +import '../../../tools/dateTool.dart'; +import '../entity/lockListInfo_entity.dart'; +import 'lockListGroup_page.dart'; +import 'lockList_logic.dart'; + +class LockListXHJPage extends StatefulWidget { + final LockListInfoGroupEntity lockListInfoGroupEntity; + + const LockListXHJPage({Key? key, required this.lockListInfoGroupEntity}) + : super(key: key); + + @override + State createState() => _LockListXHJPageState(); +} + +class _LockListXHJPageState extends State with RouteAware { + final logic = Get.put(LockListLogic()); + final state = Get.find().state; + + var groupDataList = []; + + @override + Widget build(BuildContext context) { + if (widget.lockListInfoGroupEntity.pageNo == 1) { + groupDataList = []; + } + groupDataList.addAll( + widget.lockListInfoGroupEntity.groupList as Iterable); + + return Scaffold( + floatingActionButton: FloatingActionButton( + shape: const CircleBorder(), + onPressed: () { + Get.toNamed(Routers.selectLockTypePage); + }, + backgroundColor: AppColors.mainColor, + child: const Icon( + Icons.add, + color: AppColors.darkGrayTextColor, + ), + ), + body: ListView.separated( + itemCount: groupDataList.length, + itemBuilder: (context, index) { + GroupList itemData = groupDataList[index]; + return _buildLockExpandedList(context, index, itemData); + }, + shrinkWrap: true, + physics: const AlwaysScrollableScrollPhysics(), + separatorBuilder: (context, index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }), + ); + } + + //设备多层级列表 + Widget _buildLockExpandedList(context, index, GroupList itemData) { + List lockItemList = itemData.lockList ?? []; + return LockListGroupPage( + onTap: () { + //是否选中组 + if (itemData.isChecked) { + } else {} + setState(() {}); + }, + typeImgList: const [], + groupItem: itemData, + child: ListView.separated( + itemCount: lockItemList.length, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + separatorBuilder: (context, index) { + return const Divider(height: 1, color: AppColors.greyLineColor); + }, + itemBuilder: (c, index) { + LockListInfoItemEntity keyInfo = lockItemList[index]; + bool isLast = false; + if (lockItemList.length == index + 1) { + isLast = true; + } + + return Slidable( + key: ValueKey(keyInfo.keyId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context) { + state.lockListInfoItemEntity = keyInfo; + logic.deleyLockLogicOfRoles(); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除'.tr, + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: lockInfoListItem(keyInfo, isLast, () { + if ((keyInfo.keyType == XSConstantMacro.keyTypeTime || + keyInfo.keyType == XSConstantMacro.keyTypeLoop) && + (keyInfo.keyStatus == + XSConstantMacro.keyStatusWaitIneffective)) { + logic.showToast("您的钥匙未生效".tr); + return; + } + if ((keyInfo.keyType == XSConstantMacro.keyTypeTime || + keyInfo.keyType == XSConstantMacro.keyTypeLoop) && + (keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)) { + logic.showToast("您的钥匙已冻结".tr); + return; + } + if ((keyInfo.keyType == XSConstantMacro.keyTypeTime || + keyInfo.keyType == XSConstantMacro.keyTypeLoop) && + (keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) { + logic.showToast("您的钥匙已过期".tr); + return; + } + Get.toNamed(Routers.lockDetailMainPage, arguments: { + // "lockMainEntity": widget.lockMainEntity, + "keyInfo": keyInfo, + "isOnlyOneData": false, + }); + }), + ); + }), + ); + } + + Widget lockInfoListItem( + LockListInfoItemEntity keyInfo, bool isLast, Function() action) { + return F.sw( + defaultCall: () => _defaultLockInfoListItem(keyInfo, isLast, action), + xhjCall: () => _xhjLockInfoListItem(keyInfo, isLast, action)); + } + + Widget _defaultLockInfoListItem( + LockListInfoItemEntity keyInfo, bool isLast, Function() action) { + return GestureDetector( + onTap: action, + child: Container( + // height: 122.h, + margin: isLast + ? EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w, bottom: 20.w) + : EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), + decoration: BoxDecoration( + color: ((keyInfo.keyType == XSConstantMacro.keyTypeTime || + keyInfo.keyType == XSConstantMacro.keyTypeLoop) && + (keyInfo.keyStatus == + XSConstantMacro.keyStatusWaitIneffective || + keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen || + keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) + ? AppColors.greyBackgroundColor + : Colors.white, + borderRadius: BorderRadius.circular(20.w), + ), + child: Column( + // mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + height: 20.h, + ), + Row( + children: [ + SizedBox(width: 30.w), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + keyInfo.lockAlias!, + style: TextStyle( + fontSize: 24.sp, + fontWeight: FontWeight.w500, + color: keyInfo.passageMode == 1 + ? AppColors.openPassageModeColor + : AppColors.darkGrayTextColor), + ), + ], + ), + ), + SizedBox(width: 20.w), + Image.asset( + logic.showElectricIcon(keyInfo.electricQuantity!), + width: 30.w, + height: 24.w, + ), + SizedBox(width: 2.w), + Text( + "${keyInfo.electricQuantity!}%", + style: TextStyle( + fontSize: 18.sp, color: AppColors.darkGrayTextColor), + ), + SizedBox(width: 30.w), + ], + ), + SizedBox(height: 5.h), + Visibility( + visible: keyInfo.passageMode == 1 ? true : false, + child: Row( + children: [ + SizedBox(width: 30.w), + Container( + padding: EdgeInsets.only(right: 5.w, left: 5.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.w), + color: AppColors.openPassageModeColor, + ), + child: Text("常开模式开启".tr, + style: TextStyle( + fontSize: 18.sp, + color: AppColors.appBarIconColor)), + ), + ], + )), + SizedBox(height: 5.h), + Visibility( + visible: keyInfo.lockSetting!.remoteUnlock == 1 ? true : false, + child: Row( + children: [ + SizedBox(width: 30.w), + Text( + "远程开锁".tr, + style: TextStyle( + fontSize: 18.sp, color: AppColors.darkGrayTextColor), + ), + ], + )), + 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)) + ? true + : false, + // visible: true, + child: Row( + children: [ + SizedBox(width: 30.w), + Container( + padding: EdgeInsets.only(right: 5.w, left: 5.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.w), + color: + DateTool().compareTimeIsOvertime(keyInfo.endDate!) + ? AppColors.listTimeYellowColor + : AppColors.mainColor, + ), + child: Text(logic.getKeyEffective(keyInfo), + style: TextStyle(fontSize: 18.sp, color: Colors.white) + // child: Text(logic.compareTimeIsOvertime(keyInfo.endDate!) ? "已过期" : "余${logic.compareTimeGetDaysFromNow(keyInfo.endDate!)}天", style: TextStyle(fontSize: 18.sp, color: Colors.white) + ), + ), + ], + )), + SizedBox(height: 5.h), + Row( + children: [ + SizedBox(width: 30.w), + Text( + "${logic.getUseKeyTypeStr(keyInfo.startDate, keyInfo.endDate, keyInfo.keyType)}/${keyInfo.isLockOwner == 1 ? '超级管理员'.tr : (keyInfo.keyRight == 1 ? "授权管理员".tr : "普通用户".tr)}", + style: TextStyle( + fontSize: 18.sp, color: AppColors.darkGrayTextColor), + ), + ], + ), + SizedBox(height: 20.h), + ], + ), + ), + ); + } + + Widget _xhjLockInfoListItem( + LockListInfoItemEntity keyInfo, bool isLast, Function() action) { + return GestureDetector( + onTap: action, + child: Container( + // height: 122.h, + margin: isLast + ? EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w, bottom: 20.w) + : EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), + decoration: BoxDecoration( + color: ((keyInfo.keyType == XSConstantMacro.keyTypeTime || + keyInfo.keyType == XSConstantMacro.keyTypeLoop) && + (keyInfo.keyStatus == + XSConstantMacro.keyStatusWaitIneffective || + keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen || + keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) + ? AppColors.greyBackgroundColor + : Colors.white, + borderRadius: BorderRadius.circular(20.w), + ), + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 30.w, vertical: 20.h), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Image.asset( + 'images/icon_lock_circle.png', + width: 32.r, + height: 32.r, + color: AppColors.mainColor, + ), + SizedBox( + width: 8.w, + ), + Expanded( + child: Text(keyInfo.lockAlias!, + style: TextStyle( + fontSize: 32.sp, + fontWeight: FontWeight.w500, + color: keyInfo.passageMode == 1 + ? AppColors.openPassageModeColor + : AppColors.darkGrayTextColor, + overflow: TextOverflow.ellipsis, + ), + maxLines: 1), + ), + Text( + logic.getUseKeyTypeStr( + keyInfo.startDate, keyInfo.endDate, keyInfo.keyType), + style: TextStyle( + fontSize: 18.sp, color: AppColors.darkGrayTextColor), + ) + ], + ), + Visibility( + visible: keyInfo.passageMode == 1 ? true : false, + child: Padding( + padding: EdgeInsets.only(top: 5.h), + child: Row( + children: [ + Container( + padding: EdgeInsets.only(right: 5.w, left: 5.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.w), + color: AppColors.openPassageModeColor, + ), + child: Text("常开模式开启".tr, + style: TextStyle( + fontSize: 18.sp, + color: AppColors.appBarIconColor)), + ), + ], + ), + )), + Visibility( + visible: + keyInfo.lockSetting!.remoteUnlock == 1 ? true : false, + child: Padding( + padding: EdgeInsets.only(top: 5.h), + child: Row( + children: [ + Text( + "远程开锁".tr, + style: TextStyle( + fontSize: 18.sp, + color: AppColors.darkGrayTextColor), + ), + ], + ), + )), + 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)) + ? true + : false, + child: Padding( + padding: EdgeInsets.only(top: 20.h), + child: Row( + children: [ + Container( + padding: EdgeInsets.only(right: 5.w, left: 5.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.w), + color: DateTool() + .compareTimeIsOvertime(keyInfo.endDate!) + ? AppColors.listTimeYellowColor + : AppColors.mainColor, + ), + child: Text(logic.getKeyEffective(keyInfo), + style: TextStyle( + fontSize: 18.sp, color: Colors.white) + // child: Text(logic.compareTimeIsOvertime(keyInfo.endDate!) ? "已过期" : "余${logic.compareTimeGetDaysFromNow(keyInfo.endDate!)}天", style: TextStyle(fontSize: 18.sp, color: Colors.white) + ), + ), + ], + ), + )), + SizedBox(height: 5.h), + Row( + children: [ + Expanded( + child: Text( + keyInfo.isLockOwner == 1 + ? '超级管理员'.tr + : (keyInfo.keyRight == 1 ? "授权管理员".tr : "普通用户".tr), + style: TextStyle( + fontSize: 18.sp, color: AppColors.darkGrayTextColor), + ), + ), + Image.asset( + logic.showElectricIcon(keyInfo.electricQuantity!), + width: 30.w, + height: 24.w, + ), + SizedBox(width: 2.w), + Text( + "${keyInfo.electricQuantity!}%", + style: TextStyle( + fontSize: 18.sp, color: AppColors.darkGrayTextColor), + ), + ], + ), + Text( + keyInfo.hwVersion ?? "", + style: TextStyle( + fontSize: 18.sp, color: AppColors.darkGrayTextColor), + ), + ], + ), + ), + ), + ); + } + + @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(); + } + + /// 从上级界面进入 当前界面即将出现 + @override + void didPush() { + super.didPush(); + state.ifCurrentScreen.value = true; + } + + /// 返回上一个界面 当前界面即将消失 + @override + void didPop() { + super.didPop(); + logic.cancelBlueConnetctToastTimer(); + + // BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + } + + /// 从下级返回 当前界面即将出现 + @override + void didPopNext() { + super.didPopNext(); + state.ifCurrentScreen.value = true; + } + + /// 进入下级界面 当前界面即将消失 + @override + void didPushNext() { + super.didPushNext(); + logic.cancelBlueConnetctToastTimer(); + + // BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + } +} diff --git a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart index 55c4f793..ec382028 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart @@ -4,6 +4,7 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/main/lockMian/lockList/lockList_xhj_page.dart'; import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/submitBtn.dart'; @@ -138,8 +139,11 @@ class _StarLockMainPageState extends State with BaseWidget { case 2: // 有多条数据 Storage.setBool(ifIsDemoModeOrNot, false); - returnWidget = LockListPage( - lockListInfoGroupEntity: state.lockListInfoGroupEntity.value); + returnWidget = F.sw( + defaultCall: () => LockListPage( + lockListInfoGroupEntity: state.lockListInfoGroupEntity.value), + xhjCall: () => LockListXHJPage( + lockListInfoGroupEntity: state.lockListInfoGroupEntity.value)); break; default: returnWidget = NoData(); diff --git a/star_lock/lib/mine/addLock/addLock/addLock_state.dart b/star_lock/lib/mine/addLock/addLock/addLock_state.dart index 04184a8b..280ab527 100644 --- a/star_lock/lib/mine/addLock/addLock/addLock_state.dart +++ b/star_lock/lib/mine/addLock/addLock/addLock_state.dart @@ -5,8 +5,8 @@ class AddLockState { var lockTypeImg = 'images/lockType/addLock_touchScreen.png'.obs; //不同类型锁图片更换 AddLockState() { - Map map = Get.arguments; - if (map.isNotEmpty) { + Map? map = Get.arguments; + if (map is Map && map.isNotEmpty) { if (map["getLockType"] != null) { getLockType.value = map["getLockType"]; //保险箱锁