import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart'; import 'package:star_lock/main/lockDetail/iris/irisList/irisList_logic.dart'; import 'package:star_lock/tools/keySearchWidget.dart'; import 'package:star_lock/tools/left_slide_actions.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/noData.dart'; import '../../../../tools/showIosTipView.dart'; import '../../../../tools/storage.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; class IrisListPage extends StatefulWidget { const IrisListPage({Key? key}) : super(key: key); @override State createState() => _IrisListPageState(); } class _IrisListPageState extends State { final logic = Get.put(IrisListLogic()); final state = Get.find().state; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: '虹膜'.tr, haveBack: true, backgroundColor: AppColors.mainColor, actionsList: [ TextButton( child: Text( TranslationLoader.lanKeys!.reset!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () async { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { showDeletAlertDialog(context); } else { // Get.toNamed(Routers.selectLockTypePage); logic.showToast("演示模式"); } }, ), ], ), body: Column( children: [ KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { // logic.getFaceListData(); }, ), SizedBox( height: 20.h, ), Expanded(child: _buildMainUI()), AddBottomWhiteBtn( btnName: '${TranslationLoader.lanKeys!.add!.tr}${'虹膜'.tr}', onClick: () async { // var data = // await Get.toNamed(Routers.addFaceTypeManagePage, arguments: { // "lockId": state.lockId.value, // "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 // }); var data = await Get.toNamed(Routers.addIrisTypeManagePage, arguments: { "lockId": state.lockId.value, "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 }); if (data != null) { // logic.getFaceListData(); } }, ), SizedBox(height: 64.h) ], ), ); } Widget _buildMainUI() { { return Obx(() => state.faceItemListData.value.isNotEmpty ? ListView.separated( itemCount: state.faceItemListData.value.length, itemBuilder: (c, index) { FingerprintItemData getFaceItemData = state.faceItemListData.value[index]; // 人脸 if (index < state.faceItemListData.value.length) { return LeftSlideActions( key: Key(getFaceItemData.faceName!), actionsWidth: 60, actions: [ _buildDeleteBtn(getFaceItemData), ], decoration: const BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(1)), ), child: _keyItem( 'images/icon_face.png', getFaceItemData.faceName!, (getFaceItemData.faceType! != 1) ? (getFaceItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "", getFaceItemData.validTimeStr!, // fingerprintItemData.fingerprintType! == 1 // ? "永久" // : "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", () async { var data = await Get.toNamed(Routers.faceDetailPage, arguments: { "faceItemData": getFaceItemData, }); if (data != null) { // logic.getFaceListData(); } }), ); } return const SizedBox.shrink(); }, separatorBuilder: (BuildContext context, int index) { return const Divider( height: 1, color: AppColors.greyLineColor, ); }, ) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - 170.h)); } } Widget _buildDeleteBtn(FingerprintItemData faceItemData) { return GestureDetector( onTap: () { // 省略: 弹出是否删除的确认对话框。 state.deletKeyID = faceItemData.faceId.toString(); state.deletFaceNo = int.parse(faceItemData.faceNumber!); showIosTipViewDialog(context); }, child: Container( width: 60, color: const Color(0xFFF20101), alignment: Alignment.center, child: const Text( '删除', style: TextStyle( fontSize: 16, fontWeight: FontWeight.w500, color: Colors.white, height: 1, ), ), ), ); } void showIosTipViewDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { return ShowIosTipView( title: "提示", tipTitle: "确定要删除吗?", sureClick: () async { Get.back(); state.isDeletFaceData = true; state.isDeletAll = false; state.deletUserID = (await Storage.getUid())!; // logic.senderAddFace(); }, cancelClick: () { Get.back(); }, ); }, ); } Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String ifInvalidation, String showTime, Function() action) { return GestureDetector( onTap: action, child: Container( height: 90.h, // margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), color: Colors.white, // decoration: BoxDecoration( // color: Colors.white, // // borderRadius: BorderRadius.circular(10.w), // ), child: Row( children: [ SizedBox(width: 30.w), Image.asset(lockTypeIcon, width: 60.w, height: 60.w), SizedBox(width: 20.w), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(lockTypeTitle, style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor)), Expanded(child: Container()), Text(ifInvalidation, style: TextStyle(fontSize: 22.sp, color: Colors.red)), SizedBox(width: 10.w), ], ), SizedBox(height: 5.h), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Text(showTime, style: TextStyle( fontSize: 18.sp, color: AppColors.placeholderTextColor)), ], ), SizedBox(width: 20.h), ], ), ), SizedBox(width: 20.h), ], ), ), ); } void showDeletAlertDialog(BuildContext context) { showCupertinoDialog( context: context, builder: (context) { return CupertinoAlertDialog( title: const Text("提示"), content: const Text('重置后,该锁的人脸都将被删除哦,确认要重置吗?'), actions: [ CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.cancel!.tr), onPressed: () { Navigator.pop(context); }, ), CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.sure!.tr), onPressed: () { Navigator.pop(context); state.isDeletFaceData = true; state.isDeletAll = true; state.deletKeyID = "1"; state.deletUserID = "DeleteAll!@#"; state.deletFaceNo = 255; // logic.senderAddFace(); }, ), ], ); }, ); } }