魏少阳 8381506bdd Merge branch 'release' of https://gitee.com/starlock-cn/app-starlock into release
# Conflicts:
#	lib/login/register/starLock_register_logic.dart
#	lib/login/register/starLock_register_page.dart
#	lib/login/register/starLock_register_state.dart
#	lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart
#	lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart
#	lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart
2024-06-03 14:00:23 +08:00

303 lines
12 KiB
Dart
Executable File

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.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 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_state.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/appRouteObserver.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/dateTool.dart';
import '../../../../tools/showTipView.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 FaceDetailLogic logic = Get.put(FaceDetailLogic());
final FaceDetailState state = Get.find<FaceDetailLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: '人脸详情',
haveBack: true,
backgroundColor: AppColors.mainColor,
),
body: ListView(
children: <Widget>[
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);
ShowTipView().showTFViewAlertDialog(
state.changeNameController,
'${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}',
'', () {
if (state.changeNameController.text.isEmpty) {
logic.showToast('请输入姓名'.tr);
return;
}
Get.back();
state.typeName.value = state.changeNameController.text;
logic.updateFaceNameData();
}, inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(50),
]);
})),
Obx(() => Visibility(
visible: state.keyType.value == 4 ||
state.keyType.value == 2 ||
state.keyType.value == 1,
child: CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
allHeight: 70.h,
// rightTitle:"2023.09.19 11:27\n2023.09.25 11:27",
rightTitle: logic.getKeyTypeShowDateTime(),
isHaveDirection: true,
isHaveLine: true,
action: () async {
if (state.keyType.value == 2 || state.keyType.value == 1) {
// 限时
var data = await Get.toNamed(
Routers.otherTypeKeyChangeDatePage,
arguments: <String, Object>{
'pushType': 3,
'fingerprintItemData': state.faceItemData.value,
});
if (data != null) {
setState(() {
state.startDate.value = data['beginTimeTimestamp'];
state.endDate.value = data['endTimeTimestamp'];
state.keyType.value = 2;
});
}
} else if (state.keyType.value == 4) {
// 循环
var data = await Get.toNamed(
Routers.otherTypeKeyChangeValidityDatePage,
arguments: <String, Object>{
'pushType': 3,
'fingerprintItemData': state.faceItemData.value,
});
if (data != null) {
setState(() {
state.startDate.value = data['starDate'];
state.endDate.value = data['endDate'];
state.startTime.value = data['starTime'];
state.endTime.value = data['endTime'];
state.weekDay.value = data['validityValue'];
});
}
}
}))),
Obx(() => Visibility(
visible: state.keyType.value == 4,
child: Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr,
rightTitle: logic.weekDayStr.join(','),
isHaveDirection: true,
isHaveLine: true,
action: () async {
var data = await Get.toNamed(
Routers.otherTypeKeyChangeValidityDatePage,
arguments: <String, Object>{
'pushType': 3,
'fingerprintItemData': state.faceItemData.value,
});
if (data != null) {
setState(() {
state.startDate.value = data['starDate'];
state.endDate.value = data['endDate'];
state.startTime.value = data['starTime'];
state.endTime.value = data['endTime'];
state.weekDay.value = data['validityValue'];
});
}
})))),
Obx(() => Visibility(
visible: state.keyType.value == 4,
child: Obx(() => CommonItem(
leftTitel: '有效时间',
rightTitle:
'${DateTool().dateToHNString(state.startTime.value)}-${DateTool().dateToHNString(state.endTime.value)}',
isHaveDirection: true,
action: () async {
var data = await Get.toNamed(
Routers.otherTypeKeyChangeValidityDatePage,
arguments: <String, Object>{
'pushType': 3,
'fingerprintItemData': state.faceItemData.value,
});
if (data != null) {
setState(() {
state.startDate.value = data['starDate'];
state.endDate.value = data['endDate'];
state.startTime.value = data['starTime'];
state.endTime.value = data['endTime'];
state.weekDay.value = data['validityValue'];
});
}
})))),
Container(height: 10.h),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.additive!.tr,
rightTitle: state.adder.value,
)),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.addTime!.tr,
rightTitle: DateTool()
.dateToYMDHNString(state.addTime.value.toString()),
)),
SizedBox(height: 10.h),
// Obx(() => CommonItem(
// leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
// rightTitle: "",
// isTipsImg: false,
// isHaveRightWidget: true,
// isHaveLine: true,
// rightWidget: SizedBox(width: 60.w, height: 50.h, child: _isStressFace()))),
Obx(() => CommonItem(
leftTitel: '是否为管理员'.tr,
rightTitle: '',
isTipsImg: false,
isHaveRightWidget: true,
rightWidget:
SizedBox(width: 60.w, height: 50.h, child: _isAdmin()))),
Container(height: 10.h),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.operatingRecord!.tr,
rightTitle: '',
isHaveDirection: true,
action: () {
Get.toNamed(Routers.lockOperatingRecordPage, arguments: <String, Object?>{
'type': 4,
'id': state.faceItemData.value.faceId.toString(),
'recordName': state.faceItemData.value.faceName
});
}),
// 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: () {
ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr,
() async {
state.isDeletFace.value = true;
logic.senderAddFace();
});
}),
],
),
);
}
CupertinoSwitch _isStressFace() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isStressFace.value,
onChanged: (bool value) {
setState(() {
state.isStressFace.value = value;
state.isDeletFace.value = false;
logic.senderAddFace();
});
},
);
}
// 是否为管理员
CupertinoSwitch _isAdmin() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isAdministrator.value,
onChanged: (bool value) {
// state.isAdministrator.value = value;
// state.isDeletFace.value = false;
// logic.senderAddFace();
},
);
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
/// 路由订阅
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
}
@override
void dispose() {
/// 取消路由订阅
AppRouteObserver().routeObserver.unsubscribe(this);
super.dispose();
}
/// 从上级界面进入 当前界面即将出现
@override
void didPush() {
super.didPush();
state.ifCurrentScreen.value = true;
}
/// 返回上一个界面 当前界面即将消失
@override
void didPop() {
super.didPop();
logic.cancelBlueConnetctToastTimer();
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
state.ifCurrentScreen.value = false;
state.sureBtnState.value = 0;
}
/// 从下级返回 当前界面即将出现
@override
void didPopNext() {
super.didPopNext();
state.ifCurrentScreen.value = true;
}
/// 进入下级界面 当前界面即将消失
@override
void didPushNext() {
super.didPushNext();
logic.cancelBlueConnetctToastTimer();
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
state.ifCurrentScreen.value = false;
state.sureBtnState.value = 0;
}
}