1,新增设置面容开锁接口对接
2,新增设置面容感应距离接口对接 3,新增设置面容防误开接口对接 4,新增设置面容自动亮屏接口对接
This commit is contained in:
parent
4cd6e49564
commit
28554dd0e4
@ -51,9 +51,6 @@ class VideoSlotLogic extends BaseGetXController {
|
|||||||
.add(const Duration(days: 1));
|
.add(const Duration(days: 1));
|
||||||
// 获取明天时间的时间戳
|
// 获取明天时间的时间戳
|
||||||
state.recordEndTime.value = tomorrow.millisecondsSinceEpoch;
|
state.recordEndTime.value = tomorrow.millisecondsSinceEpoch;
|
||||||
|
|
||||||
// state.recordEndTime.value =
|
|
||||||
// DateTool().dateToTimestamp(state.endDate.value, 0);
|
|
||||||
}
|
}
|
||||||
var entity = await ApiRepository.to.updateCatEyeModeConfig(
|
var entity = await ApiRepository.to.updateCatEyeModeConfig(
|
||||||
lockId: state.lockSetInfoData.value.lockId!,
|
lockId: state.lockSetInfoData.value.lockId!,
|
||||||
|
|||||||
@ -1,6 +1,73 @@
|
|||||||
import 'package:star_lock/main/lockDetail/lockSet/faceUnlock/faceUnlock_state.dart';
|
import 'package:star_lock/main/lockDetail/lockSet/faceUnlock/faceUnlock_state.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
||||||
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
class FaceUnlockLogic extends BaseGetXController {
|
class FaceUnlockLogic extends BaseGetXController {
|
||||||
final FaceUnlockState state = FaceUnlockState();
|
final FaceUnlockState state = FaceUnlockState();
|
||||||
|
|
||||||
|
// 获取锁设置信息
|
||||||
|
Future<LockSetInfoEntity> getLockSettingInfoData() async {
|
||||||
|
LockSetInfoEntity entity = await ApiRepository.to.getLockSettingInfoData(
|
||||||
|
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||||
|
);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
state.lockSetInfoData.value = entity.data!;
|
||||||
|
state.faceOn.value =
|
||||||
|
entity.data!.lockSettingInfo!.faceSwitch == 0 ? false : true;
|
||||||
|
state.autoBright.value =
|
||||||
|
entity.data!.lockSettingInfo!.faceAutoLightScreen == 0 ? false : true;
|
||||||
|
state.senseDistance.value =
|
||||||
|
entity.data!.lockSettingInfo!.faceInductionDistance! == 0
|
||||||
|
? '远距离'
|
||||||
|
: '近距离';
|
||||||
|
state.antiMisoperation.value =
|
||||||
|
entity.data!.lockSettingInfo!.faceAntiMistakeOpen!;
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置面容开锁开关
|
||||||
|
void updateFaceSwitch() async {
|
||||||
|
var entity = await ApiRepository.to.updateFaceSwitch(
|
||||||
|
lockId: state.lockSetInfoData.value.lockId ?? 0,
|
||||||
|
faceSwitch: state.faceOn.value == false ? 0 : 1,
|
||||||
|
);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
showToast('设置成功');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置自动亮屏开关
|
||||||
|
void updateFaceConfig() async {
|
||||||
|
var entity = await ApiRepository.to.updateFaceAutoLightScreen(
|
||||||
|
lockId: state.lockSetInfoData.value.lockId ?? 0,
|
||||||
|
faceAutoLightScreen: state.autoBright.value == false ? 0 : 1,
|
||||||
|
);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
showToast('设置成功');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置面容感应距离
|
||||||
|
void updateFaceSenseDistance() async {
|
||||||
|
var entity = await ApiRepository.to.updateFaceSenseDistance(
|
||||||
|
lockId: state.lockSetInfoData.value.lockId ?? 0,
|
||||||
|
faceInductionDistance: state.senseDistance.value == '远距离' ? 0 : 1,
|
||||||
|
);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
showToast('设置成功');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置面容防误开
|
||||||
|
void updateFacePreventMisrun() async {
|
||||||
|
var entity = await ApiRepository.to.updateFacePreventMisrun(
|
||||||
|
lockId: state.lockSetInfoData.value.lockId ?? 0,
|
||||||
|
faceAntiMistakeOpen: state.antiMisoperation.value,
|
||||||
|
);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
showToast('设置成功');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,12 @@ class _FaceUnlockPageState extends State<FaceUnlockPage> {
|
|||||||
final logic = Get.put(FaceUnlockLogic());
|
final logic = Get.put(FaceUnlockLogic());
|
||||||
final state = Get.find<FaceUnlockLogic>().state;
|
final state = Get.find<FaceUnlockLogic>().state;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
logic.getLockSettingInfoData();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -29,45 +35,57 @@ class _FaceUnlockPageState extends State<FaceUnlockPage> {
|
|||||||
barTitle: TranslationLoader.lanKeys!.faceUnlocksSet!.tr,
|
barTitle: TranslationLoader.lanKeys!.faceUnlocksSet!.tr,
|
||||||
haveBack: true,
|
haveBack: true,
|
||||||
backgroundColor: AppColors.mainColor),
|
backgroundColor: AppColors.mainColor),
|
||||||
body: Column(
|
body: Obx(() => Column(
|
||||||
children: [
|
children: [
|
||||||
CommonItem(
|
Container(
|
||||||
leftTitel: TranslationLoader.lanKeys!.faceUnlocks!.tr,
|
margin: EdgeInsets.only(left: 20.w),
|
||||||
rightTitle: "",
|
child: CommonItem(
|
||||||
allHeight: 70.h,
|
leftTitel: TranslationLoader.lanKeys!.faceUnlocks!.tr,
|
||||||
isHaveLine: true,
|
rightTitle: "",
|
||||||
isHaveRightWidget: true,
|
allHeight: 70.h,
|
||||||
rightWidget:
|
isHaveLine: true,
|
||||||
SizedBox(width: 60.w, height: 50.h, child: _switch(1))),
|
isHaveRightWidget: true,
|
||||||
CommonItem(
|
rightWidget: SizedBox(
|
||||||
leftTitel: TranslationLoader.lanKeys!.automaticBrighteningScreen!.tr,
|
width: 60.w, height: 50.h, child: _switch(1))),
|
||||||
rightTitle: "",
|
),
|
||||||
isHaveLine: true,
|
Container(
|
||||||
isHaveRightWidget: true,
|
margin: EdgeInsets.only(left: 20.w),
|
||||||
rightWidget:
|
child: CommonItem(
|
||||||
SizedBox(width: 60.w, height: 50.h, child: _switch(2))),
|
leftTitel: TranslationLoader
|
||||||
_buildSubTitleItem(
|
.lanKeys!.automaticBrighteningScreen!.tr,
|
||||||
TranslationLoader.lanKeys!.sensingDistance!.tr, TranslationLoader.lanKeys!.sensingDistanceTip!.tr, state.senseDistance.value,
|
rightTitle: "",
|
||||||
() {
|
isHaveLine: true,
|
||||||
_openBottomItemSheet(state.senseDistanceList.value, 0);
|
isHaveRightWidget: true,
|
||||||
}),
|
rightWidget: SizedBox(
|
||||||
SizedBox(
|
width: 60.w, height: 50.h, child: _switch(2))),
|
||||||
height: 30.h,
|
),
|
||||||
),
|
_buildSubTitleItem(
|
||||||
_buildSubTitleItem(
|
TranslationLoader.lanKeys!.sensingDistance!.tr,
|
||||||
TranslationLoader.lanKeys!.preventWrongOpening!.tr, TranslationLoader.lanKeys!.preventWrongOpeningTip!.tr, state.antiMisoperation.value, () {
|
TranslationLoader.lanKeys!.sensingDistanceTip!.tr,
|
||||||
_openBottomItemSheet(state.antiMisoperationList.value, 1);
|
state.senseDistance.value, () {
|
||||||
}),
|
_openBottomItemSheet(state.senseDistanceList.value, 0);
|
||||||
Expanded(
|
}),
|
||||||
child: SizedBox(
|
SizedBox(
|
||||||
height: 30.h,
|
height: 30.h,
|
||||||
)),
|
),
|
||||||
_buildTipsView(),
|
_buildSubTitleItem(
|
||||||
SizedBox(
|
TranslationLoader.lanKeys!.preventWrongOpening!.tr,
|
||||||
height: 60.h,
|
TranslationLoader.lanKeys!.preventWrongOpeningTip!.tr,
|
||||||
)
|
state.antiMisoperation.value == 0
|
||||||
],
|
? '关闭'
|
||||||
));
|
: '${state.antiMisoperation.value}秒', () {
|
||||||
|
_openBottomItemSheet(state.antiMisoperationStrList.value, 1);
|
||||||
|
}),
|
||||||
|
Expanded(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 30.h,
|
||||||
|
)),
|
||||||
|
_buildTipsView(),
|
||||||
|
SizedBox(
|
||||||
|
height: 60.h,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSubTitleItem(
|
Widget _buildSubTitleItem(
|
||||||
@ -76,6 +94,7 @@ class _FaceUnlockPageState extends State<FaceUnlockPage> {
|
|||||||
onTap: action,
|
onTap: action,
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.only(left: 20.sp, right: 20.sp, top: 20.h),
|
margin: EdgeInsets.only(left: 20.sp, right: 20.sp, top: 20.h),
|
||||||
|
color: Colors.white,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -152,19 +171,20 @@ class _FaceUnlockPageState extends State<FaceUnlockPage> {
|
|||||||
thumbColor: CupertinoColors.white,
|
thumbColor: CupertinoColors.white,
|
||||||
value: getIndex == 1 ? state.faceOn.value : state.autoBright.value,
|
value: getIndex == 1 ? state.faceOn.value : state.autoBright.value,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
if (getIndex == 1) {
|
||||||
if (getIndex == 1) {
|
//设置面容开锁开关
|
||||||
state.faceOn.value = value;
|
state.faceOn.value = value;
|
||||||
} else {
|
logic.updateFaceSwitch();
|
||||||
state.autoBright.value = value;
|
} else {
|
||||||
}
|
//设置自动亮屏开关
|
||||||
});
|
state.autoBright.value = value;
|
||||||
|
logic.updateFaceConfig();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _openBottomItemSheet(
|
Future _openBottomItemSheet(List bottomItemList, int clickIndex) async {
|
||||||
List<String> bottomItemList, int clickIndex) async {
|
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
@ -178,13 +198,13 @@ class _FaceUnlockPageState extends State<FaceUnlockPage> {
|
|||||||
//感应距离
|
//感应距离
|
||||||
state.senseDistance.value =
|
state.senseDistance.value =
|
||||||
state.senseDistanceList.value[value];
|
state.senseDistanceList.value[value];
|
||||||
|
logic.updateFaceSenseDistance();
|
||||||
} else if (clickIndex == 1) {
|
} else if (clickIndex == 1) {
|
||||||
//防误开
|
//防误开
|
||||||
state.antiMisoperation.value =
|
state.antiMisoperation.value =
|
||||||
state.antiMisoperationList.value[value];
|
state.antiMisoperationList.value[value];
|
||||||
|
logic.updateFacePreventMisrun();
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {});
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,20 +1,32 @@
|
|||||||
import 'dart:ui';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/app_settings/app_colors.dart';
|
import 'package:star_lock/app_settings/app_colors.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
||||||
|
|
||||||
import '../../../../translations/trans_lib.dart';
|
import '../../../../translations/trans_lib.dart';
|
||||||
|
|
||||||
class FaceUnlockState {
|
class FaceUnlockState {
|
||||||
|
var lockSetInfoData = LockSetInfoData().obs;
|
||||||
|
|
||||||
var isCheck = false.obs;
|
var isCheck = false.obs;
|
||||||
var faceOn = false.obs; //面容开锁
|
var faceOn = false.obs; //面容开锁
|
||||||
var autoBright = false.obs; //自动亮屏
|
var autoBright = false.obs; //自动亮屏
|
||||||
var senseDistance = TranslationLoader.lanKeys!.remote!.tr.obs; //感应距离
|
var senseDistance = TranslationLoader.lanKeys!.remote!.tr.obs; //感应距离
|
||||||
var antiMisoperation = TranslationLoader.lanKeys!.close!.tr.obs; //防误开
|
var antiMisoperation = 0.obs; //防误开
|
||||||
var senseDistanceList = [TranslationLoader.lanKeys!.remote!.tr, TranslationLoader.lanKeys!.closeRange!.tr].obs;
|
var senseDistanceList = [
|
||||||
var antiMisoperationList = [TranslationLoader.lanKeys!.close!.tr, '5${TranslationLoader.lanKeys!.second!.tr}', '10${TranslationLoader.lanKeys!.second!.tr}', '15${TranslationLoader.lanKeys!.second!.tr}', '30${TranslationLoader.lanKeys!.second!.tr}', '60${TranslationLoader.lanKeys!.second!.tr}'].obs;
|
TranslationLoader.lanKeys!.remote!.tr,
|
||||||
|
TranslationLoader.lanKeys!.closeRange!.tr
|
||||||
|
].obs;
|
||||||
|
var antiMisoperationList = [0, 5, 10, 15, 30, 60].obs;
|
||||||
|
var antiMisoperationStrList = [
|
||||||
|
TranslationLoader.lanKeys!.close!.tr,
|
||||||
|
'5${TranslationLoader.lanKeys!.second!.tr}',
|
||||||
|
'10${TranslationLoader.lanKeys!.second!.tr}',
|
||||||
|
'15${TranslationLoader.lanKeys!.second!.tr}',
|
||||||
|
'30${TranslationLoader.lanKeys!.second!.tr}',
|
||||||
|
'60${TranslationLoader.lanKeys!.second!.tr}'
|
||||||
|
].obs;
|
||||||
//高亮样式
|
//高亮样式
|
||||||
final TextStyle titleStyle = TextStyle(
|
final TextStyle titleStyle = TextStyle(
|
||||||
color: Colors.black, fontSize: 24.sp, fontWeight: FontWeight.w500);
|
color: Colors.black, fontSize: 24.sp, fontWeight: FontWeight.w500);
|
||||||
@ -23,9 +35,18 @@ class FaceUnlockState {
|
|||||||
TextStyle(color: AppColors.placeholderTextColor, fontSize: 22.sp);
|
TextStyle(color: AppColors.placeholderTextColor, fontSize: 22.sp);
|
||||||
|
|
||||||
late InlineSpan tipsPreviewSpan = TextSpan(children: [
|
late InlineSpan tipsPreviewSpan = TextSpan(children: [
|
||||||
TextSpan(text: '${TranslationLoader.lanKeys!.addAndUseFaceWhenUnlocking!.tr}:\n', style: titleStyle),
|
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text:TranslationLoader.lanKeys!.addAndUseFaceWhenUnlockingTip!.tr,
|
text: '${TranslationLoader.lanKeys!.addAndUseFaceWhenUnlocking!.tr}:\n',
|
||||||
|
style: titleStyle),
|
||||||
|
TextSpan(
|
||||||
|
text: TranslationLoader.lanKeys!.addAndUseFaceWhenUnlockingTip!.tr,
|
||||||
style: subTipsStyle),
|
style: subTipsStyle),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
FaceUnlockState() {
|
||||||
|
Map map = Get.arguments;
|
||||||
|
if (map['lockSetInfoData'] != null) {
|
||||||
|
lockSetInfoData.value = map['lockSetInfoData'];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -357,7 +357,9 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
action: () {
|
action: () {
|
||||||
Get.toNamed(Routers.faceUnlockPage);
|
Get.toNamed(Routers.faceUnlockPage, arguments: {
|
||||||
|
'lockSetInfoData': state.lockSetInfoData.value
|
||||||
|
});
|
||||||
})),
|
})),
|
||||||
// ),
|
// ),
|
||||||
// 消息提醒
|
// 消息提醒
|
||||||
|
|||||||
@ -1718,8 +1718,9 @@ class ApiProvider extends BaseProvider {
|
|||||||
'faceSwitch': faceSwitch,
|
'faceSwitch': faceSwitch,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// 设置面容开锁
|
// 设置面容感应距离
|
||||||
Future<Response> updateFaceConfig(int lockId, int faceInductionDistance) =>
|
Future<Response> updateFaceSenseDistance(
|
||||||
|
int lockId, int faceInductionDistance) =>
|
||||||
post(
|
post(
|
||||||
updateFaceConfigURL.toUrl,
|
updateFaceConfigURL.toUrl,
|
||||||
jsonEncode({
|
jsonEncode({
|
||||||
|
|||||||
@ -1757,10 +1757,10 @@ class ApiRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置面容感应距离
|
// 设置面容感应距离
|
||||||
Future<VersionUndateEntity> updateFaceConfig(
|
Future<VersionUndateEntity> updateFaceSenseDistance(
|
||||||
{required int lockId, required int faceInductionDistance}) async {
|
{required int lockId, required int faceInductionDistance}) async {
|
||||||
final res =
|
final res = await apiProvider.updateFaceSenseDistance(
|
||||||
await apiProvider.updateFaceConfig(lockId, faceInductionDistance);
|
lockId, faceInductionDistance);
|
||||||
return VersionUndateEntity.fromJson(res.body);
|
return VersionUndateEntity.fromJson(res.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user