289 lines
10 KiB
Dart
Executable File
289 lines
10 KiB
Dart
Executable File
|
|
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/main/lockDetail/iris/irisList/irisList_state.dart';
|
|
import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart';
|
|
import 'package:star_lock/tools/keySearchWidget.dart';
|
|
import 'package:star_lock/tools/left_slide/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';
|
|
|
|
class IrisListPage extends StatefulWidget {
|
|
const IrisListPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<IrisListPage> createState() => _IrisListPageState();
|
|
}
|
|
|
|
class _IrisListPageState extends State<IrisListPage> {
|
|
final IrisListLogic logic = Get.put(IrisListLogic());
|
|
final IrisListState state = Get.find<IrisListLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '虹膜'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor,
|
|
actionsList: <Widget>[
|
|
TextButton(
|
|
child: Text(
|
|
'重置'.tr,
|
|
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
|
),
|
|
onPressed: () async {
|
|
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
|
if (isDemoMode == false) {
|
|
final bool isNetWork =
|
|
await LockMainLogic.to()?.judgeTheNetwork() ?? false;
|
|
if (!isNetWork) {
|
|
return;
|
|
}
|
|
// showDeletAlertDialog(context);
|
|
} else {
|
|
// Get.toNamed(Routers.selectLockTypePage);
|
|
logic.showToast('演示模式'.tr);
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
body: Column(
|
|
children: <Widget>[
|
|
KeySearchWidget(
|
|
editingController: state.searchController,
|
|
onSubmittedAction: () {
|
|
// logic.getFaceListData();
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 20.h,
|
|
),
|
|
Expanded(child: _buildMainUI()),
|
|
AddBottomWhiteBtn(
|
|
btnName: '添加虹膜'.tr,
|
|
onClick: () async {
|
|
// var data =
|
|
// await Get.toNamed(Routers.addFaceTypeManagePage, arguments: {
|
|
// "lockId": state.lockId.value,
|
|
// "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
|
// });
|
|
final data =
|
|
await Get.toNamed(Routers.addIrisTypeManagePage, arguments: <String, int>{
|
|
'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: (BuildContext c, int index) {
|
|
final FingerprintItemData getFaceItemData =
|
|
state.faceItemListData.value[index];
|
|
// 人脸
|
|
if (index < state.faceItemListData.value.length) {
|
|
return LeftSlideActions(
|
|
tag: getFaceItemData.faceName!,
|
|
key: Key(getFaceItemData.faceName!),
|
|
actionsWidth: 60,
|
|
actions: <Widget>[
|
|
_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
|
|
? '已失效'.tr
|
|
: '')
|
|
: '',
|
|
getFaceItemData.validTimeStr!,
|
|
// fingerprintItemData.fingerprintType! == 1
|
|
// ? "永久"
|
|
// : "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}",
|
|
() async {
|
|
final data =
|
|
await Get.toNamed(Routers.faceDetailPage, arguments: <String, FingerprintItemData>{
|
|
'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: Text(
|
|
'删除'.tr,
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.white,
|
|
height: 1,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void showIosTipViewDialog(BuildContext context) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return ShowIosTipView(
|
|
title: '提示'.tr,
|
|
tipTitle: '确定要删除吗?'.tr,
|
|
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: <Widget>[
|
|
SizedBox(width: 30.w),
|
|
Image.asset(lockTypeIcon, width: 60.w, height: 60.w),
|
|
SizedBox(width: 20.w),
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Row(
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: <Widget>[
|
|
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: <Widget>[
|
|
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: (BuildContext context) {
|
|
// return CupertinoAlertDialog(
|
|
// title: const Text('提示'),
|
|
// content: const Text('重置后,该锁的人脸都将被删除哦,确认要重置吗?'),
|
|
// actions: <Widget>[
|
|
// CupertinoDialogAction(
|
|
// child: Text('取消'.tr),
|
|
// onPressed: () {
|
|
// Navigator.pop(context);
|
|
// },
|
|
// ),
|
|
// CupertinoDialogAction(
|
|
// child: Text('确定'.tr),
|
|
// onPressed: () {
|
|
// Navigator.pop(context);
|
|
// state.isDeletFaceData = true;
|
|
// state.isDeletAll = true;
|
|
// state.deletKeyID = '1';
|
|
// state.deletUserID = 'DeleteAll!@#';
|
|
// state.deletFaceNo = 255;
|
|
// // logic.senderAddFace();
|
|
// },
|
|
// ),
|
|
// ],
|
|
// );
|
|
// },
|
|
// );
|
|
// }
|
|
}
|