109 lines
4.0 KiB
Dart
Executable File
109 lines
4.0 KiB
Dart
Executable File
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.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/main/lockDetail/lockSet/basicInformation/lockSelectGrouping/lockSelectGrouping_state.dart';
|
|
|
|
import '../../../../../app_settings/app_colors.dart';
|
|
import '../../../../../tools/commonItem.dart';
|
|
import '../../../../../tools/noData.dart';
|
|
import '../../../../../tools/showTipView.dart';
|
|
import '../../../../../tools/submitBtn.dart';
|
|
import '../../../../../tools/titleAppBar.dart';
|
|
import '../../../../../translations/trans_lib.dart';
|
|
import 'lockSelectGrouping_logic.dart';
|
|
|
|
class LockSelectGroupingPage extends StatefulWidget {
|
|
const LockSelectGroupingPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<LockSelectGroupingPage> createState() => _LockSelectGroupingPageState();
|
|
}
|
|
|
|
class _LockSelectGroupingPageState extends State<LockSelectGroupingPage> {
|
|
final LockSelectGroupingLogic logic = Get.put(LockSelectGroupingLogic());
|
|
final LockSelectGroupingState state = Get.find<LockSelectGroupingLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: TranslationLoader.lanKeys!.selectGroup!.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: Column(
|
|
children: <Widget>[
|
|
Expanded(child: _buildMainUI()),
|
|
SubmitBtn(
|
|
btnName: TranslationLoader.lanKeys!.createNewGroup!.tr,
|
|
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: () {
|
|
// showCupertinoAlertDialog(context);
|
|
ShowTipView().showTFViewAlertDialog(state.changeNameController, TranslationLoader.lanKeys!.createNewGroup!.tr, '请输入分组名称'.tr, (){
|
|
logic.addLockGroupRequest();
|
|
Get.back();
|
|
}, isShowSuffixIcon:true, inputFormatters: <TextInputFormatter>[
|
|
LengthLimitingTextInputFormatter(50),
|
|
]);
|
|
}),
|
|
SizedBox(
|
|
height: 40.h,
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildMainUI() {
|
|
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(() {}));
|
|
});
|
|
}) : NoData());
|
|
}
|
|
|
|
Widget lockDataListItem(String title, bool isShowSeletIcon, Function()? action){
|
|
return GestureDetector(
|
|
onTap: action,
|
|
child: Container(
|
|
// height: 70.h,
|
|
padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 15.h, bottom: 15.h),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
border: Border(
|
|
bottom: BorderSide(
|
|
color: AppColors.greyLineColor, // 设置边框颜色
|
|
width: 2.0.h, // 设置边框宽度
|
|
),
|
|
)
|
|
),
|
|
child: Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: Text(title, style: TextStyle(fontSize: 22.sp))
|
|
),
|
|
SizedBox(width: 15.w),
|
|
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,),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|