2023-11-13 11:28:42 +08:00
|
|
|
|
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';
|
2024-06-05 14:36:31 +08:00
|
|
|
|
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_state.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/commonItem.dart';
|
|
|
|
|
|
import '../../../../../../tools/titleAppBar.dart';
|
|
|
|
|
|
import '../../../../../../translations/trans_lib.dart';
|
|
|
|
|
|
import '../../../../tools/left_slide_actions.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(
|
|
|
|
|
|
barTitle: TranslationLoader.lanKeys!.lockGroup!.tr,
|
|
|
|
|
|
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,
|
|
|
|
|
|
TranslationLoader.lanKeys!.createNewGroup!.tr,
|
|
|
|
|
|
TranslationLoader.lanKeys!.pleaseEnter!.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-05-06 14:51:18 +08:00
|
|
|
|
logic.showToast(
|
|
|
|
|
|
TranslationLoader.lanKeys!.pleaseEnterAGroupName!.tr);
|
2024-04-17 15:03:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
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(
|
|
|
|
|
|
child: Obx(() => state.itemDataList.value.isEmpty
|
|
|
|
|
|
? NoData()
|
|
|
|
|
|
: _buildMainUI())),
|
2023-11-13 11:28:42 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildMainUI() {
|
|
|
|
|
|
for (int i = 0; i < state.itemDataList.value.length; i++) {
|
2024-06-05 14:36:31 +08:00
|
|
|
|
final GroupListItem itemData = state.itemDataList.value[i];
|
2023-11-13 11:28:42 +08:00
|
|
|
|
state.lockNum += itemData.lockList!.length;
|
|
|
|
|
|
}
|
|
|
|
|
|
return ListView.separated(
|
|
|
|
|
|
itemCount: state.itemDataList.value.length + 1,
|
2024-06-05 14:36:31 +08:00
|
|
|
|
itemBuilder: (BuildContext c, int index) {
|
2023-11-13 11:28:42 +08:00
|
|
|
|
if (index == state.itemDataList.value.length) {
|
|
|
|
|
|
return Center(
|
|
|
|
|
|
child: Column(
|
2024-06-05 14:36:31 +08:00
|
|
|
|
children: <Widget>[
|
2023-11-13 11:28:42 +08:00
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 20.h,
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
height: 40.h,
|
|
|
|
|
|
child: Text(
|
2024-05-06 14:51:18 +08:00
|
|
|
|
'${TranslationLoader.lanKeys!.lockTrCount!.tr}:${state.lockNum.toString()}',
|
2023-11-13 11:28:42 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: AppColors.darkGrayTextColor, fontSize: 20.sp),
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
} else {
|
2024-06-05 14:36:31 +08:00
|
|
|
|
final GroupListItem itemData = state.itemDataList.value[index];
|
2024-05-06 14:51:18 +08:00
|
|
|
|
if (itemData.groupType == 0) {
|
2023-11-13 11:28:42 +08:00
|
|
|
|
state.ungrouped = itemData;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (index < state.itemDataList.value.length) {
|
|
|
|
|
|
return LeftSlideActions(
|
|
|
|
|
|
key: Key(itemData.keyGroupId!.toString()),
|
|
|
|
|
|
actionsWidth: itemData.groupType != 0 ? 200.w : 0,
|
2024-05-06 14:51:18 +08:00
|
|
|
|
actions: itemData.groupType != 0
|
2024-06-05 14:36:31 +08:00
|
|
|
|
? <Widget>[
|
2024-05-06 14:51:18 +08:00
|
|
|
|
_buildEditBtn(itemData),
|
|
|
|
|
|
_buildDeleteBtn(itemData),
|
|
|
|
|
|
]
|
2024-06-05 14:36:31 +08:00
|
|
|
|
: <Widget>[],
|
2023-11-13 11:28:42 +08:00
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(1)),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: CommonItem(
|
2024-06-05 14:36:31 +08:00
|
|
|
|
leftTitel: '${itemData.keyGroupName}(${itemData.lockList?.length})',
|
|
|
|
|
|
rightTitle: '',
|
2023-11-13 11:28:42 +08:00
|
|
|
|
allHeight: 70.h,
|
|
|
|
|
|
action: () {
|
2024-06-05 14:36:31 +08:00
|
|
|
|
Get.toNamed(Routers.lockItemListPage, arguments: <String, GroupListItem>{
|
2024-05-06 14:51:18 +08:00
|
|
|
|
'groupListItem': itemData,
|
2024-06-05 14:36:31 +08:00
|
|
|
|
'ungrouped': state.ungrouped
|
2024-05-06 14:51:18 +08:00
|
|
|
|
});
|
2023-11-13 11:28:42 +08:00
|
|
|
|
}),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
return const SizedBox.shrink();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
|
|
|
|
return const Divider(
|
|
|
|
|
|
height: 1,
|
|
|
|
|
|
color: AppColors.greyLineColor,
|
|
|
|
|
|
);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
|
width: 100.w,
|
|
|
|
|
|
color: const Color(0xFFF20101),
|
|
|
|
|
|
alignment: Alignment.center,
|
2023-11-28 13:47:49 +08:00
|
|
|
|
child: Text(
|
|
|
|
|
|
TranslationLoader.lanKeys!.delete!.tr,
|
|
|
|
|
|
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-05-06 14:51:18 +08:00
|
|
|
|
ShowTipView().showTFViewAlertDialog(
|
|
|
|
|
|
state.changeNameController,
|
2024-06-05 14:36:31 +08:00
|
|
|
|
'修改名称'.tr,
|
2024-05-06 14:51:18 +08:00
|
|
|
|
TranslationLoader.lanKeys!.pleaseEnter!.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!);
|
|
|
|
|
|
} else {
|
2024-05-06 14:51:18 +08:00
|
|
|
|
logic.showToast(
|
|
|
|
|
|
TranslationLoader.lanKeys!.pleaseEnterAGroupName!.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(
|
|
|
|
|
|
width: 100.w,
|
|
|
|
|
|
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,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|