1,新增手掌列表页面

2,新增添加永久、限时、循环类型手掌界面
3,新增添加手掌手势过程页面
This commit is contained in:
Daisy 2024-04-10 14:03:46 +08:00
parent 945e24aa37
commit eab54c1494
23 changed files with 1776 additions and 215 deletions

View File

@ -25,6 +25,9 @@ import 'package:star_lock/main/lockDetail/lockSet/msgNotification/msgNotificatio
import 'package:star_lock/main/lockDetail/lockSet/notificationMode/notificationMode_page.dart';
import 'package:star_lock/main/lockDetail/lockSet/openDoorDirection/openDoorDirection_page.dart';
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart';
import 'package:star_lock/main/lockDetail/palm/addPalm/addPalm_page.dart';
import 'package:star_lock/main/lockDetail/palm/addPalmType/addPalmTypeManage/addPalmTypeManage_page.dart';
import 'package:star_lock/main/lockDetail/palm/palmList/palmList_page.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart';
import 'package:star_lock/mine/about/webviewShow_page.dart';
import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart';
@ -423,7 +426,11 @@ abstract class Routers {
static const irisListPage = '/IrisListPage'; //
static const addIrisTypeManagePage = '/AddIrisTypeManagePage'; //
static const addIrisPage = '/AddIrisPage'; //
static const addIrisPage = '/AddIrisPage'; //
static const palmListPage = '/PalmListPage'; //
static const addPalmTypeManagePage = '/AddPalmTypeManagePage'; //
static const addPalmPage = '/AddPalmPage'; //
static const passwordKeyDetailChangeDatePage =
'/passwordKeyDetailChangeDatePage'; //
@ -1044,6 +1051,11 @@ abstract class AppRouters {
GetPage(
name: Routers.addIrisTypeManagePage,
page: (() => const AddIrisTypeManagePage())),
GetPage(name: Routers.addIrisPage, page: (() => const AddIrisPage()))
GetPage(name: Routers.addIrisPage, page: (() => const AddIrisPage())),
GetPage(name: Routers.palmListPage, page: (() => const PalmListPage())),
GetPage(
name: Routers.addPalmTypeManagePage,
page: (() => const AddPalmTypeManagePage())),
GetPage(name: Routers.addPalmPage, page: (() => const AddPalmPage()))
];
}

View File

@ -1,24 +1,9 @@
import 'dart:async';
import 'package:star_lock/main/lockDetail/iris/addIris/addIris_state.dart';
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart';
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/main/lockDetail/face/addFace/addFace_state.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import '../../../../../blue/blue_manage.dart';
import '../../../../../blue/io_reply.dart';
import '../../../../../blue/io_tool/io_tool.dart';
import '../../../../../blue/io_tool/manager_event_bus.dart';
import '../../../../../blue/sender_manage.dart';
import '../../../../../network/api_repository.dart';
import '../../../../../tools/baseGetXController.dart';
import '../../../../../tools/storage.dart';
class AddIrisLogic extends BaseGetXController {
final AddFaceState state = AddFaceState();
final AddIrisState state = AddIrisState();
@override
void onReady() {

View File

@ -22,10 +22,10 @@ class AddIrisTypeManageTabbar extends StatefulWidget {
@override
State<AddIrisTypeManageTabbar> createState() =>
_AddFaceTypeManageTabbarState();
_AddIrisTypeManageTabbarState();
}
class _AddFaceTypeManageTabbarState extends State<AddIrisTypeManageTabbar>
class _AddIrisTypeManageTabbarState extends State<AddIrisTypeManageTabbar>
with SingleTickerProviderStateMixin {
late TabController _tabController;

View File

@ -1,29 +1,40 @@
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/face/addFaceType/addFaceType_state.dart';
import 'package:star_lock/main/lockDetail/iris/addIrisType/addIrisType_state.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart';
import '../../../../appRouters.dart';
import '../../../../network/api_repository.dart';
class AddIrisTypeLogic extends BaseGetXController {
AddFaceTypeState state = AddFaceTypeState();
AddIrisTypeState state = AddIrisTypeState();
//
void addFaceData() async {
var faceType = 0; // :1;23:4
//
void addIrisData() async {
var irisType = 0; // :1;23:4
var startDate = "";
var endDate = "";
if (state.seletType.value == "0") {
faceType = 1;
var startTime = "";
var endTime = "";
if (state.selectType.value == "0") {
irisType = 1;
startDate = "0";
endDate = "0";
} else if (state.seletType.value == "1") {
faceType = 2;
if (state.beginTimeTimestamp.value.isEmpty) {
showToast("请选择开始时间");
startTime = "0";
endTime = "0";
} else if (state.selectType.value == "1") {
irisType = 2;
startDate =
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
startTime = "0";
endTime = "0";
if (startDate.isEmpty) {
showToast("请选择开始时间".tr);
return;
}
if (state.endTimeTimestamp.value.isEmpty) {
showToast("请选择结束时间");
if (endDate.isEmpty) {
showToast("请选择结束时间".tr);
return;
}
@ -32,53 +43,33 @@ class AddIrisTypeLogic extends BaseGetXController {
// return;
// }
if (int.parse(state.beginTimeTimestamp.value) >=
int.parse(state.endTimeTimestamp.value)) {
showToast("失效时间要大于生效时间");
if (int.parse(startDate) >= int.parse(endDate)) {
showToast("失效时间要大于生效时间".tr);
return;
}
startDate = state.beginTimeTimestamp.value;
endDate = state.endTimeTimestamp.value;
} else if (state.seletType.value == "2") {
if (state.effectiveDateTime.value <= 0) {
showToast("请选择生效时间");
} else if (state.selectType.value == "2") {
if (state.beginTime.value.isEmpty) {
showToast("请选择有效期".tr);
return;
}
if (state.failureDateTime.value <= 0) {
showToast("请选择失效时间");
return;
}
if (state.weekdaysList.value.isEmpty) {
showToast("请选择有效日");
return;
}
// if(DateTime.now().millisecondsSinceEpoch >= state.effectiveDateTime.value){
// Toast.show(msg: "生效时间要大于当前时间");
// return;
// }
if (state.effectiveDateTime.value >= state.failureDateTime.value) {
showToast("失效时间要大于生效时间");
return;
}
startDate = state.effectiveDateTime.value.toString();
endDate = state.failureDateTime.value.toString();
faceType = 4;
startDate =
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
startTime = DateTool()
.dateToTimestamp(state.effectiveDateTime.value, 0)
.toString();
endTime =
DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString();
irisType = 4;
}
print(
"传出去的给你限时人脸开始时间:${int.parse(startDate) ~/ 1000} 限时人脸结束时间:${int.parse(endDate) ~/ 1000}");
//
//
Get.toNamed(Routers.addIrisPage, arguments: {
"lockId": state.lockId.value,
"endDate": int.parse(endDate),
"addType": "1",
"faceName": state.nameController.text,
"faceNumber": "123456",
"faceType": faceType,
"faceType": irisType,
"startDate": int.parse(startDate),
"cyclicConfig": state.weekdaysList.value,
"fromType": state.fromType.value,
@ -87,13 +78,13 @@ class AddIrisTypeLogic extends BaseGetXController {
}
//
void checkFaceNameDuplicated(String faceName) async {
void checkIrisNameDuplicated(String irisName) async {
var entity = await ApiRepository.to.checkFaceNameDuplicatedData(
lockId: state.lockId.value.toString(),
faceName: faceName,
faceName: irisName,
);
if (entity.errorCode!.codeIsSuccessful) {
addFaceData();
addIrisData();
}
}
}

View File

@ -1,8 +1,10 @@
import 'package:flutter/cupertino.dart';
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/iris/addIrisType/addIrisType_logic.dart';
import 'package:star_lock/tools/dateTool.dart';
import 'package:star_lock/tools/pickers/pickers.dart';
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
@ -28,16 +30,16 @@ class AddIrisTypePage extends StatefulWidget {
: super(key: key);
@override
State<AddIrisTypePage> createState() => _AddFaceTypePageState();
State<AddIrisTypePage> createState() => _AddIrisTypePageState();
}
class _AddFaceTypePageState extends State<AddIrisTypePage> {
class _AddIrisTypePageState extends State<AddIrisTypePage> {
final logic = Get.put(AddIrisTypeLogic());
final state = Get.find<AddIrisTypeLogic>().state;
@override
Widget build(BuildContext context) {
state.seletType.value = widget.selectType;
state.selectType.value = widget.selectType;
state.lockId.value = widget.lockId;
if (widget.fromTypeTwoStaffName.isNotEmpty) {
state.nameController.text = widget.fromTypeTwoStaffName;
@ -47,12 +49,29 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
return indexChangeWidget();
}
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (state.selectType.value == "1") {
state.beginTime.value = DateTool().dateToYMDHNString(
DateTime.now().millisecondsSinceEpoch.toString()); //
state.endTime.value = DateTool().dateToYMDHNString(
DateTime.now().millisecondsSinceEpoch.toString()); //
} else {
state.beginTime.value = ""; //
state.endTime.value = ""; //
}
});
}
Widget indexChangeWidget() {
switch (int.parse(widget.selectType)) {
case 0:
{
//
// return sendElectronicKeySucceed();
return Column(
children: [
perpetualKeyWidget(
@ -86,21 +105,7 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle: "",
isHaveDirection: true,
action: () async {
Map result = await Get.toNamed(
Routers.electronicKeyPeriodValidityPage);
state.weekdaysList.value = result['validityValue'];
state.effectiveDateTime.value =
result['starDate'].millisecondsSinceEpoch;
state.failureDateTime.value =
result['endDate'].millisecondsSinceEpoch;
print(
'得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
}),
keyCyclicDate(),
SizedBox(height: 10.h),
keyBottomWidget()
],
@ -139,12 +144,7 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
action: () async {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
state.beginTime.value =
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
state.beginTimeTimestamp.value =
DateTime.parse(state.beginTime.value)
.millisecondsSinceEpoch
.toString();
state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
});
})),
Obx(() => CommonItem(
@ -154,12 +154,7 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
state.endTime.value =
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
state.endTimeTimestamp.value =
DateTime.parse(state.endTime.value)
.millisecondsSinceEpoch
.toString();
state.endTime.value = DateTool().getYMDHNDateString(p, 1);
});
})),
Container(height: 10.h),
@ -167,16 +162,90 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
);
}
//
Widget keyCyclicDate() {
return Column(
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle: "${state.beginTime.value}\n${state.endTime.value}",
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result =
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value,
'endDate': state.endTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
Get.log(
'得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
}
})),
Obx(() => Visibility(
visible: state.weekdaysList.isNotEmpty ? true : false,
child: CommonItem(
leftTitel: "有效日",
rightTitle: state.weekdaysList.value.join(",").toString(),
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value,
'endDate': state.endTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
}
}))),
Obx(() => Visibility(
visible: state.effectiveDateTime.value.isNotEmpty,
child: CommonItem(
leftTitel: "有效时间".tr,
rightTitle:
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
isHaveDirection: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value,
'endDate': state.endTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
Get.back(result: result);
}
}))),
],
);
}
Widget keyBottomWidget() {
return Column(
children: [
// CommonItem(
// leftTitel: TranslationLoader.lanKeys!.face!.tr,
// rightTitle: "",
// isTipsImg: false,
// isHaveRightWidget: true,
// rightWidget: SizedBox(
// width: 60.w, height: 50.h, child: _isStressFingerprint())),
CommonItem(
leftTitel: "是否是管理员",
rightTitle: "",
@ -195,7 +264,7 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
logic.showToast("请输入姓名");
return;
}
logic.checkFaceNameDuplicated(state.nameController.text);
logic.checkIrisNameDuplicated(state.nameController.text);
} else {
// Get.toNamed(Routers.selectLockTypePage);
logic.showToast("演示模式");
@ -205,97 +274,48 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
);
}
//
Widget sendElectronicKeySucceed() {
return Column(
children: [
Container(
height: 300.h,
width: 1.sw,
color: Colors.white,
child: Column(
children: [
SizedBox(
height: 30.h,
),
Image.asset(
'images/main/icon_main_addLock.png',
width: 150.w,
height: 150.w,
color: AppColors.mainColor,
),
SizedBox(
height: 20.h,
),
Text(
"操作成功,密码为",
style: TextStyle(
fontSize: 32.sp,
color: Colors.black,
fontWeight: FontWeight.w500),
),
SizedBox(
height: 10.h,
),
Text(
"62689876",
style: TextStyle(
fontSize: 60.sp,
color: Colors.black,
fontWeight: FontWeight.w500),
),
],
),
),
SizedBox(
height: 20.h,
),
SubmitBtn(
btnName: '完成',
fontSize: 28.sp,
borderRadius: 20.w,
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
onClick: () {}),
SubmitBtn(
btnName: '分享',
fontSize: 28.sp,
borderRadius: 20.w,
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
onClick: () {}),
SubmitBtn(
btnName: '标记为:已入住',
fontSize: 28.sp,
borderRadius: 20.w,
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
onClick: () {}),
],
);
}
//
Widget getTFWidget(String tfStr) {
return Container(
height: 50.h,
// color: Colors.red,
height: 65.h,
width: 300.w,
padding: EdgeInsets.only(top: 5.h),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: TextField(
//
maxLines: 1,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(18),
],
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
controller: state.nameController,
autofocus: false,
textAlign: TextAlign.end,
decoration: InputDecoration(
//
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
hintText: tfStr,
hintStyle: TextStyle(fontSize: 24.sp),
//线
border: InputBorder.none,
hintStyle: TextStyle(fontSize: 22.sp),
focusedBorder: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
disabledBorder: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
enabledBorder: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
border: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
contentPadding: const EdgeInsets.symmetric(vertical: 0),
),
),
),

View File

@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class AddFaceTypeState {
class AddIrisTypeState {
final lockId = 0.obs;
final seletType = "0".obs; // 0 1 2
final selectType = "0".obs; // 0 1 2
final fromType = 1.obs; // // 1 2
var fromTypeTwoStaffName = "".obs; //
final isStressFingerprint = false.obs;
@ -11,15 +11,12 @@ class AddFaceTypeState {
var beginTime = "".obs; //
var endTime = "".obs; //
var beginTimeTimestamp = "".obs; //
var endTimeTimestamp = "".obs; //
var effectiveDateTime = 0.obs; //
var failureDateTime = 0.obs; //
var effectiveDateTime = "".obs; //
var failureDateTime = "".obs; //
var weekdaysList = [].obs;
final TextEditingController nameController = TextEditingController();
AddFaceTypeState() {
AddIrisTypeState() {
// Map map = Get.arguments;
// lockId.value = map["lockId"];
// fromType.value = map["fromType"];

View File

@ -299,7 +299,7 @@ class IrisListLogic extends BaseGetXController {
}
//
Future<void> senderAddFace() async {
Future<void> senderAddIris() async {
showEasyLoading();
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
@ -339,8 +339,8 @@ class IrisListLogic extends BaseGetXController {
});
}
//
void getFaceListData() async {
//
void getIrisListData() async {
var entity = await ApiRepository.to.getFaceListData(
lockId: state.lockId.value.toString(),
pageNo: '1',
@ -368,7 +368,7 @@ class IrisListLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) {
showToast("删除成功");
state.isDeletFaceData = false;
getFaceListData();
getIrisListData();
}
}
@ -387,7 +387,7 @@ class IrisListLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) {
showToast("重置成功");
state.isDeletFaceData = false;
getFaceListData();
getIrisListData();
}
}
@ -395,7 +395,7 @@ class IrisListLogic extends BaseGetXController {
late StreamSubscription _teamEvent;
void _initRefreshAction() {
_teamEvent = eventBus.on<OtherTypeRefreshListEvent>().listen((event) {
getFaceListData();
getIrisListData();
});
}
@ -409,11 +409,11 @@ class IrisListLogic extends BaseGetXController {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
// print("aaaaaaa:$isDemoMode");
if (isDemoMode == false) {
_initReplySubscription();
// _initReplySubscription();
_initRefreshAction();
// _initRefreshAction();
getFaceListData();
// getFaceListData();
}
}

View File

@ -58,7 +58,7 @@ class _IrisListPageState extends State<IrisListPage> {
KeySearchWidget(
editingController: state.searchController,
onSubmittedAction: () {
logic.getFaceListData();
// logic.getFaceListData();
},
),
SizedBox(
@ -79,7 +79,7 @@ class _IrisListPageState extends State<IrisListPage> {
"fromType": 1 // 1 2
});
if (data != null) {
logic.getFaceListData();
// logic.getFaceListData();
}
},
),
@ -127,7 +127,7 @@ class _IrisListPageState extends State<IrisListPage> {
"faceItemData": getFaceItemData,
});
if (data != null) {
logic.getFaceListData();
// logic.getFaceListData();
}
}),
);
@ -182,7 +182,7 @@ class _IrisListPageState extends State<IrisListPage> {
state.isDeletFaceData = true;
state.isDeletAll = false;
state.deletUserID = (await Storage.getUid())!;
logic.senderAddFace();
// logic.senderAddFace();
},
cancelClick: () {
Get.back();
@ -269,7 +269,7 @@ class _IrisListPageState extends State<IrisListPage> {
state.deletKeyID = "1";
state.deletUserID = "DeleteAll!@#";
state.deletFaceNo = 255;
logic.senderAddFace();
// logic.senderAddFace();
},
),
],

View File

@ -688,12 +688,12 @@ class _LockDetailPageState extends State<LockDetailPage>
);
showWidgetArr.add(
bottomItem(
'images/main/icon_face.png',
'手掌',
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value,
() {}),
bottomItem('images/main/icon_face.png', '手掌',
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
Get.toNamed(Routers.palmListPage, arguments: {
"lockId": state.keyInfos.value.lockId,
});
}),
);
//->

View File

@ -0,0 +1,31 @@
import 'package:star_lock/main/lockDetail/palm/addPalm/addPalm_state.dart';
import '../../../../../tools/baseGetXController.dart';
class AddPalmLogic extends BaseGetXController {
final AddPalmState state = AddPalmState();
@override
void onReady() {
// TODO: implement onReady
super.onReady();
// _initReplySubscription();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
//
// senderAddFace();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
// _replySubscription.cancel();
}
}

View File

@ -0,0 +1,94 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/palm/addPalm/addPalm_logic.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/submitBtn.dart';
import '../../../../../tools/titleAppBar.dart';
import '../../../../../translations/trans_lib.dart';
class AddPalmPage extends StatefulWidget {
const AddPalmPage({Key? key}) : super(key: key);
@override
State<AddPalmPage> createState() => _AddPalmPageState();
}
class _AddPalmPageState extends State<AddPalmPage> {
final logic = Get.put(AddPalmLogic());
final state = Get.find<AddPalmLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: TitleAppBar(
barTitle: "${TranslationLoader.lanKeys!.addTip!.tr}手掌",
haveBack: true,
backgroundColor: AppColors.mainColor),
body: ListView(
children: [
SizedBox(
height: 50.h,
),
Obx(() => Image.asset(
state.isClickAddFace.value == false
? 'images/main/icon_addFace_step1.png'
: 'images/main/icon_addFace_step2.png',
width: 100.w,
height: 457.h,
fit: BoxFit.fitHeight,
)),
SizedBox(
height: 60.h,
),
Container(
padding: EdgeInsets.only(left: 20.w, right: 20.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: Text(
"请单人正对门锁,距离一个成年人手臂长度\n(约0.6米)。\n保持脸部无遮挡,露出五官。",
textAlign: TextAlign.left,
maxLines: null,
style:
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
),
),
],
),
),
SizedBox(
height: 120.h,
),
Obx(
() => state.isClickAddFace.value == false
? Container(
padding: EdgeInsets.only(left: 20.w, right: 20.w),
child: SubmitBtn(
btnName: "准备好了,开始添加",
borderRadius: 20.w,
onClick: () {
state.isClickAddFace.value = true;
}),
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'正在录入中...',
style: TextStyle(
color: AppColors.darkGrayTextColor,
fontSize: 22.sp),
textAlign: TextAlign.center,
)
],
),
)
],
),
);
}
}

View File

@ -0,0 +1,37 @@
import 'package:get/get.dart';
class AddPalmState {
var ifCurrentScreen = true.obs; // ,
var ifConnectScuess = false.obs;
var maxRegCount = 0.obs; //
var regIndex = 0.obs; //
var faceNumber = "".obs;
final lockId = 0.obs;
final endDate = 0.obs;
final addType = "".obs;
final faceName = "".obs;
final faceType = 0.obs;
final startDate = 0.obs;
final cyclicConfig = [].obs;
final fromType = 1.obs;
final featureData = ''.obs;
final isClickAddFace = false.obs;
final isAdministrator = false.obs;
AddPalmState() {
Map map = Get.arguments;
lockId.value = map["lockId"];
endDate.value = map["endDate"];
addType.value = map["addType"];
faceName.value = map["faceName"];
faceType.value = map["faceType"];
startDate.value = map["startDate"];
lockId.value = map["lockId"];
cyclicConfig.value = map["cyclicConfig"];
fromType.value = map["fromType"];
isAdministrator.value = map["isAdministrator"];
}
}

View File

@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/palm/addPalmType/addPalmTypeManage/addPalmTypeManage_tabbar.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/titleAppBar.dart';
import '../../../../../translations/trans_lib.dart';
class AddPalmTypeManagePage extends StatefulWidget {
const AddPalmTypeManagePage({Key? key}) : super(key: key);
@override
State<AddPalmTypeManagePage> createState() => _AddPalmTypeManagePageState();
}
class _AddPalmTypeManagePageState extends State<AddPalmTypeManagePage> {
var index = 0;
@override
Widget build(BuildContext context) {
Map map = Get.arguments;
var lockId = map["lockId"];
var fromType = map["fromType"]; // 1 2
var fromTypeTwoStaffName = "";
if (fromType == 2) {
fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; //
}
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: "${TranslationLoader.lanKeys!.addTip!.tr}手掌",
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
children: [
AddPalmTypeManageTabbar(
lockId: lockId,
fromType: fromType,
fromTypeTwoStaffName: fromTypeTwoStaffName,
initialIndex: index),
],
),
);
}
}

View File

@ -0,0 +1,138 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/palm/addPalmType/addPalmType_page.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/CustomUnderlineTabIndicator.dart';
import '../../../../../translations/trans_lib.dart';
class AddPalmTypeManageTabbar extends StatefulWidget {
var initialIndex = 1;
var lockId = 0;
var fromType = 1; // 1 2
var fromTypeTwoStaffName = ""; //
AddPalmTypeManageTabbar(
{Key? key,
required this.lockId,
required this.fromType,
required this.fromTypeTwoStaffName,
required this.initialIndex})
: super(key: key);
@override
State<AddPalmTypeManageTabbar> createState() =>
_AddPalmTypeManageTabbarState();
}
class _AddPalmTypeManageTabbarState extends State<AddPalmTypeManageTabbar>
with SingleTickerProviderStateMixin {
late TabController _tabController;
final List<ItemView> _itemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
ItemView(
title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"),
];
final List<ItemView> _fromCheckInTypeItemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
];
@override
void initState() {
// TODO: implement initState
super.initState();
_tabController = TabController(
vsync: this,
length: _itemTabs.length,
initialIndex: widget.initialIndex);
_tabController.addListener(() {
// print("_tabController.animation!.value:${_tabController.animation!.value} _tabController.index:${_tabController.index}");
if (_tabController.animation!.value == _tabController.index) {
FocusScope.of(context).requestFocus(FocusNode());
}
});
}
@override
Widget build(BuildContext context) {
return Expanded(
child: Column(
children: [
_tabBar(),
_pageWidget(),
],
));
}
TabBar _tabBar() {
return TabBar(
controller: _tabController,
tabs: widget.fromType == 1
? _itemTabs.map((ItemView item) => _tab(item)).toList()
: _fromCheckInTypeItemTabs
.map((ItemView item) => _tab(item))
.toList(),
isScrollable: true,
indicatorColor: Colors.red,
unselectedLabelColor: Colors.black,
unselectedLabelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
),
automaticIndicatorColorAdjustment: true,
labelColor: AppColors.mainColor,
labelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
fontWeight: FontWeight.w600),
indicator: CustomUnderlineTabIndicator(
borderSide: BorderSide(color: AppColors.mainColor, width: 4.w),
strokeCap: StrokeCap.round,
width: 30.w),
);
}
Tab _tab(ItemView item) {
return Tab(
child: SizedBox(
width: 1.sw / 5,
child: Text(item.title, textAlign: TextAlign.center)));
}
Widget _pageWidget() {
return Expanded(
child: TabBarView(
controller: _tabController,
children: widget.fromType == 1
? _itemTabs
.map((ItemView item) => AddPalmTypePage(
selectType: item.selectType,
lockId: widget.lockId,
fromType: widget.fromType,
fromTypeTwoStaffName: widget.fromTypeTwoStaffName))
.toList()
: _itemTabs
.map((ItemView item) => AddPalmTypePage(
selectType: item.selectType,
lockId: widget.lockId,
fromType: widget.fromType,
fromTypeTwoStaffName: widget.fromTypeTwoStaffName))
.toList(),
// _itemTabs.map((ItemView item) => AddFaceTypePage(selectType: item.selectType, lockId: widget.lockId, fromType: widget.fromType, fromTypeTwoStaffName:widget.fromTypeTwoStaffName)).toList(),
),
);
}
}
class ItemView {
const ItemView({required this.title, required this.selectType});
final String title;
final String selectType;
}

View File

@ -0,0 +1,90 @@
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/palm/addPalmType/addPalmType_state.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart';
import '../../../../appRouters.dart';
import '../../../../network/api_repository.dart';
class AddPalmTypeLogic extends BaseGetXController {
AddPalmTypeState state = AddPalmTypeState();
//
void addPalmData() async {
var palmType = 0; // :1;23:4
var startDate = "";
var endDate = "";
var startTime = "";
var endTime = "";
if (state.selectType.value == "0") {
palmType = 1;
startDate = "0";
endDate = "0";
startTime = "0";
endTime = "0";
} else if (state.selectType.value == "1") {
palmType = 2;
startDate =
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
startTime = "0";
endTime = "0";
if (startDate.isEmpty) {
showToast("请选择开始时间".tr);
return;
}
if (endDate.isEmpty) {
showToast("请选择结束时间".tr);
return;
}
// if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){
// Toast.show(msg: "生效时间要大于当前时间");
// return;
// }
if (int.parse(startDate) >= int.parse(endDate)) {
showToast("失效时间要大于生效时间".tr);
return;
}
} else if (state.selectType.value == "2") {
if (state.beginTime.value.isEmpty) {
showToast("请选择有效期".tr);
return;
}
startDate =
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
startTime = DateTool()
.dateToTimestamp(state.effectiveDateTime.value, 0)
.toString();
endTime =
DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString();
palmType = 4;
}
//
Get.toNamed(Routers.addPalmPage, arguments: {
"lockId": state.lockId.value,
"endDate": int.parse(endDate),
"addType": "1",
"faceName": state.nameController.text,
"faceNumber": "123456",
"faceType": palmType,
"startDate": int.parse(startDate),
"cyclicConfig": state.weekdaysList.value,
"fromType": state.fromType.value,
"isAdministrator": state.isAdministrator.value,
});
}
//
void checkPalmNameDuplicated(String palmName) async {
var entity = await ApiRepository.to.checkFaceNameDuplicatedData(
lockId: state.lockId.value.toString(),
faceName: palmName,
);
if (entity.errorCode!.codeIsSuccessful) {
addPalmData();
}
}
}

View File

@ -0,0 +1,342 @@
import 'package:flutter/cupertino.dart';
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/palm/addPalmType/addPalmType_logic.dart';
import 'package:star_lock/tools/dateTool.dart';
import 'package:star_lock/tools/pickers/pickers.dart';
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/storage.dart';
import '../../../../tools/submitBtn.dart';
import '../../../../translations/trans_lib.dart';
class AddPalmTypePage extends StatefulWidget {
final String selectType; //
final int lockId;
final int fromType; // // 1 2
final String fromTypeTwoStaffName; //
const AddPalmTypePage(
{Key? key,
required this.selectType,
required this.lockId,
required this.fromType,
required this.fromTypeTwoStaffName})
: super(key: key);
@override
State<AddPalmTypePage> createState() => _AddPalmTypePageState();
}
class _AddPalmTypePageState extends State<AddPalmTypePage> {
final logic = Get.put(AddPalmTypeLogic());
final state = Get.find<AddPalmTypeLogic>().state;
@override
Widget build(BuildContext context) {
state.selectType.value = widget.selectType;
state.lockId.value = widget.lockId;
if (widget.fromTypeTwoStaffName.isNotEmpty) {
state.nameController.text = widget.fromTypeTwoStaffName;
}
state.fromType.value = widget.fromType;
return indexChangeWidget();
}
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (state.selectType.value == "1") {
state.beginTime.value = DateTool().dateToYMDHNString(
DateTime.now().millisecondsSinceEpoch.toString()); //
state.endTime.value = DateTool().dateToYMDHNString(
DateTime.now().millisecondsSinceEpoch.toString()); //
} else {
state.beginTime.value = ""; //
state.endTime.value = ""; //
}
});
}
Widget indexChangeWidget() {
switch (int.parse(widget.selectType)) {
case 0:
{
//
return Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyBottomWidget()
],
);
}
case 1:
{
//
return Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyTimeLimitWidget(),
keyBottomWidget()
],
);
}
case 2:
{
//
return Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyCyclicDate(),
SizedBox(height: 10.h),
keyBottomWidget()
],
);
}
default:
return Container();
}
}
//
Widget perpetualKeyWidget(
String titleStr, String rightTitle, TextEditingController controller) {
return Column(
children: [
Container(height: 10.h),
CommonItem(
leftTitel: titleStr,
rightTitle: "",
isHaveRightWidget: true,
rightWidget: getTFWidget(rightTitle)),
Container(height: 10.h),
],
);
}
//
Widget keyTimeLimitWidget() {
return Column(
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.beginTime.value,
isHaveLine: true,
isHaveDirection: true,
action: () async {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
});
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.endTime.value,
isHaveDirection: true,
action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
state.endTime.value = DateTool().getYMDHNDateString(p, 1);
});
})),
Container(height: 10.h),
],
);
}
//
Widget keyCyclicDate() {
return Column(
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle: "${state.beginTime.value}\n${state.endTime.value}",
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result =
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value,
'endDate': state.endTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
Get.log(
'得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
}
})),
Obx(() => Visibility(
visible: state.weekdaysList.isNotEmpty ? true : false,
child: CommonItem(
leftTitel: "有效日",
rightTitle: state.weekdaysList.value.join(",").toString(),
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value,
'endDate': state.endTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
}
}))),
Obx(() => Visibility(
visible: state.effectiveDateTime.value.isNotEmpty,
child: CommonItem(
leftTitel: "有效时间".tr,
rightTitle:
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
isHaveDirection: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value,
'endDate': state.endTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
Get.back(result: result);
}
}))),
],
);
}
Widget keyBottomWidget() {
return Column(
children: [
CommonItem(
leftTitel: "是否是管理员",
rightTitle: "",
isTipsImg: false,
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w, height: 50.h, child: Obx(() => _isAdmin()))),
SizedBox(height: 30.h),
SubmitBtn(
btnName: TranslationLoader.lanKeys!.next!.tr,
onClick: () async {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
// print("state.selectType:${state.selectType.value}");
if (state.nameController.text.isEmpty) {
logic.showToast("请输入姓名");
return;
}
logic.checkPalmNameDuplicated(state.nameController.text);
} else {
// Get.toNamed(Routers.selectLockTypePage);
logic.showToast("演示模式");
}
}),
],
);
}
//
Widget getTFWidget(String tfStr) {
return Container(
// color: Colors.red,
height: 65.h,
width: 300.w,
padding: EdgeInsets.only(top: 5.h),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: TextField(
//
maxLines: 1,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(18),
],
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
controller: state.nameController,
autofocus: false,
textAlign: TextAlign.end,
decoration: InputDecoration(
//
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
hintText: tfStr,
hintStyle: TextStyle(fontSize: 22.sp),
focusedBorder: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
disabledBorder: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
enabledBorder: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
border: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent)),
contentPadding: const EdgeInsets.symmetric(vertical: 0),
),
),
),
SizedBox(
width: 10.w,
),
],
),
);
}
//
CupertinoSwitch _isAdmin() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isAdministrator.value,
onChanged: (value) {
state.isAdministrator.value = value;
},
);
}
}

View File

@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class AddPalmTypeState {
final lockId = 0.obs;
final selectType = "0".obs; // 0 1 2
final fromType = 1.obs; // // 1 2
var fromTypeTwoStaffName = "".obs; //
final isStressFingerprint = false.obs;
final isAdministrator = false.obs; //
var beginTime = "".obs; //
var endTime = "".obs; //
var effectiveDateTime = "".obs; //
var failureDateTime = "".obs; //
var weekdaysList = [].obs;
final TextEditingController nameController = TextEditingController();
AddPalmTypeState() {
// Map map = Get.arguments;
// lockId.value = map["lockId"];
// fromType.value = map["fromType"];
// if(fromType.value == 2){
// fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; //
// // nameController.text = fromTypeTwoStaffName.value;
// }
// print("lockId:${lockId.value} fromType:${fromType.value}");
}
}

View File

@ -0,0 +1,445 @@
import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/main/lockDetail/palm/palmList/palmList_state.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../../blue/blue_manage.dart';
import '../../../../blue/io_protocol/io_checkingUserInfoCount.dart';
import '../../../../blue/io_reply.dart';
import '../../../../blue/io_tool/io_tool.dart';
import '../../../../blue/io_tool/manager_event_bus.dart';
import '../../../../blue/sender_manage.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/storage.dart';
class PalmListLogic extends BaseGetXController {
PalmListState state = PalmListState();
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((reply) {
// ()
if ((reply is SenderAddFaceReply) && (state.isDeletFaceData == true)) {
_replyAddFaceBegin(reply);
}
if (reply is SenderQueryingFaceStatusReply) {
//
_replyQueryingFaceStatus(reply);
}
if (reply is SenderCheckingUserInfoCountReply) {
_replyCheckingUserInfoCount(reply);
}
});
}
// ---
Future<void> _replyAddFaceBegin(Reply reply) async {
int status = reply.data[2];
print("status:$status");
switch (status) {
case 0x00:
//
print("${reply.commandType!.typeValue} list人脸数据解析成功");
state.isDeletFaceData = false;
cancelBlueConnetctToastTimer();
dismissEasyLoading();
if (state.isDeletAll == false) {
deletFacesData();
} else {
clearAllFacesData();
}
break;
case 0x06:
//
print("${reply.commandType!.typeValue} 需要鉴权");
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderAddFaceCommand(
keyID: state.deletKeyID,
userID: state.deletUserID,
faceNo: state.deletFaceNo,
useCountLimit: 0,
startTime: 0x11223344,
endTime: 0x11223344,
needAuthor: 1,
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
token: getTokenList,
);
break;
case 0x07:
//
print("${reply.commandType!.typeValue} 用户无权限");
break;
case 0x09:
//
print("${reply.commandType!.typeValue} 权限校验错误");
break;
default:
//
print("${reply.commandType!.typeValue} list人脸失败");
break;
}
}
//
Future<void> _replyQueryingFaceStatus(Reply reply) async {
int status = reply.data[2];
switch (status) {
case 0x00:
//
print("${reply.commandType}数据解析成功");
// _getLockStatus();
break;
case 0x06:
//
print("${reply.commandType}需要鉴权");
break;
case 0x07:
//
print("${reply.commandType}用户无权限");
break;
case 0x09:
//
print("${reply.commandType}权限校验错误");
break;
default:
//
print("${reply.commandType}失败");
break;
}
}
//
Future<void> _replyReferEventRecordNumber(Reply reply) async {
int status = reply.data[2];
switch (status) {
case 0x00:
//
print("${reply.commandType}数据解析成功");
// _getLockStatus();
break;
case 0x06:
//
print("${reply.commandType}需要鉴权");
break;
case 0x07:
//
print("${reply.commandType}用户无权限");
break;
case 0x09:
//
print("${reply.commandType}权限校验错误");
break;
default:
//
print("${reply.commandType}失败");
break;
}
}
// ()
Future<void> _replyCheckingUserInfoCount(Reply reply) async {
int status = reply.data[2];
//
int userNum = reply.data[5];
// print("userNum:$userNum");
//
int fingerNum = reply.data[6];
// print("fingerNum:$fingerNum");
//
int pwdNum = reply.data[7];
//
int cardNum = reply.data[8];
//
int logsNum = reply.data[9];
//
int verNo = reply.data[10];
//
int maxAdminFingerNum = reply.data[11];
//
int maxUserFingerNum = reply.data[12];
//
int maxAdminPassNum = reply.data[13];
//
int maxUserPassNum = reply.data[14];
//
int maxAdminCardNum = reply.data[15];
//
int maxUserCardNum = reply.data[16];
//
var serialNo = reply.data.sublist(17, 21);
print("serialNo:$serialNo");
switch (status) {
case 0x00:
//
print("${reply.commandType}数据解析成功");
// _getLockStatus();
break;
case 0x06:
//
print("${reply.commandType}需要鉴权");
break;
case 0x07:
//
print("${reply.commandType}用户无权限");
break;
case 0x09:
//
print("${reply.commandType}权限校验错误");
break;
default:
//
print("${reply.commandType}失败");
break;
}
}
//
Future<void> senderQueryingFaceStatus() async {
BlueManage().bludSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState state) async {
if (state == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
IoSenderManage.senderQueryingFaceStatusCommand(
keyID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
role: 0xff,
faceCount: 20,
faceNo: 1,
token: getTokenList,
needAuthor: 1,
publicKey: getPublicKeyList,
privateKey: getPrivateKeyList,
);
}
});
}
// ()
Future<void> senderCheckingUserInfoCount() async {
BlueManage().bludSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState state) async {
if (state == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
IoSenderManage.senderCheckingUserInfoCountCommand(
keyID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
role: 0xff,
nowTime: DateTime.now().millisecondsSinceEpoch ~/ 1000,
token: getTokenList,
needAuthor: 1,
publicKey: getPublicKeyList,
privateKey: getPrivateKeyList,
);
}
});
}
//
Future<void> senderAddFace() async {
showEasyLoading();
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
});
BlueManage().bludSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderAddFaceCommand(
keyID: state.deletKeyID,
userID: state.deletUserID,
faceNo: state.deletFaceNo,
useCountLimit: 0,
startTime: 0x11223344,
endTime: 0x11223344,
needAuthor: 1,
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
token: getTokenList,
);
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
}
}
});
}
//
void getFaceListData() async {
var entity = await ApiRepository.to.getFaceListData(
lockId: state.lockId.value.toString(),
pageNo: '1',
pageSize: '20',
searchStr: state.searchController.text,
);
if (entity.errorCode!.codeIsSuccessful) {
state.faceItemListData.value = entity.data!.list!;
}
}
//
void deletFacesData() async {
var faceId = "";
var type = "1";
if (state.isDeletAll == false) {
faceId = state.deletKeyID;
type = "0";
}
print("delet faceId $faceId");
var entity = await ApiRepository.to.deleteFaceData(
faceId: int.parse(faceId),
lockId: state.lockId.value,
);
if (entity.errorCode!.codeIsSuccessful) {
showToast("删除成功");
state.isDeletFaceData = false;
getFaceListData();
}
}
//
void clearAllFacesData() async {
var faceId = "";
var type = "1";
if (state.isDeletAll == false) {
faceId = state.deletKeyID;
type = "0";
}
print("delet faceId $faceId");
var entity = await ApiRepository.to.clearFaceData(
lockId: state.lockId.value,
);
if (entity.errorCode!.codeIsSuccessful) {
showToast("重置成功");
state.isDeletFaceData = false;
getFaceListData();
}
}
//
late StreamSubscription _teamEvent;
void _initRefreshAction() {
_teamEvent = eventBus.on<OtherTypeRefreshListEvent>().listen((event) {
getFaceListData();
});
}
@override
Future<void> onReady() async {
// TODO: implement onReady
super.onReady();
print("onReady()");
//
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
// print("aaaaaaa:$isDemoMode");
if (isDemoMode == false) {
// _initReplySubscription();
// _initRefreshAction();
// getFaceListData();
}
}
@override
Future<void> onInit() async {
// TODO: implement onInit
super.onInit();
print("onInit()");
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
// senderQueryingFingerprintStatus();
// senderCheckingCardStatus();
// senderCheckingUserInfoCount();
}
}
@override
Future<void> onClose() async {
// TODO: implement onClose
super.onClose();
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
_replySubscription.cancel();
_teamEvent.cancel();
}
}
}

View File

@ -0,0 +1,280 @@
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/palm/palmList/palmList_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 PalmListPage extends StatefulWidget {
const PalmListPage({Key? key}) : super(key: key);
@override
State<PalmListPage> createState() => _PalmListPageState();
}
class _PalmListPageState extends State<PalmListPage> {
final logic = Get.put(PalmListLogic());
final state = Get.find<PalmListLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: '手掌',
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}手掌',
onClick: () async {
// var data =
// await Get.toNamed(Routers.addFaceTypeManagePage, arguments: {
// "lockId": state.lockId.value,
// "fromType": 1 // 1 2
// });
var data =
await Get.toNamed(Routers.addPalmTypeManagePage, 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();
},
),
],
);
},
);
}
}

View File

@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart';
class PalmListState {
final TextEditingController searchController = TextEditingController();
final lockId = 0.obs;
//
var isDeletFaceData = false;
var isDeletAll = false;
var deletKeyID = "";
var deletUserID = "DeleteAll!@#";
var deletFaceNo = 0;
final faceItemListData = <FingerprintItemData>[].obs;
var ifCurrentScreen = true.obs; // ,
PalmListState() {
Map map = Get.arguments;
lockId.value = map["lockId"];
}
}