feat:修改首页布局

This commit is contained in:
anfe 2024-04-28 09:05:24 +08:00
parent a37cbf31f5
commit f04adc5db5
3 changed files with 120 additions and 108 deletions

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_slidable/flutter_slidable.dart';
@ -16,7 +15,8 @@ import 'lockList_logic.dart';
class LockListPage extends StatefulWidget { class LockListPage extends StatefulWidget {
final LockListInfoGroupEntity lockListInfoGroupEntity; final LockListInfoGroupEntity lockListInfoGroupEntity;
const LockListPage({Key? key, required this.lockListInfoGroupEntity}) : super(key: key); const LockListPage({Key? key, required this.lockListInfoGroupEntity})
: super(key: key);
@override @override
State<LockListPage> createState() => _LockListPageState(); State<LockListPage> createState() => _LockListPageState();
@ -30,44 +30,41 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if(widget.lockListInfoGroupEntity.pageNo == 1){ if (widget.lockListInfoGroupEntity.pageNo == 1) {
groupDataList = <GroupList>[]; groupDataList = <GroupList>[];
} }
groupDataList.addAll(widget.lockListInfoGroupEntity.groupList as Iterable<GroupList>); groupDataList.addAll(
widget.lockListInfoGroupEntity.groupList as Iterable<GroupList>);
return ListView.separated( return Scaffold(
itemCount: groupDataList.length, floatingActionButton: FloatingActionButton(
itemBuilder: (context, index) { shape: const CircleBorder(),
GroupList itemData = groupDataList[index]; onPressed: () {
return _buildLockExpandedList(context, index, itemData); Get.toNamed(Routers.addLockPage);
}, },
shrinkWrap: true, backgroundColor: AppColors.mainColor,
physics:const AlwaysScrollableScrollPhysics(), child: const Icon(
separatorBuilder: (context, index) { Icons.add,
return const Divider( color: AppColors.darkGrayTextColor,
height: 1, ),
color: AppColors.greyLineColor, ),
); 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) { Widget _buildLockExpandedList(context, index, GroupList itemData) {
List lockItemList = itemData.lockList ?? []; List lockItemList = itemData.lockList ?? [];
@ -77,10 +74,7 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
// clickIndex = index; // clickIndex = index;
// //
if (itemData.isChecked) { if (itemData.isChecked) {
} else {}
}else{
}
setState(() {}); setState(() {});
}, },
typeImgList: const [], typeImgList: const [],
@ -88,25 +82,25 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
child: ListView.separated( child: ListView.separated(
itemCount: lockItemList.length, itemCount: lockItemList.length,
shrinkWrap: true, shrinkWrap: true,
physics:const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (context, index) { separatorBuilder: (context, index) {
return const Divider(height: 1, color: AppColors.greyLineColor); return const Divider(height: 1, color: AppColors.greyLineColor);
}, },
itemBuilder: (c, index) { itemBuilder: (c, index) {
LockListInfoItemEntity keyInfo = lockItemList[index]; LockListInfoItemEntity keyInfo = lockItemList[index];
bool isLast = false; bool isLast = false;
if (lockItemList.length == index+1){ if (lockItemList.length == index + 1) {
isLast = true; isLast = true;
} }
return Slidable( return Slidable(
key:ValueKey(keyInfo.keyId), key: ValueKey(keyInfo.keyId),
endActionPane: ActionPane( endActionPane: ActionPane(
extentRatio: 0.2, extentRatio: 0.2,
motion: const ScrollMotion(), motion: const ScrollMotion(),
children: [ children: [
SlidableAction( SlidableAction(
onPressed: (BuildContext context){ onPressed: (BuildContext context) {
state.lockListInfoItemEntity = keyInfo; state.lockListInfoItemEntity = keyInfo;
logic.deleyLockLogicOfRoles(); logic.deleyLockLogicOfRoles();
}, },
@ -118,15 +112,22 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
], ],
), ),
child: lockInfoListItem(keyInfo, isLast, () { 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); logic.showToast("您的钥匙未生效".tr);
return; 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); logic.showToast("您的钥匙已冻结".tr);
return; 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); logic.showToast("您的钥匙已过期".tr);
return; return;
} }
@ -137,40 +138,28 @@ class _LockListPageState extends State<LockListPage> 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( return GestureDetector(
onTap: action, onTap: action,
child: Container( child: Container(
// height: 122.h, // 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( decoration: BoxDecoration(
color: ((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && color: ((keyInfo.keyType == XSConstantMacro.keyTypeTime ||
(keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective || keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen || keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
? AppColors.greyBackgroundColor : Colors.white, (keyInfo.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective ||
keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen ||
keyInfo.keyStatus == XSConstantMacro.keyStatusExpired))
? AppColors.greyBackgroundColor
: Colors.white,
borderRadius: BorderRadius.circular(20.w), borderRadius: BorderRadius.circular(20.w),
), ),
child: Column( child: Column(
@ -190,7 +179,11 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
Text( Text(
keyInfo.lockAlias!, keyInfo.lockAlias!,
style: TextStyle( 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<LockListPage> with RouteAware {
SizedBox(height: 5.h), SizedBox(height: 5.h),
Visibility( Visibility(
visible: keyInfo.passageMode == 1 ? true : false, visible: keyInfo.passageMode == 1 ? true : false,
child:Row( child: Row(
children: [ children: [
SizedBox(width: 30.w), SizedBox(width: 30.w),
Container( Container(
@ -222,42 +215,55 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
borderRadius: BorderRadius.circular(5.w), borderRadius: BorderRadius.circular(5.w),
color: AppColors.openPassageModeColor, 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), SizedBox(height: 5.h),
Visibility( Visibility(
visible: keyInfo.lockSetting!.remoteUnlock == 1 ? true : false, visible: keyInfo.lockSetting!.remoteUnlock == 1 ? true : false,
child:Row( child: Row(
children: [ children: [
SizedBox(width: 30.w), SizedBox(width: 30.w),
Text( Text(
"远程开锁".tr, style: TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor), "远程开锁".tr,
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
), ),
], ],
)), )),
SizedBox(height: 20.h), SizedBox(height: 20.h),
Visibility( Visibility(
visible: ( visible: ((keyInfo.keyType == XSConstantMacro.keyTypeTime ||
(keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective || keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen || keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) (keyInfo.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective ||
keyInfo.keyStatus ==
XSConstantMacro.keyStatusFrozen ||
keyInfo.keyStatus ==
XSConstantMacro.keyStatusExpired))
? true ? true
: false, : false,
// visible: true, // visible: true,
child:Row( child: Row(
children: [ children: [
SizedBox(width: 30.w), SizedBox(width: 30.w),
Container( Container(
padding: EdgeInsets.only(right: 5.w, left: 5.w), padding: EdgeInsets.only(right: 5.w, left: 5.w),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.w), borderRadius: BorderRadius.circular(5.w),
color: DateTool().compareTimeIsOvertime(keyInfo.endDate!) ? AppColors.listTimeYellowColor : AppColors.mainColor, color:
), DateTool().compareTimeIsOvertime(keyInfo.endDate!)
child: Text(logic.getKeyEffective(keyInfo), style: TextStyle(fontSize: 18.sp, color: Colors.white) ? AppColors.listTimeYellowColor
// child: Text(logic.compareTimeIsOvertime(keyInfo.endDate!) ? "已过期" : "${logic.compareTimeGetDaysFromNow(keyInfo.endDate!)}", style: TextStyle(fontSize: 18.sp, color: Colors.white) : 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)
),
), ),
], ],
)), )),
@ -333,5 +339,4 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
// BlueManage().stopScan(); // BlueManage().stopScan();
state.ifCurrentScreen.value = false; state.ifCurrentScreen.value = false;
} }
} }

View File

@ -119,6 +119,10 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
Widget getDataReturnUI(int type) { Widget getDataReturnUI(int type) {
Widget returnWidget; Widget returnWidget;
if (type == 1) {
type = F.sw(defaultCall: () => 1, xhjCall: () => 2);
}
switch (type) { switch (type) {
case 0: case 0:
// //

View File

@ -41,35 +41,31 @@ class _StarLockMainXHJPageState extends State<StarLockMainXHJPage>
builder: (LockMainXHJLogic logic) { builder: (LockMainXHJLogic logic) {
return Scaffold( return Scaffold(
backgroundColor: const Color(0xFFF5F5F5), 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( body: SafeArea(
bottom: false, bottom: false,
child: Stack( child: Stack(
children: [ children: [
pageView(
widget: StarLockMainPage(
showAppBar: false,
showDrawer: false,
),
logic: logic,
index: 0,
),
pageView( pageView(
widget: LockMallPage( widget: LockMallPage(
showAppBar: false, showAppBar: false,
), ),
logic: logic, logic: logic,
index: 0, index: 1,
), ),
pageView( pageView(
widget: MessageListPage( widget: MessageListPage(
showAppBar: false, showAppBar: false,
), ),
logic: logic, logic: logic,
index: 1, index: 2,
), ),
pageView( pageView(
widget: MinePersonInfoPage( widget: MinePersonInfoPage(
@ -77,7 +73,7 @@ class _StarLockMainXHJPageState extends State<StarLockMainXHJPage>
showAbout: true, showAbout: true,
), ),
logic: logic, logic: logic,
index: 2, index: 3,
), ),
], ],
), ),
@ -97,18 +93,25 @@ class _StarLockMainXHJPageState extends State<StarLockMainXHJPage>
top: false, top: false,
child: Row( child: Row(
children: [ children: [
navigationBarItem(Icons.shopping_cart, '商城'.tr, logic, 0, navigationBarItem(
() { Icons.key,
TranslationLoader.lanKeys!.device!.tr,
logic,
0, () {
logic.setIndex(0); logic.setIndex(0);
}), }),
navigationBarItem(Icons.message, navigationBarItem(Icons.shopping_cart, '商城'.tr, logic, 1,
TranslationLoader.lanKeys!.message!.tr, logic, 1, () { () {
logic.setIndex(1); logic.setIndex(1);
}), }),
navigationBarItem(Icons.account_circle, '我的'.tr, logic, 2, navigationBarItem(Icons.message,
() { TranslationLoader.lanKeys!.message!.tr, logic, 2, () {
logic.setIndex(2); logic.setIndex(2);
}), }),
navigationBarItem(Icons.account_circle, '我的'.tr, logic, 3,
() {
logic.setIndex(3);
}),
], ],
), ),
), ),