diff --git a/star_lock/lib/main/lockMian/lockList/lockList_page.dart b/star_lock/lib/main/lockMian/lockList/lockList_page.dart index 2dc91e9b..214f898e 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_page.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; @@ -16,7 +15,8 @@ import 'lockList_logic.dart'; class LockListPage extends StatefulWidget { final LockListInfoGroupEntity lockListInfoGroupEntity; - const LockListPage({Key? key, required this.lockListInfoGroupEntity}) : super(key: key); + const LockListPage({Key? key, required this.lockListInfoGroupEntity}) + : super(key: key); @override State createState() => _LockListPageState(); @@ -30,44 +30,41 @@ class _LockListPageState extends State with RouteAware { @override Widget build(BuildContext context) { - if(widget.lockListInfoGroupEntity.pageNo == 1){ + if (widget.lockListInfoGroupEntity.pageNo == 1) { groupDataList = []; } - groupDataList.addAll(widget.lockListInfoGroupEntity.groupList as Iterable); + groupDataList.addAll( + widget.lockListInfoGroupEntity.groupList as Iterable); - return ListView.separated( - itemCount: groupDataList.length, - itemBuilder: (context, index) { - GroupList itemData = groupDataList[index]; - return _buildLockExpandedList(context, index, itemData); + return Scaffold( + floatingActionButton: FloatingActionButton( + shape: const CircleBorder(), + onPressed: () { + Get.toNamed(Routers.addLockPage); }, - shrinkWrap: true, - physics:const AlwaysScrollableScrollPhysics(), - separatorBuilder: (context, index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }); + 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 _buildListView(BuildContext context, List itemList) { - // return ListView.separated( - // itemCount: itemList.length, - // itemBuilder: (context, index) { - // GroupList itemData = itemList[index]; - // return _buildLockExpandedList(context, index, itemData); - // }, - // shrinkWrap: true, - // separatorBuilder: (context, index) { - // return const Divider( - // height: 1, - // color: AppColors.greyLineColor, - // ); - // }); - // } - //设备多层级列表 Widget _buildLockExpandedList(context, index, GroupList itemData) { List lockItemList = itemData.lockList ?? []; @@ -77,10 +74,7 @@ class _LockListPageState extends State with RouteAware { // clickIndex = index; //是否选中组 if (itemData.isChecked) { - - }else{ - - } + } else {} setState(() {}); }, typeImgList: const [], @@ -88,25 +82,25 @@ class _LockListPageState extends State with RouteAware { child: ListView.separated( itemCount: lockItemList.length, shrinkWrap: true, - physics:const NeverScrollableScrollPhysics(), + 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){ + if (lockItemList.length == index + 1) { isLast = true; } return Slidable( - key:ValueKey(keyInfo.keyId), + key: ValueKey(keyInfo.keyId), endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), children: [ SlidableAction( - onPressed: (BuildContext context){ + onPressed: (BuildContext context) { state.lockListInfoItemEntity = keyInfo; logic.deleyLockLogicOfRoles(); }, @@ -118,15 +112,22 @@ class _LockListPageState extends State with RouteAware { ], ), child: lockInfoListItem(keyInfo, isLast, () { - if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective)){ + 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)){ + 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)){ + if ((keyInfo.keyType == XSConstantMacro.keyTypeTime || + keyInfo.keyType == XSConstantMacro.keyTypeLoop) && + (keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) { logic.showToast("您的钥匙已过期".tr); return; } @@ -137,40 +138,28 @@ class _LockListPageState extends State with RouteAware { }); }), ); - - // return lockInfoListItem(keyInfo, isLast, () { - // if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective)){ - // logic.showToast("您的钥匙未生效"); - // // return; - // } - // if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)){ - // logic.showToast("您的钥匙已冻结"); - // // return; - // } - // if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)){ - // logic.showToast("您的钥匙已过期"); - // // return; - // } - // Get.toNamed(Routers.lockDetailMainPage, arguments: { - // // "lockMainEntity": widget.lockMainEntity, - // "keyInfo": keyInfo, - // "isOnlyOneData": false, - // }); - // }); }), ); } - Widget lockInfoListItem(LockListInfoItemEntity keyInfo, bool isLast, Function() action) { + Widget lockInfoListItem( + 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), + 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, + 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( @@ -190,7 +179,11 @@ class _LockListPageState extends State with RouteAware { Text( keyInfo.lockAlias!, style: TextStyle( - fontSize: 24.sp, fontWeight: FontWeight.w500, color: keyInfo.passageMode == 1 ? AppColors.openPassageModeColor : AppColors.darkGrayTextColor), + fontSize: 24.sp, + fontWeight: FontWeight.w500, + color: keyInfo.passageMode == 1 + ? AppColors.openPassageModeColor + : AppColors.darkGrayTextColor), ), ], ), @@ -213,7 +206,7 @@ class _LockListPageState extends State with RouteAware { SizedBox(height: 5.h), Visibility( visible: keyInfo.passageMode == 1 ? true : false, - child:Row( + child: Row( children: [ SizedBox(width: 30.w), Container( @@ -222,42 +215,55 @@ class _LockListPageState extends State with RouteAware { borderRadius: BorderRadius.circular(5.w), color: AppColors.openPassageModeColor, ), - child: Text("常开模式开启".tr, style: TextStyle(fontSize: 18.sp, color: AppColors.appBarIconColor)), + 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( + child: Row( children: [ SizedBox(width: 30.w), Text( - "远程开锁".tr, style: TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor), + "远程开锁".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)) + 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( + // 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) + 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) + ), ), ], )), @@ -329,5 +335,4 @@ class _LockListPageState extends State with RouteAware { // 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 3993ee28..55c4f793 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart @@ -118,6 +118,10 @@ class _StarLockMainPageState extends State with BaseWidget { Widget getDataReturnUI(int type) { Widget returnWidget; + + if (type == 1) { + type = F.sw(defaultCall: () => 1, xhjCall: () => 2); + } switch (type) { case 0: // 显示无数据模式 diff --git a/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart b/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart index 7eae2768..364a7f92 100644 --- a/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart @@ -41,35 +41,31 @@ class _StarLockMainXHJPageState extends State builder: (LockMainXHJLogic logic) { return Scaffold( backgroundColor: const Color(0xFFF5F5F5), - floatingActionButton: FloatingActionButton( - shape: const CircleBorder(), - onPressed: () { - logic.openEquipment(); - }, - backgroundColor: AppColors.mainColor, - tooltip: TranslationLoader.lanKeys!.device!.tr, - child: const Icon( - Icons.key, - color: AppColors.darkGrayTextColor, - ), - ), body: SafeArea( bottom: false, child: Stack( children: [ + pageView( + widget: StarLockMainPage( + showAppBar: false, + showDrawer: false, + ), + logic: logic, + index: 0, + ), pageView( widget: LockMallPage( showAppBar: false, ), logic: logic, - index: 0, + index: 1, ), pageView( widget: MessageListPage( showAppBar: false, ), logic: logic, - index: 1, + index: 2, ), pageView( widget: MinePersonInfoPage( @@ -77,7 +73,7 @@ class _StarLockMainXHJPageState extends State showAbout: true, ), logic: logic, - index: 2, + index: 3, ), ], ), @@ -97,18 +93,25 @@ class _StarLockMainXHJPageState extends State top: false, child: Row( children: [ - navigationBarItem(Icons.shopping_cart, '商城'.tr, logic, 0, - () { + navigationBarItem( + Icons.key, + TranslationLoader.lanKeys!.device!.tr, + logic, + 0, () { logic.setIndex(0); }), - navigationBarItem(Icons.message, - TranslationLoader.lanKeys!.message!.tr, logic, 1, () { + navigationBarItem(Icons.shopping_cart, '商城'.tr, logic, 1, + () { logic.setIndex(1); }), - navigationBarItem(Icons.account_circle, '我的'.tr, logic, 2, - () { + navigationBarItem(Icons.message, + TranslationLoader.lanKeys!.message!.tr, logic, 2, () { logic.setIndex(2); }), + navigationBarItem(Icons.account_circle, '我的'.tr, logic, 3, + () { + logic.setIndex(3); + }), ], ), ),