155 lines
5.6 KiB
Dart
Executable File
155 lines
5.6 KiB
Dart
Executable File
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
|
import 'package:star_lock/tools/noData.dart';
|
|
import 'package:star_lock/tools/submitBtn.dart';
|
|
|
|
import '../../../../../../app_settings/app_colors.dart';
|
|
import '../../../../../../tools/titleAppBar.dart';
|
|
import '../../../../appRouters.dart';
|
|
import '../../../../tools/custom_bottom_sheet.dart';
|
|
|
|
class LockItemListPage extends StatefulWidget {
|
|
const LockItemListPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<LockItemListPage> createState() => _LockItemListPageState();
|
|
}
|
|
|
|
class _LockItemListPageState extends State<LockItemListPage> {
|
|
List<LockListItem> lockList = [];
|
|
var ungrouped = GroupListItem();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final Map map = Get.arguments;
|
|
final GroupListItem groupListItem = map['groupListItem'];
|
|
lockList = groupListItem.lockList!;
|
|
ungrouped = map['ungrouped'];
|
|
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: groupListItem.keyGroupName ?? '',
|
|
haveBack: true,
|
|
actionsList: (lockList.isNotEmpty && groupListItem.groupType != 0) ? [
|
|
IconButton(
|
|
icon: Image.asset(
|
|
'images/icon_bar_more.png',
|
|
height: 30.h,
|
|
width: 10.w,
|
|
),
|
|
onPressed: () {
|
|
// 处理操作按钮的点击事件
|
|
_openModalBottomSheet(groupListItem);
|
|
// JhPopMenus.showLinePop(context, clickCallback: (index, selText) {
|
|
// if (index == 0) {
|
|
// Get.back();
|
|
// // Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
|
|
// Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
|
|
// } else if (index == 1) {
|
|
// Get.back();
|
|
// Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 1});
|
|
// }
|
|
// }, listData: [
|
|
// {'text': '添加'},
|
|
// {'text': '删除'},
|
|
// ]);
|
|
},
|
|
),
|
|
] :[],
|
|
backgroundColor: AppColors.mainColor),
|
|
body: lockList.isNotEmpty
|
|
? ListView.separated(
|
|
itemBuilder: (context, index) {
|
|
final LockListItem itemData = lockList[index];
|
|
return _listItemView(itemData);
|
|
},
|
|
itemCount: lockList.length,
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return Divider(
|
|
height: 1.h,
|
|
color: AppColors.greyLineColor,
|
|
);
|
|
},
|
|
)
|
|
: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
NoData(),
|
|
Positioned(
|
|
bottom: 350.h,
|
|
left: (ScreenUtil().screenWidth - 200.w) / 2,
|
|
width: 200.w,
|
|
child: SubmitBtn(
|
|
btnName: '添加'.tr,
|
|
onClick: () {
|
|
//选择要添加到分组的锁
|
|
Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
|
|
},
|
|
)),
|
|
],
|
|
));
|
|
}
|
|
|
|
Widget _listItemView(LockListItem itemData) {
|
|
return GestureDetector(
|
|
child: Container(
|
|
color: Colors.white,
|
|
height: 80.h,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
SizedBox(
|
|
width: 20.w,
|
|
),
|
|
Image.asset(
|
|
'images/icon_lockGroup_item.png',
|
|
width: 50.w,
|
|
height: 50.w,
|
|
fit: BoxFit.fill,
|
|
),
|
|
SizedBox(
|
|
width: 10.w,
|
|
),
|
|
Expanded(child:
|
|
Text(itemData.lockAlias ?? '',
|
|
style: TextStyle(fontSize: 24.sp),
|
|
)
|
|
),
|
|
// Text(
|
|
// itemData.lockAlias ?? '',
|
|
// style: TextStyle(fontSize: 24.sp),
|
|
// )
|
|
],
|
|
),
|
|
),
|
|
onTap: () {},
|
|
);
|
|
}
|
|
|
|
Future _openModalBottomSheet(GroupListItem groupListItem) async {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadiusDirectional.circular(10)),
|
|
builder: (BuildContext context) {
|
|
return AlertBottomWidget(
|
|
topTitle: '',
|
|
items: ['添加'.tr, '删除'.tr],
|
|
chooseCallback: (value) {
|
|
final int getSelectIndex = value;
|
|
if (getSelectIndex == 0) {
|
|
Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
|
|
} else if (getSelectIndex == 1) {
|
|
Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 1});
|
|
}
|
|
},
|
|
);
|
|
});
|
|
}
|
|
}
|