373 lines
13 KiB
Dart
373 lines
13 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_logic.dart';
|
|
|
|
import '../../../../appRouters.dart';
|
|
import '../../../../app_settings/app_colors.dart';
|
|
import '../../../../blue/blue_manage.dart';
|
|
import '../../../../tools/appRouteObserver.dart';
|
|
import '../../../../tools/commonItem.dart';
|
|
import '../../../../tools/dateTool.dart';
|
|
import '../../../../tools/showIosTipView.dart';
|
|
import '../../../../tools/showTFView.dart';
|
|
import '../../../../tools/submitBtn.dart';
|
|
import '../../../../tools/titleAppBar.dart';
|
|
import '../../../../translations/trans_lib.dart';
|
|
|
|
class FaceDetailPage extends StatefulWidget {
|
|
const FaceDetailPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<FaceDetailPage> createState() => _FaceDetailPageState();
|
|
}
|
|
|
|
class _FaceDetailPageState extends State<FaceDetailPage> with RouteAware {
|
|
final logic = Get.put(FaceDetailLogic());
|
|
final state = Get.find<FaceDetailLogic>().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!.share!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp),),
|
|
// onPressed: () {
|
|
//
|
|
// },
|
|
// ),
|
|
// ],
|
|
),
|
|
body: Column(
|
|
children: [
|
|
Obx(() => CommonItem(
|
|
leftTitel: "人脸号",
|
|
rightTitle: state.typeNumber.value,
|
|
isHaveDirection: false,
|
|
isHaveLine: true)),
|
|
Obx(() => CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
|
rightTitle: state.typeName.value,
|
|
isHaveDirection: true,
|
|
isHaveLine: true,
|
|
action: () {
|
|
showCupertinoAlertDialog(context);
|
|
})),
|
|
Obx(() => Visibility(
|
|
visible: (state.keyType.value == 4 || state.keyType.value == 2)
|
|
? true
|
|
: false,
|
|
child: CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
|
allHeight: 70.h,
|
|
// rightTitle:"2023.09.19 11:27\n2023.09.25 11:27",
|
|
rightTitle: state.keyType.value == 1
|
|
? "永久"
|
|
: "${DateTool().dateToYMDHNString(state.effectiveDateTime.value.toString())}\n${DateTool().dateToYMDHNString(state.failureDateTime.value.toString())}",
|
|
isHaveDirection: true,
|
|
isHaveLine: true,
|
|
action: () async {
|
|
// switch(state.type.value){
|
|
// case 0:
|
|
// // 卡
|
|
//
|
|
// break;
|
|
// case 1:
|
|
// 当是指纹的时候
|
|
if (state.keyType.value == 2) {
|
|
// 限时
|
|
var data = await Get.toNamed(
|
|
Routers.otherTypeKeyChangeDatePage,
|
|
arguments: {
|
|
"faceItemData": state.faceItemData.value,
|
|
"pushType": 1,
|
|
});
|
|
if (data != null) {
|
|
setState(() {
|
|
state.effectiveDateTime.value =
|
|
data["beginTimeTimestamp"];
|
|
state.failureDateTime.value =
|
|
data["endTimeTimestamp"];
|
|
});
|
|
}
|
|
} else if (state.keyType.value == 4) {
|
|
// 循环
|
|
var data = await Get.toNamed(
|
|
Routers.otherTypeKeyChangeValidityDatePage,
|
|
arguments: {
|
|
"faceItemData": state.faceItemData.value,
|
|
});
|
|
if (data != null) {
|
|
setState(() {
|
|
state.effectiveDateTime.value =
|
|
data["beginTimeTimestamp"];
|
|
state.failureDateTime.value =
|
|
data["endTimeTimestamp"];
|
|
state.weekDay.value = data["weekDay"];
|
|
});
|
|
}
|
|
}
|
|
}))),
|
|
Obx(() => Visibility(
|
|
visible: state.keyType.value == 4 ? true : false,
|
|
child: Obx(() => CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr,
|
|
rightTitle: state.weekDay.value.join(','),
|
|
isHaveDirection: true,
|
|
action: () async {
|
|
// 当是人脸的时候
|
|
var data = await Get.toNamed(
|
|
Routers.otherTypeKeyChangeValidityDatePage,
|
|
arguments: {
|
|
"faceItemData": state.faceItemData.value,
|
|
});
|
|
if (data != null) {
|
|
setState(() {
|
|
state.effectiveDateTime.value =
|
|
data["beginTimeTimestamp"];
|
|
state.failureDateTime.value = data["endTimeTimestamp"];
|
|
state.weekDay.value = data["weekDay"];
|
|
});
|
|
}
|
|
})))),
|
|
Container(height: 10.h),
|
|
Obx(() => CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.additive!.tr,
|
|
rightTitle: state.adder.value,
|
|
isHaveLine: true,
|
|
action: () {})),
|
|
Obx(() => CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.addTime!.tr,
|
|
rightTitle:
|
|
DateTool().dateToYMDHNString(state.addTime.value.toString()),
|
|
action: () {})),
|
|
SizedBox(height: 10.h),
|
|
|
|
Container(height: 10.h),
|
|
CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.operatingRecord!.tr,
|
|
rightTitle: "",
|
|
isHaveDirection: true,
|
|
action: () {
|
|
// 人脸
|
|
Get.toNamed(Routers.keyOperationRecordPage, arguments: {
|
|
'lockId': state.faceItemData.value.lockId.toString(),
|
|
'faceId': state.faceItemData.value.faceId.toString()
|
|
});
|
|
}),
|
|
// SizedBox(height: 40.h),
|
|
// addControlsBtn(type),
|
|
SizedBox(height: 30.h),
|
|
SubmitBtn(
|
|
btnName: TranslationLoader.lanKeys!.delete!.tr,
|
|
isDelete: true,
|
|
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: () {
|
|
showIosTipViewDialog(context);
|
|
}),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// Widget addControlsBtn(int type) {
|
|
// List<Widget> widgetList = [];
|
|
// List<Map<String, dynamic>> routerList = [];
|
|
// //卡详情
|
|
// if (type == 0) {
|
|
// routerList.add({
|
|
// 'btnTitle': '设置密码',
|
|
// 'routerName': Routers.passwordKeyDetailPage,
|
|
// 'type': 9
|
|
// });
|
|
// routerList.add({
|
|
// 'btnTitle': '设置指纹',
|
|
// 'routerName': Routers.otherTypeKeyManagePage,
|
|
// 'type': 1
|
|
// });
|
|
// routerList.add({
|
|
// 'btnTitle': '设置遥控',
|
|
// 'routerName': Routers.otherTypeKeyManagePage,
|
|
// 'type': 2
|
|
// });
|
|
// } else if (type == 1) {
|
|
// //指纹详情
|
|
// routerList.add({
|
|
// 'btnTitle': '设置密码',
|
|
// 'routerName': Routers.passwordKeyDetailPage,
|
|
// 'type': 9
|
|
// });
|
|
// routerList.add({
|
|
// 'btnTitle': '设置卡',
|
|
// 'routerName': Routers.otherTypeKeyManagePage,
|
|
// 'type': 0
|
|
// });
|
|
// routerList.add({
|
|
// 'btnTitle': '设置遥控',
|
|
// 'routerName': Routers.otherTypeKeyManagePage,
|
|
// 'type': 2
|
|
// });
|
|
// } else if (type == 2) {
|
|
// //遥控详情
|
|
// routerList.add({
|
|
// 'btnTitle': '设置密码',
|
|
// 'routerName': Routers.passwordKeyDetailPage,
|
|
// 'type': 9
|
|
// });
|
|
// routerList.add({
|
|
// 'btnTitle': '设置卡',
|
|
// 'routerName': Routers.otherTypeKeyManagePage,
|
|
// 'type': 0
|
|
// });
|
|
// routerList.add({
|
|
// 'btnTitle': '设置指纹',
|
|
// 'routerName': Routers.otherTypeKeyManagePage,
|
|
// 'type': 1
|
|
// });
|
|
// }
|
|
//
|
|
// for (int i = 0; i < routerList.length; i++) {
|
|
// widgetList.add(SizedBox(
|
|
// width: ScreenUtil().screenWidth - 40.w,
|
|
// height: 60.h,
|
|
// child: OutlinedButton(
|
|
// style: OutlinedButton.styleFrom(
|
|
// // backgroundColor: Colors.white,
|
|
// side: BorderSide(width: 1, color: AppColors.mainColor)),
|
|
// onPressed: () {
|
|
// if (routerList[i]['type'] == 9) {
|
|
// Navigator.pushNamed(context, Routers.passwordKeyManagePage);
|
|
// } else {
|
|
// Navigator.pushNamed(context, Routers.otherTypeKeyManagePage,
|
|
// arguments: routerList[i]['type']);
|
|
// }
|
|
// },
|
|
// child: Text(
|
|
// routerList[i]['btnTitle'],
|
|
// style: TextStyle(color: AppColors.mainColor, fontSize: 24.sp),
|
|
// )),
|
|
// ));
|
|
//
|
|
// widgetList.add(
|
|
// SizedBox(
|
|
// height: 10.h,
|
|
// ),
|
|
// );
|
|
// }
|
|
//
|
|
// return Column(
|
|
// children: widgetList,
|
|
// );
|
|
// }
|
|
|
|
void showCupertinoAlertDialog(BuildContext context) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return ShowTFView(
|
|
title:
|
|
"${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}",
|
|
tipTitle: "",
|
|
controller: state.changeNameController,
|
|
sureClick: () {
|
|
if (state.changeNameController.text.isEmpty) {
|
|
logic.showToast("请输入姓名");
|
|
return;
|
|
}
|
|
Get.back();
|
|
// 面容
|
|
logic.updateFaceNameData();
|
|
},
|
|
cancelClick: () {
|
|
Get.back();
|
|
},
|
|
);
|
|
});
|
|
}
|
|
|
|
void showIosTipViewDialog(BuildContext context) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return ShowIosTipView(
|
|
title: "提示",
|
|
tipTitle: "确定要删除吗?",
|
|
sureClick: () {
|
|
Get.back();
|
|
// 人脸
|
|
logic.senderAddFace();
|
|
},
|
|
cancelClick: () {
|
|
Get.back();
|
|
},
|
|
);
|
|
});
|
|
}
|
|
|
|
@override
|
|
void didChangeDependencies() {
|
|
// TODO: implement didChangeDependencies
|
|
super.didChangeDependencies();
|
|
|
|
/// 路由订阅
|
|
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// TODO: implement dispose
|
|
/// 取消路由订阅
|
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
|
super.dispose();
|
|
}
|
|
|
|
/// 从上级界面进入 当前界面即将出现
|
|
@override
|
|
void didPush() {
|
|
super.didPush();
|
|
print("lockSet===didPush");
|
|
state.ifCurrentScreen.value = true;
|
|
}
|
|
|
|
/// 返回上一个界面 当前界面即将消失
|
|
@override
|
|
void didPop() {
|
|
super.didPop();
|
|
print("lockSet===didPop");
|
|
logic.cancelBlueConnetctToastTimer();
|
|
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
|
BlueManage().stopScan();
|
|
state.ifCurrentScreen.value = false;
|
|
state.sureBtnState.value = 0;
|
|
}
|
|
|
|
/// 从下级返回 当前界面即将出现
|
|
@override
|
|
void didPopNext() {
|
|
super.didPopNext();
|
|
print("lockSet===didPopNext");
|
|
state.ifCurrentScreen.value = true;
|
|
}
|
|
|
|
/// 进入下级界面 当前界面即将消失
|
|
@override
|
|
void didPushNext() {
|
|
super.didPushNext();
|
|
print("lockSet===didPushNext");
|
|
logic.cancelBlueConnetctToastTimer();
|
|
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
|
BlueManage().stopScan();
|
|
state.ifCurrentScreen.value = false;
|
|
state.sureBtnState.value = 0;
|
|
}
|
|
}
|