2024-08-21 14:12:15 +08:00
|
|
|
|
|
2023-11-13 11:28:42 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
2024-06-13 09:12:39 +08:00
|
|
|
|
import 'package:flutter/services.dart';
|
2023-11-13 11:28:42 +08:00
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
2024-10-19 09:38:57 +08:00
|
|
|
|
import 'package:flutter_slidable/flutter_slidable.dart';
|
2023-11-13 11:28:42 +08:00
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
2024-06-05 14:36:31 +08:00
|
|
|
|
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_state.dart';
|
2024-06-24 16:37:33 +08:00
|
|
|
|
import 'package:star_lock/tools/left_slide/left_slide_logic.dart';
|
2024-04-17 15:03:11 +08:00
|
|
|
|
import 'package:star_lock/tools/showTipView.dart';
|
2023-11-13 11:28:42 +08:00
|
|
|
|
|
|
|
|
|
|
import '../../../../../../appRouters.dart';
|
|
|
|
|
|
import '../../../../../../app_settings/app_colors.dart';
|
|
|
|
|
|
import '../../../../../../tools/titleAppBar.dart';
|
|
|
|
|
|
import '../../../../tools/noData.dart';
|
|
|
|
|
|
import 'lockGroupList_logic.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class LockGroupListPage extends StatefulWidget {
|
|
|
|
|
|
const LockGroupListPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<LockGroupListPage> createState() => _LockGroupListPageState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _LockGroupListPageState extends State<LockGroupListPage> {
|
2024-06-05 14:36:31 +08:00
|
|
|
|
final LockGroupListLogic logic = Get.put(LockGroupListLogic());
|
|
|
|
|
|
final LockGroupListState state = Get.find<LockGroupListLogic>().state;
|
2023-11-13 11:28:42 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
|
|
|
|
appBar: TitleAppBar(
|
2024-08-01 18:54:32 +08:00
|
|
|
|
barTitle: '锁分组'.tr,
|
2023-11-13 11:28:42 +08:00
|
|
|
|
haveBack: true,
|
2024-06-05 14:36:31 +08:00
|
|
|
|
actionsList: <Widget>[
|
2023-11-13 11:28:42 +08:00
|
|
|
|
IconButton(
|
|
|
|
|
|
icon: Image.asset(
|
|
|
|
|
|
'images/icon_add_white.png',
|
|
|
|
|
|
width: 36.w,
|
|
|
|
|
|
height: 36.w,
|
|
|
|
|
|
),
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
// 处理操作按钮的点击事件-添加锁分组
|
2024-06-05 14:36:31 +08:00
|
|
|
|
state.changeNameController.text = '';
|
2024-04-17 15:03:11 +08:00
|
|
|
|
// showCupertinoAlertDialog(context, true, 0);
|
2024-05-06 14:51:18 +08:00
|
|
|
|
ShowTipView().showTFViewAlertDialog(
|
|
|
|
|
|
state.changeNameController,
|
2024-07-31 17:24:30 +08:00
|
|
|
|
'创建新分组'.tr,
|
2024-10-19 09:38:57 +08:00
|
|
|
|
'请输入姓名'.tr, () {
|
2024-04-17 15:03:11 +08:00
|
|
|
|
//发送编辑钥匙名称请求
|
|
|
|
|
|
if (state.changeNameController.text.isNotEmpty) {
|
2024-05-06 14:51:18 +08:00
|
|
|
|
Navigator.of(context).pop();
|
2024-04-17 15:03:11 +08:00
|
|
|
|
logic.addLockGroupRequest();
|
|
|
|
|
|
} else {
|
2024-08-02 13:52:37 +08:00
|
|
|
|
logic.showToast('请输入分组名称'.tr);
|
2024-04-17 15:03:11 +08:00
|
|
|
|
}
|
2024-06-24 16:37:33 +08:00
|
|
|
|
},
|
|
|
|
|
|
isShowSuffixIcon: true,
|
|
|
|
|
|
inputFormatters: <TextInputFormatter>[
|
|
|
|
|
|
LengthLimitingTextInputFormatter(50),
|
|
|
|
|
|
]);
|
2023-11-13 11:28:42 +08:00
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
backgroundColor: AppColors.mainColor),
|
|
|
|
|
|
body: Column(
|
2024-06-05 14:36:31 +08:00
|
|
|
|
children: <Widget>[
|
2024-05-06 14:51:18 +08:00
|
|
|
|
Expanded(
|
2024-06-24 16:37:33 +08:00
|
|
|
|
child: Obx(() =>
|
|
|
|
|
|
state.itemDataList.isEmpty ? NoData() : _buildMainUI())),
|
2023-11-13 11:28:42 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildMainUI() {
|
2024-06-24 16:37:33 +08:00
|
|
|
|
for (int i = 0; i < state.itemDataList.length; i++) {
|
|
|
|
|
|
final GroupListItem itemData = state.itemDataList[i];
|
2023-11-13 11:28:42 +08:00
|
|
|
|
state.lockNum += itemData.lockList!.length;
|
|
|
|
|
|
}
|
2024-10-19 09:38:57 +08:00
|
|
|
|
return SlidableAutoCloseBehavior(
|
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
|
itemCount: state.itemDataList.length + 1,
|
|
|
|
|
|
itemBuilder: (BuildContext c, int index) {
|
|
|
|
|
|
if (index == state.itemDataList.length) {
|
|
|
|
|
|
return Center(
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 20.h,
|
2023-11-13 11:28:42 +08:00
|
|
|
|
),
|
2024-10-19 09:38:57 +08:00
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 40.h,
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
'${'锁数量'.tr}:${state.lockNum.toString()}',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: AppColors.darkGrayTextColor, fontSize: 20.sp),
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
],
|
2023-11-13 11:28:42 +08:00
|
|
|
|
),
|
|
|
|
|
|
);
|
2024-10-19 09:38:57 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
final GroupListItem itemData = state.itemDataList[index];
|
|
|
|
|
|
if (itemData.groupType == 0) {
|
|
|
|
|
|
state.ungrouped = itemData;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (index < state.itemDataList.length) {
|
|
|
|
|
|
return Slidable(
|
|
|
|
|
|
key: ValueKey(itemData.keyGroupId),
|
|
|
|
|
|
endActionPane: ActionPane(
|
|
|
|
|
|
extentRatio: 0.4,
|
|
|
|
|
|
motion: const ScrollMotion(),
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_buildEditBtn(itemData),
|
|
|
|
|
|
_buildDeleteBtn(itemData),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
child: lockDataListItem(
|
|
|
|
|
|
'${itemData.keyGroupName}(${itemData.lockList?.length})',
|
|
|
|
|
|
() {
|
|
|
|
|
|
Get.toNamed(Routers.lockItemListPage,
|
|
|
|
|
|
arguments: <String, GroupListItem>{
|
|
|
|
|
|
'groupListItem': itemData,
|
|
|
|
|
|
'ungrouped': state.ungrouped
|
|
|
|
|
|
});
|
|
|
|
|
|
}),
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// return LeftSlideActions(
|
|
|
|
|
|
// tag: itemData.keyGroupId!.toString(),
|
|
|
|
|
|
// key: Key(itemData.keyGroupId!.toString()),
|
|
|
|
|
|
// actionsWidth: itemData.groupType != 0 ? 200.w : 0,
|
|
|
|
|
|
// actions: itemData.groupType != 0
|
|
|
|
|
|
// ? <Widget>[
|
|
|
|
|
|
// _buildEditBtn(itemData),
|
|
|
|
|
|
// _buildDeleteBtn(itemData),
|
|
|
|
|
|
// ]
|
|
|
|
|
|
// : <Widget>[],
|
|
|
|
|
|
// decoration: const BoxDecoration(
|
|
|
|
|
|
// borderRadius: BorderRadius.all(Radius.circular(1)),
|
|
|
|
|
|
// ),
|
|
|
|
|
|
// child: lockDataListItem(
|
|
|
|
|
|
// '${itemData.keyGroupName}(${itemData.lockList?.length})',
|
|
|
|
|
|
// () {
|
|
|
|
|
|
// Get.toNamed(Routers.lockItemListPage,
|
|
|
|
|
|
// arguments: <String, GroupListItem>{
|
|
|
|
|
|
// 'groupListItem': itemData,
|
|
|
|
|
|
// 'ungrouped': state.ungrouped
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }),
|
|
|
|
|
|
// );
|
|
|
|
|
|
}
|
|
|
|
|
|
return const SizedBox.shrink();
|
2023-11-13 11:28:42 +08:00
|
|
|
|
}
|
2024-10-19 09:38:57 +08:00
|
|
|
|
},
|
|
|
|
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
|
|
|
|
return const Divider(
|
|
|
|
|
|
height: 1,
|
|
|
|
|
|
color: AppColors.greyLineColor,
|
|
|
|
|
|
);
|
|
|
|
|
|
}),
|
|
|
|
|
|
);
|
2023-11-13 11:28:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildDeleteBtn(GroupListItem groupListItem) {
|
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
// 省略: 弹出是否删除的确认对话框。
|
2024-04-17 15:03:11 +08:00
|
|
|
|
// showIosTipViewDialog(context, groupListItem);
|
2024-06-05 14:36:31 +08:00
|
|
|
|
ShowTipView().showIosTipWithContentDialog('分组下的锁将被移到未分组里'.tr, () {
|
2024-04-17 15:03:11 +08:00
|
|
|
|
logic.deleteLockGroupRequest(groupListItem.keyGroupId!);
|
|
|
|
|
|
});
|
2023-11-13 11:28:42 +08:00
|
|
|
|
},
|
|
|
|
|
|
child: Container(
|
2024-10-19 09:38:57 +08:00
|
|
|
|
width: 1.sw*0.2,
|
2023-11-13 11:28:42 +08:00
|
|
|
|
color: const Color(0xFFF20101),
|
|
|
|
|
|
alignment: Alignment.center,
|
2023-11-28 13:47:49 +08:00
|
|
|
|
child: Text(
|
2024-07-26 09:21:22 +08:00
|
|
|
|
'删除'.tr,
|
2023-11-28 13:47:49 +08:00
|
|
|
|
style: const TextStyle(
|
2023-11-13 11:28:42 +08:00
|
|
|
|
fontSize: 16,
|
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
height: 1,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildEditBtn(GroupListItem groupListItem) {
|
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
// 编辑
|
|
|
|
|
|
state.changeNameController.text = groupListItem.keyGroupName!;
|
2024-04-17 15:03:11 +08:00
|
|
|
|
// showCupertinoAlertDialog(context, false, groupListItem.keyGroupId!);
|
|
|
|
|
|
|
2024-06-24 16:37:33 +08:00
|
|
|
|
ShowTipView().showTFViewAlertDialog(state.changeNameController,
|
2024-10-19 09:38:57 +08:00
|
|
|
|
'修改名称'.tr, '请输入姓名'.tr, () {
|
2024-04-17 15:03:11 +08:00
|
|
|
|
if (state.changeNameController.text.isNotEmpty) {
|
2024-06-05 14:36:31 +08:00
|
|
|
|
Get.back();
|
2024-04-17 15:03:11 +08:00
|
|
|
|
logic.editLockGroupRequest(groupListItem.keyGroupId!);
|
2024-06-24 16:37:33 +08:00
|
|
|
|
final String keyGroupId = groupListItem.keyGroupId!.toString();
|
|
|
|
|
|
if (Get.isRegistered<LeftSlideLogic>(tag: keyGroupId)) {
|
|
|
|
|
|
Get.find<LeftSlideLogic>(tag: keyGroupId).hide();
|
|
|
|
|
|
}
|
2024-04-17 15:03:11 +08:00
|
|
|
|
} else {
|
2024-08-02 13:52:37 +08:00
|
|
|
|
logic.showToast('请输入分组名称'.tr);
|
2024-04-17 15:03:11 +08:00
|
|
|
|
}
|
2024-06-07 10:53:24 +08:00
|
|
|
|
}, isShowSuffixIcon: true);
|
2023-11-13 11:28:42 +08:00
|
|
|
|
},
|
|
|
|
|
|
child: Container(
|
2024-10-19 09:38:57 +08:00
|
|
|
|
width: 1.sw*0.2,
|
2023-11-13 11:28:42 +08:00
|
|
|
|
color: AppColors.mainColor,
|
|
|
|
|
|
alignment: Alignment.center,
|
2023-11-28 13:47:49 +08:00
|
|
|
|
child: Text(
|
2024-06-05 14:36:31 +08:00
|
|
|
|
'重命名'.tr,
|
2023-11-28 13:47:49 +08:00
|
|
|
|
style: const TextStyle(
|
2023-11-13 11:28:42 +08:00
|
|
|
|
fontSize: 16,
|
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
height: 1,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2024-06-13 09:12:39 +08:00
|
|
|
|
|
2024-06-24 16:37:33 +08:00
|
|
|
|
Widget lockDataListItem(String title, Function()? action) {
|
2024-06-13 09:12:39 +08:00
|
|
|
|
return GestureDetector(
|
|
|
|
|
|
onTap: action,
|
|
|
|
|
|
child: Container(
|
2024-10-19 09:38:57 +08:00
|
|
|
|
height: 70.h,
|
2024-06-24 16:37:33 +08:00
|
|
|
|
padding:
|
|
|
|
|
|
EdgeInsets.only(left: 20.w, right: 10.w, top: 15.h, bottom: 15.h),
|
2024-06-13 09:12:39 +08:00
|
|
|
|
decoration: BoxDecoration(
|
2024-06-24 16:37:33 +08:00
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
border: Border(
|
|
|
|
|
|
bottom: BorderSide(
|
|
|
|
|
|
color: AppColors.greyLineColor, // 设置边框颜色
|
|
|
|
|
|
width: 2.0.h, // 设置边框宽度
|
|
|
|
|
|
),
|
|
|
|
|
|
)),
|
2024-06-13 09:12:39 +08:00
|
|
|
|
child: Row(
|
|
|
|
|
|
children: <Widget>[
|
2024-06-24 16:37:33 +08:00
|
|
|
|
Expanded(child: Text(title, style: TextStyle(fontSize: 22.sp))),
|
2024-06-13 09:12:39 +08:00
|
|
|
|
// Text(title, style: TextStyle(fontSize: 22.sp)),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2023-11-13 11:28:42 +08:00
|
|
|
|
}
|