156 lines
5.2 KiB
Dart
Executable File
156 lines
5.2 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/mine/mineSet/lockGroup/groupEditLock/groupEditLock_state.dart';
|
|
import 'package:star_lock/tools/noData.dart';
|
|
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
|
|
|
import '../../../../../../app_settings/app_colors.dart';
|
|
import '../../../../../../tools/titleAppBar.dart';
|
|
import '../../../../tools/submitBtn.dart';
|
|
import 'groupEditLock_logic.dart';
|
|
|
|
class GroupEditLockPage extends StatefulWidget {
|
|
const GroupEditLockPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<GroupEditLockPage> createState() => _GroupEditLockPageState();
|
|
}
|
|
|
|
class _GroupEditLockPageState extends State<GroupEditLockPage> {
|
|
final GroupEditLockLogic logic = Get.put(GroupEditLockLogic());
|
|
final GroupEditLockState state = Get.find<GroupEditLockLogic>().state;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
logic.getVipStatus();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: state.type == 0 ? '添加'.tr : '删除'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: Column(
|
|
children: <Widget>[
|
|
Obx(() => Visibility(
|
|
visible: !state.isVip.value,
|
|
child: ShowCupertinoAlertView()
|
|
.topTipsAdvancedFeatures('开通高级功能后才可以对锁进行管理'.tr))),
|
|
Container(
|
|
margin: EdgeInsets.all(15.w),
|
|
child: Row(
|
|
children: <Widget>[
|
|
Text(state.type == 0 ? '选择要加入分组的锁'.tr : '选择要从分组中删除的锁'.tr,
|
|
style: TextStyle(fontSize: 25.sp)),
|
|
],
|
|
),
|
|
),
|
|
Expanded(child: _buildMainUI()),
|
|
Obx(() => Visibility(
|
|
visible: state.isVip.value,
|
|
child: SubmitBtn(
|
|
btnName: '确定'.tr,
|
|
onClick: () async {
|
|
final List idList = [];
|
|
for (int i = 0; i < state.lockList.length; i++) {
|
|
final LockListItem lockListItem = state.lockList[i];
|
|
if (lockListItem.isChecked == true) {
|
|
idList.add(lockListItem.lockId);
|
|
}
|
|
}
|
|
if (state.type == 0) {
|
|
// 添加
|
|
logic.lockGroupAddLock(idList);
|
|
} else if (state.type == 1) {
|
|
// 删除
|
|
logic.lockGroupDeletLock(idList);
|
|
}
|
|
}))),
|
|
SizedBox(height: 20.h)
|
|
],
|
|
));
|
|
}
|
|
|
|
Widget _buildMainUI() {
|
|
return state.lockList.isNotEmpty
|
|
? ListView.separated(
|
|
itemBuilder: (BuildContext context, int index) {
|
|
final LockListItem itemData = state.lockList[index];
|
|
return _listItemView(itemData);
|
|
},
|
|
itemCount: state.lockList.length,
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return Divider(
|
|
height: 1.h,
|
|
color: AppColors.greyLineColor,
|
|
);
|
|
},
|
|
)
|
|
: NoData();
|
|
}
|
|
|
|
Widget _listItemView(LockListItem itemData) {
|
|
return GestureDetector(
|
|
onTap: () {
|
|
if (!state.isVip.value) {
|
|
return;
|
|
}
|
|
setState(() {
|
|
itemData.isChecked = !itemData.isChecked;
|
|
});
|
|
},
|
|
child: Container(
|
|
color: Colors.white,
|
|
height: 80.h,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: <Widget>[
|
|
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: SizedBox(
|
|
width: 1.sw - 80.w - 75.w,
|
|
child: Text(
|
|
itemData.lockAlias ?? '',
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(fontSize: 24.sp),
|
|
))),
|
|
// Text(
|
|
// itemData.lockAlias ?? '',
|
|
// style: TextStyle(fontSize: 24.sp),
|
|
// ),
|
|
SizedBox(width: 10.w),
|
|
Image.asset(
|
|
itemData.isChecked
|
|
? 'images/icon_round_select.png'
|
|
: 'images/icon_round_unSelect.png',
|
|
width: 35.w,
|
|
height: 35.w,
|
|
),
|
|
SizedBox(width: 30.w)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|