fix:完善猫眼设置

This commit is contained in:
liyi 2025-02-27 18:51:10 +08:00
parent 86854e8f3f
commit 681b96a478
5 changed files with 138 additions and 22 deletions

View File

@ -783,18 +783,6 @@ class LockDetailLogic extends BaseGetXController {
await PermissionDialog.request(Permission.location); await PermissionDialog.request(Permission.location);
await PermissionDialog.requestBluetooth(); await PermissionDialog.requestBluetooth();
_requestDeviceNetworkInfo(); _requestDeviceNetworkInfo();
eventBus
.on<PassCurrentLockInformationEvent>()
.listen((PassCurrentLockInformationEvent event) {
if (event.lockSetInfoData.lockSettingInfo != null &&
event.lockSetInfoData.lockSettingInfo!.catEyeConfig != null &&
event.lockSetInfoData.lockSettingInfo!.catEyeConfig!.length > 0) {
state.keyInfos.value.lockSetting!.catEyeConfig![0].catEyeMode = event
.lockSetInfoData.lockSettingInfo!.catEyeConfig![0].catEyeMode ??
1;
state.keyInfos.refresh();
}
});
} }
@override @override
@ -820,5 +808,30 @@ class LockDetailLogic extends BaseGetXController {
state.keyInfos.refresh(); state.keyInfos.refresh();
} }
}); });
eventBus
.on<PassCurrentLockInformationEvent>()
.listen((PassCurrentLockInformationEvent event) {
if (event.lockSetInfoData.lockSettingInfo != null &&
event.lockSetInfoData.lockSettingInfo!.catEyeConfig != null &&
event.lockSetInfoData.lockSettingInfo!.catEyeConfig!.length > 0) {
if (state.keyInfos.value.lockSetting!.catEyeConfig == null ||
state.keyInfos.value.lockSetting!.catEyeConfig!.length == 0) {
state.keyInfos.value.lockSetting!.catEyeConfig!.add(CatEyeConfig(
catEyeMode: 0,
catEyeModeConfig: CatEyeModeConfig(
realTimeMode: 0,
recordEndTime: 0,
recordMode: 0,
recordStartTime: 0,
recordTime: 0,
detectionDistance: 0)));
}
state.keyInfos.value.lockSetting!.catEyeConfig![0].catEyeMode = event
.lockSetInfoData.lockSettingInfo!.catEyeConfig![0].catEyeMode ??
1;
state.keyInfos.refresh();
}
});
} }
} }

View File

@ -91,7 +91,15 @@ class CatEyeCustomModeLogic extends BaseGetXController {
0 0
? '发生事件时查看'.tr ? '发生事件时查看'.tr
: '实时查看'.tr; : '实时查看'.tr;
if (event.lockSetInfoData.lockSettingInfo!.catEyeConfig![0]
.catEyeModeConfig!.recordMode ==
0) {
state.selectVideoSlot.value = '自定义时段'.tr;
} else {
state.selectVideoSlot.value = '全天'.tr;
}
state.realTimeMode.refresh(); state.realTimeMode.refresh();
} }
}); });
} }

View File

@ -25,6 +25,34 @@ class CatEyeSetLogic extends BaseGetXController {
void onInit() { void onInit() {
super.onInit(); super.onInit();
_initReplySubscription(); _initReplySubscription();
eventBus
.on<PassCurrentLockInformationEvent>()
.listen((PassCurrentLockInformationEvent event) {
state.selectCatEyeWorkMode.value = ''; //
if (event.lockSetInfoData.lockSettingInfo != null &&
event.lockSetInfoData.lockSettingInfo!.catEyeConfig != null &&
event.lockSetInfoData.lockSettingInfo!.catEyeConfig!.length > 0) {
if (event
.lockSetInfoData.lockSettingInfo!.catEyeConfig![0].catEyeMode ==
XSConstantMacro.catEyeWorkModePowerSaving) {
state.selectCatEyeWorkMode.value = '省电模式'.tr;
} else if (event
.lockSetInfoData.lockSettingInfo!.catEyeConfig![0].catEyeMode ==
XSConstantMacro.catEyeWorkModeStayCapture) {
state.selectCatEyeWorkMode.value = '逗留抓拍模式'.tr;
} else if (event
.lockSetInfoData.lockSettingInfo!.catEyeConfig![0].catEyeMode ==
XSConstantMacro.catEyeWorkModeRealTimeMonitoring) {
state.selectCatEyeWorkMode.value = '实时监控模式'.tr;
} else if (event
.lockSetInfoData.lockSettingInfo!.catEyeConfig![0].catEyeMode ==
XSConstantMacro.catEyeWorkModeCustom) {
state.selectCatEyeWorkMode.value = '自定义模式'.tr;
}
}
state.updateCatEyeSetByState();
});
} }
// //
@ -83,13 +111,13 @@ class CatEyeSetLogic extends BaseGetXController {
default: default:
break; break;
} }
getLockSettingInfoData();
break; break;
case 0x06: case 0x06:
// //
showToast('无权限');
break; break;
default: default:
showToast('修改失败');
break; break;
} }
} }
@ -102,10 +130,9 @@ class CatEyeSetLogic extends BaseGetXController {
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.lockSetInfoData.value = entity.data!; state.lockSetInfoData.value = entity.data!;
eventBus eventBus
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); .fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
//
state.selectCatEyeWorkMode.value = ''; // state.selectCatEyeWorkMode.value = ''; //
if (state.lockSetInfoData.value.lockSettingInfo != null && if (state.lockSetInfoData.value.lockSettingInfo != null &&
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig != null && state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig != null &&
@ -130,7 +157,6 @@ class CatEyeSetLogic extends BaseGetXController {
} }
} }
state.updateCatEyeSetByState(); state.updateCatEyeSetByState();
} }
} }
@ -145,6 +171,10 @@ class CatEyeSetLogic extends BaseGetXController {
showToast(state.settingSuccess); showToast(state.settingSuccess);
state.catEyeConfig.value.autoLightScreen = state.catEyeConfig.value.autoLightScreen =
state.isAutoBright.value == true ? 1 : 0; state.isAutoBright.value == true ? 1 : 0;
state.lockSetInfoData.value.lockSettingInfo!.autoLightScreen =
state.isAutoBright.value == true ? 1 : 0;
eventBus
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
state.catEyeConfig.refresh(); state.catEyeConfig.refresh();
} }
} }
@ -161,6 +191,10 @@ class CatEyeSetLogic extends BaseGetXController {
showToast(state.settingSuccess); showToast(state.settingSuccess);
state.catEyeConfig.value.autoLightScreenTime = state.catEyeConfig.value.autoLightScreenTime =
int.parse(state.selectBrightDuration.value.replaceAll(''.tr, '')); int.parse(state.selectBrightDuration.value.replaceAll(''.tr, ''));
state.lockSetInfoData.value.lockSettingInfo!.autoLightScreenTime =
int.parse(state.selectBrightDuration.value.replaceAll(''.tr, ''));
eventBus
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
state.catEyeConfig.refresh(); state.catEyeConfig.refresh();
} }
} }
@ -176,6 +210,10 @@ class CatEyeSetLogic extends BaseGetXController {
showToast(state.settingSuccess); showToast(state.settingSuccess);
state.catEyeConfig.value.stayWarn = state.catEyeConfig.value.stayWarn =
state.isStayWarning.value == true ? 1 : 0; state.isStayWarning.value == true ? 1 : 0;
state.lockSetInfoData.value.lockSettingInfo!.stayWarn =
state.isStayWarning.value == true ? 1 : 0;
eventBus
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
state.catEyeConfig.refresh(); state.catEyeConfig.refresh();
} }
} }
@ -200,7 +238,57 @@ class CatEyeSetLogic extends BaseGetXController {
], ],
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast('设置成功'.tr); if (state.lockSetInfoData.value.lockSettingInfo != null &&
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig != null &&
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig!.length ==
0) {
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig!.add(
CatEyeConfig(
catEyeMode: 0,
catEyeModeConfig: CatEyeModeConfig(
realTimeMode: 0,
recordEndTime: 0,
recordMode: 0,
recordStartTime: 0,
recordTime: 0,
detectionDistance: 0)));
}
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig![0].catEyeMode =
state.catEyeConfig.value.catEyeMode;
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig![0]
.catEyeModeConfig?.recordMode = state.catEyeConfig.value.recordMode;
state
.lockSetInfoData
.value
.lockSettingInfo!
.catEyeConfig![0]
.catEyeModeConfig
?.recordStartTime = state.catEyeConfig.value.recordStartTime;
state
.lockSetInfoData
.value
.lockSettingInfo!
.catEyeConfig![0]
.catEyeModeConfig
?.recordEndTime = state.catEyeConfig.value.recordEndTime;
state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig![0]
.catEyeModeConfig?.recordTime = state.catEyeConfig.value.recordTime;
state
.lockSetInfoData
.value
.lockSettingInfo!
.catEyeConfig![0]
.catEyeModeConfig
?.detectionDistance = state.catEyeConfig.value.detectionDistance;
state
.lockSetInfoData
.value
.lockSettingInfo!
.catEyeConfig![0]
.catEyeModeConfig
?.realTimeMode = state.catEyeConfig.value.realTimeMode;
eventBus
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
} }
} }
@ -215,6 +303,10 @@ class CatEyeSetLogic extends BaseGetXController {
showToast(state.settingSuccess); showToast(state.settingSuccess);
state.catEyeConfig.value.abnormalWarn = state.catEyeConfig.value.abnormalWarn =
state.isExceptionWarning.value == true ? 1 : 0; state.isExceptionWarning.value == true ? 1 : 0;
state.lockSetInfoData.value.lockSettingInfo!.abnormalWarn =
state.isExceptionWarning.value == true ? 1 : 0;
eventBus
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
state.catEyeConfig.refresh(); state.catEyeConfig.refresh();
// await getLockSettingInfoData(); // await getLockSettingInfoData();
} }

View File

@ -17,6 +17,7 @@ import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dar
import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/talk/starChart/star_chart_manage.dart'; import 'package:star_lock/talk/starChart/star_chart_manage.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/versionUndate/versionUndate_entity.dart'; import 'package:star_lock/versionUndate/versionUndate_entity.dart';

View File

@ -11,6 +11,7 @@ import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/talk/starChart/star_chart_manage.dart'; import 'package:star_lock/talk/starChart/star_chart_manage.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/dateTool.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/versionUndate/versionUndate_entity.dart'; import 'package:star_lock/versionUndate/versionUndate_entity.dart';
@ -73,14 +74,15 @@ class VideoSlotLogic extends BaseGetXController {
@override @override
void onInit() { void onInit() {
// TODO: implement onInit
super.onInit(); super.onInit();
state.isCustom.value = catEyeSetState.catEyeConfig.value.recordMode == 0; state.isCustom.value = catEyeSetState.catEyeConfig.value.recordMode == 0;
state.startDate.value = _handleMinutesToTime( state.startDate.value = _handleMinutesToTime(
catEyeSetState.catEyeConfig.value.recordStartTime!); catEyeSetState.catEyeConfig.value.recordStartTime!);
state.endDate.value = _handleMinutesToTime( state.endDate.value =
catEyeSetState.catEyeConfig.value.recordEndTime!); _handleMinutesToTime(catEyeSetState.catEyeConfig.value.recordEndTime!);
} }
String _handleMinutesToTime(int minutes) { String _handleMinutesToTime(int minutes) {
if (minutes < 0) { if (minutes < 0) {
throw ArgumentError("分钟数不能为负值"); throw ArgumentError("分钟数不能为负值");
@ -88,7 +90,7 @@ class VideoSlotLogic extends BaseGetXController {
// //
int hours = minutes ~/ 60; // 60 int hours = minutes ~/ 60; // 60
int mins = minutes % 60; // int mins = minutes % 60; //
// HH:mm // HH:mm
return "${hours.toString().padLeft(2, '0')}:${mins.toString().padLeft(2, '0')}"; return "${hours.toString().padLeft(2, '0')}:${mins.toString().padLeft(2, '0')}";