2023-07-10 17:50:31 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2024-06-13 09:12:39 +08:00
|
|
|
import 'package:flutter/services.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
import 'package:get/get.dart';
|
2023-09-12 18:38:11 +08:00
|
|
|
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
2024-06-13 09:12:39 +08:00
|
|
|
import 'package:star_lock/main/lockDetail/lockSet/basicInformation/lockSelectGrouping/lockSelectGrouping_state.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
import '../../../../../app_settings/app_colors.dart';
|
|
|
|
|
import '../../../../../tools/commonItem.dart';
|
2023-11-01 17:28:59 +08:00
|
|
|
import '../../../../../tools/noData.dart';
|
2024-04-16 17:44:38 +08:00
|
|
|
import '../../../../../tools/showTipView.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
import '../../../../../tools/submitBtn.dart';
|
|
|
|
|
import '../../../../../tools/titleAppBar.dart';
|
2024-01-23 17:29:18 +08:00
|
|
|
import 'lockSelectGrouping_logic.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
|
2024-01-23 17:29:18 +08:00
|
|
|
class LockSelectGroupingPage extends StatefulWidget {
|
|
|
|
|
const LockSelectGroupingPage({Key? key}) : super(key: key);
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
@override
|
2024-01-23 17:29:18 +08:00
|
|
|
State<LockSelectGroupingPage> createState() => _LockSelectGroupingPageState();
|
2023-07-10 17:50:31 +08:00
|
|
|
}
|
|
|
|
|
|
2024-01-23 17:29:18 +08:00
|
|
|
class _LockSelectGroupingPageState extends State<LockSelectGroupingPage> {
|
2024-06-13 09:12:39 +08:00
|
|
|
final LockSelectGroupingLogic logic = Get.put(LockSelectGroupingLogic());
|
2024-11-26 17:46:54 +08:00
|
|
|
final LockSelectGroupingState state =
|
|
|
|
|
Get.find<LockSelectGroupingLogic>().state;
|
2023-08-28 17:35:30 +08:00
|
|
|
|
2023-07-10 17:50:31 +08:00
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
2023-07-28 15:37:33 +08:00
|
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
|
|
|
appBar: TitleAppBar(
|
2024-07-31 17:24:30 +08:00
|
|
|
barTitle: '选择分组'.tr,
|
2023-07-28 15:37:33 +08:00
|
|
|
haveBack: true,
|
|
|
|
|
backgroundColor: AppColors.mainColor),
|
2023-11-01 17:28:59 +08:00
|
|
|
body: Column(
|
2024-06-13 09:12:39 +08:00
|
|
|
children: <Widget>[
|
2023-11-01 17:28:59 +08:00
|
|
|
Expanded(child: _buildMainUI()),
|
|
|
|
|
SubmitBtn(
|
2024-07-31 17:24:30 +08:00
|
|
|
btnName: '创建新分组'.tr,
|
2023-11-01 17:28:59 +08:00
|
|
|
borderRadius: 20.w,
|
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
|
left: 30.w, right: 30.w, top: 30.w, bottom: 30.w),
|
|
|
|
|
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
|
|
|
|
onClick: () {
|
2024-04-16 17:44:38 +08:00
|
|
|
// showCupertinoAlertDialog(context);
|
2024-09-27 10:15:24 +08:00
|
|
|
ShowTipView().showTFViewAlertDialog(
|
2024-11-26 17:46:54 +08:00
|
|
|
state.changeNameController, '创建新分组'.tr, '请输入分组名称'.tr, () {
|
2024-04-16 17:44:38 +08:00
|
|
|
logic.addLockGroupRequest();
|
|
|
|
|
Get.back();
|
2024-11-26 17:46:54 +08:00
|
|
|
},
|
|
|
|
|
isShowSuffixIcon: true,
|
|
|
|
|
inputFormatters: <TextInputFormatter>[
|
|
|
|
|
LengthLimitingTextInputFormatter(50),
|
|
|
|
|
]);
|
2023-11-01 17:28:59 +08:00
|
|
|
}),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 40.h,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
2023-07-10 17:50:31 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-01 17:28:59 +08:00
|
|
|
Widget _buildMainUI() {
|
2024-11-26 17:46:54 +08:00
|
|
|
return Obx(() => state.groupList.value.isNotEmpty
|
|
|
|
|
? ListView.builder(
|
|
|
|
|
itemCount: state.groupList.value.length,
|
|
|
|
|
itemBuilder: (BuildContext c, int index) {
|
|
|
|
|
final GroupListItem itemData = state.groupList.value[index];
|
|
|
|
|
return lockDataListItem(itemData.keyGroupName ?? '',
|
|
|
|
|
state.lockBasicInfo.value.groupId == itemData.keyGroupId, () {
|
|
|
|
|
logic
|
|
|
|
|
.setLockGroupRequest(itemData)
|
|
|
|
|
.then((value) => setState(() {}));
|
2023-07-28 15:37:33 +08:00
|
|
|
});
|
2024-11-26 17:46:54 +08:00
|
|
|
})
|
|
|
|
|
: NoData());
|
2023-08-28 17:35:30 +08:00
|
|
|
}
|
|
|
|
|
|
2024-11-26 17:46:54 +08:00
|
|
|
Widget lockDataListItem(
|
|
|
|
|
String title, bool isShowSeletIcon, Function()? action) {
|
2024-06-13 09:12:39 +08:00
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: action,
|
|
|
|
|
child: Container(
|
|
|
|
|
// height: 70.h,
|
2024-11-26 17:46:54 +08:00
|
|
|
padding:
|
|
|
|
|
EdgeInsets.only(left: 20.w, right: 20.w, top: 15.h, bottom: 15.h),
|
2024-06-13 09:12:39 +08:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
border: Border(
|
|
|
|
|
bottom: BorderSide(
|
|
|
|
|
color: AppColors.greyLineColor, // 设置边框颜色
|
|
|
|
|
width: 2.0.h, // 设置边框宽度
|
|
|
|
|
),
|
2024-11-26 17:46:54 +08:00
|
|
|
)),
|
2024-06-13 09:12:39 +08:00
|
|
|
child: Row(
|
|
|
|
|
children: <Widget>[
|
2024-11-26 17:46:54 +08:00
|
|
|
Expanded(child: Text(title, style: TextStyle(fontSize: 22.sp))),
|
2024-06-13 09:12:39 +08:00
|
|
|
SizedBox(width: 15.w),
|
2024-11-26 17:46:54 +08:00
|
|
|
if (isShowSeletIcon)
|
|
|
|
|
Image(
|
|
|
|
|
image: const AssetImage('images/icon_item_checked.png'),
|
|
|
|
|
width: 30.w,
|
|
|
|
|
height: 30.w,
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
)
|
|
|
|
|
else
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 30.w,
|
|
|
|
|
height: 30.w,
|
|
|
|
|
),
|
2024-06-13 09:12:39 +08:00
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
}
|