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));
|
||||
// 获取明天时间的时间戳
|
||||
state.recordEndTime.value = tomorrow.millisecondsSinceEpoch;
|
||||
|
||||
// state.recordEndTime.value =
|
||||
// DateTool().dateToTimestamp(state.endDate.value, 0);
|
||||
}
|
||||
var entity = await ApiRepository.to.updateCatEyeModeConfig(
|
||||
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/lockSet/lockSetInfo_entity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
class FaceUnlockLogic extends BaseGetXController {
|
||||
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 state = Get.find<FaceUnlockLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
logic.getLockSettingInfoData();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -29,45 +35,57 @@ class _FaceUnlockPageState extends State<FaceUnlockPage> {
|
||||
barTitle: TranslationLoader.lanKeys!.faceUnlocksSet!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.faceUnlocks!.tr,
|
||||
rightTitle: "",
|
||||
allHeight: 70.h,
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, height: 50.h, child: _switch(1))),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.automaticBrighteningScreen!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, height: 50.h, child: _switch(2))),
|
||||
_buildSubTitleItem(
|
||||
TranslationLoader.lanKeys!.sensingDistance!.tr, TranslationLoader.lanKeys!.sensingDistanceTip!.tr, state.senseDistance.value,
|
||||
() {
|
||||
_openBottomItemSheet(state.senseDistanceList.value, 0);
|
||||
}),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
_buildSubTitleItem(
|
||||
TranslationLoader.lanKeys!.preventWrongOpening!.tr, TranslationLoader.lanKeys!.preventWrongOpeningTip!.tr, state.antiMisoperation.value, () {
|
||||
_openBottomItemSheet(state.antiMisoperationList.value, 1);
|
||||
}),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 30.h,
|
||||
)),
|
||||
_buildTipsView(),
|
||||
SizedBox(
|
||||
height: 60.h,
|
||||
)
|
||||
],
|
||||
));
|
||||
body: Obx(() => Column(
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 20.w),
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.faceUnlocks!.tr,
|
||||
rightTitle: "",
|
||||
allHeight: 70.h,
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _switch(1))),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 20.w),
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader
|
||||
.lanKeys!.automaticBrighteningScreen!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _switch(2))),
|
||||
),
|
||||
_buildSubTitleItem(
|
||||
TranslationLoader.lanKeys!.sensingDistance!.tr,
|
||||
TranslationLoader.lanKeys!.sensingDistanceTip!.tr,
|
||||
state.senseDistance.value, () {
|
||||
_openBottomItemSheet(state.senseDistanceList.value, 0);
|
||||
}),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
_buildSubTitleItem(
|
||||
TranslationLoader.lanKeys!.preventWrongOpening!.tr,
|
||||
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(
|
||||
@ -76,6 +94,7 @@ class _FaceUnlockPageState extends State<FaceUnlockPage> {
|
||||
onTap: action,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(left: 20.sp, right: 20.sp, top: 20.h),
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
@ -152,19 +171,20 @@ class _FaceUnlockPageState extends State<FaceUnlockPage> {
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: getIndex == 1 ? state.faceOn.value : state.autoBright.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
if (getIndex == 1) {
|
||||
state.faceOn.value = value;
|
||||
} else {
|
||||
state.autoBright.value = value;
|
||||
}
|
||||
});
|
||||
if (getIndex == 1) {
|
||||
//设置面容开锁开关
|
||||
state.faceOn.value = value;
|
||||
logic.updateFaceSwitch();
|
||||
} else {
|
||||
//设置自动亮屏开关
|
||||
state.autoBright.value = value;
|
||||
logic.updateFaceConfig();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future _openBottomItemSheet(
|
||||
List<String> bottomItemList, int clickIndex) async {
|
||||
Future _openBottomItemSheet(List bottomItemList, int clickIndex) async {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
shape: RoundedRectangleBorder(
|
||||
@ -178,13 +198,13 @@ class _FaceUnlockPageState extends State<FaceUnlockPage> {
|
||||
//感应距离
|
||||
state.senseDistance.value =
|
||||
state.senseDistanceList.value[value];
|
||||
logic.updateFaceSenseDistance();
|
||||
} else if (clickIndex == 1) {
|
||||
//防误开
|
||||
state.antiMisoperation.value =
|
||||
state.antiMisoperationList.value[value];
|
||||
logic.updateFacePreventMisrun();
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@ -1,20 +1,32 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.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';
|
||||
|
||||
class FaceUnlockState {
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
|
||||
var isCheck = false.obs;
|
||||
var faceOn = false.obs; //面容开锁
|
||||
var autoBright = false.obs; //自动亮屏
|
||||
var senseDistance = TranslationLoader.lanKeys!.remote!.tr.obs; //感应距离
|
||||
var antiMisoperation = TranslationLoader.lanKeys!.close!.tr.obs; //防误开
|
||||
var senseDistanceList = [TranslationLoader.lanKeys!.remote!.tr, TranslationLoader.lanKeys!.closeRange!.tr].obs;
|
||||
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;
|
||||
var antiMisoperation = 0.obs; //防误开
|
||||
var senseDistanceList = [
|
||||
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(
|
||||
color: Colors.black, fontSize: 24.sp, fontWeight: FontWeight.w500);
|
||||
@ -23,9 +35,18 @@ class FaceUnlockState {
|
||||
TextStyle(color: AppColors.placeholderTextColor, fontSize: 22.sp);
|
||||
|
||||
late InlineSpan tipsPreviewSpan = TextSpan(children: [
|
||||
TextSpan(text: '${TranslationLoader.lanKeys!.addAndUseFaceWhenUnlocking!.tr}:\n', style: titleStyle),
|
||||
TextSpan(
|
||||
text:TranslationLoader.lanKeys!.addAndUseFaceWhenUnlockingTip!.tr,
|
||||
text: '${TranslationLoader.lanKeys!.addAndUseFaceWhenUnlocking!.tr}:\n',
|
||||
style: titleStyle),
|
||||
TextSpan(
|
||||
text: TranslationLoader.lanKeys!.addAndUseFaceWhenUnlockingTip!.tr,
|
||||
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,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.faceUnlockPage);
|
||||
Get.toNamed(Routers.faceUnlockPage, arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value
|
||||
});
|
||||
})),
|
||||
// ),
|
||||
// 消息提醒
|
||||
|
||||
@ -1718,8 +1718,9 @@ class ApiProvider extends BaseProvider {
|
||||
'faceSwitch': faceSwitch,
|
||||
}));
|
||||
|
||||
// 设置面容开锁
|
||||
Future<Response> updateFaceConfig(int lockId, int faceInductionDistance) =>
|
||||
// 设置面容感应距离
|
||||
Future<Response> updateFaceSenseDistance(
|
||||
int lockId, int faceInductionDistance) =>
|
||||
post(
|
||||
updateFaceConfigURL.toUrl,
|
||||
jsonEncode({
|
||||
|
||||
@ -1757,10 +1757,10 @@ class ApiRepository {
|
||||
}
|
||||
|
||||
// 设置面容感应距离
|
||||
Future<VersionUndateEntity> updateFaceConfig(
|
||||
Future<VersionUndateEntity> updateFaceSenseDistance(
|
||||
{required int lockId, required int faceInductionDistance}) async {
|
||||
final res =
|
||||
await apiProvider.updateFaceConfig(lockId, faceInductionDistance);
|
||||
final res = await apiProvider.updateFaceSenseDistance(
|
||||
lockId, faceInductionDistance);
|
||||
return VersionUndateEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user