118 lines
3.8 KiB
Dart
118 lines
3.8 KiB
Dart
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 '../../../../../../app_settings/app_colors.dart';
|
|
import '../../../../../../tools/titleAppBar.dart';
|
|
import '../../../../../../translations/trans_lib.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 logic = Get.put(GroupEditLockLogic());
|
|
final state = Get.find<GroupEditLockLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: state.type == 0 ? TranslationLoader.lanKeys!.add!.tr : TranslationLoader.lanKeys!.delete!.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: Column(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.all(15.w),
|
|
child: Row(
|
|
children: [
|
|
Text(TranslationLoader.lanKeys!.selectTheLockToJoinTheGroup!.tr, style: TextStyle(fontSize: 25.sp)),
|
|
],
|
|
),
|
|
),
|
|
Expanded(child: _buildMainUI()),
|
|
SubmitBtn(btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () async {
|
|
var idList = [];
|
|
for(int i = 0; i<state.lockList.length; i++){
|
|
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: (context, index) {
|
|
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 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: 36, height: 36, fit: BoxFit.fill,),
|
|
SizedBox(width: 10.w,),
|
|
Text(
|
|
itemData.lockAlias ?? '',
|
|
style: TextStyle(fontSize: 24.sp),
|
|
),
|
|
Expanded(child: SizedBox(width: 10.w)),
|
|
GestureDetector(
|
|
child: Image.asset(
|
|
itemData.isChecked
|
|
? 'images/icon_round_select.png'
|
|
: 'images/icon_round_unSelect.png',
|
|
width: 35.w,
|
|
height: 35.w,
|
|
),
|
|
onTap: (){
|
|
setState(() {
|
|
itemData.isChecked = !itemData.isChecked;
|
|
});
|
|
},
|
|
),
|
|
SizedBox(width: 30.w)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
}
|