mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 08:04:53 +00:00
Implement Flush Mounted Presence Sensor Routine Control and change the device type logic
This commit is contained in:
@ -179,7 +179,8 @@ class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> {
|
||||
DeviceType.ThreeGang,
|
||||
DeviceType.OneGang,
|
||||
DeviceType.TwoGang,
|
||||
DeviceType.WH
|
||||
DeviceType.WH,
|
||||
DeviceType.FlushMountedSensor,
|
||||
};
|
||||
|
||||
return devices
|
||||
|
||||
@ -107,6 +107,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
for (var element in tempTasksList) {
|
||||
if (element.code == event.deviceControlModel.code) {
|
||||
var updatedElement = element.copyWith(
|
||||
deviceType: event.deviceType,
|
||||
operationName: event.operation,
|
||||
deviceName: event.deviceName,
|
||||
icon: event.icon,
|
||||
@ -134,6 +135,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
if (element.deviceId == event.deviceControlModel.deviceId &&
|
||||
element.code == event.deviceControlModel.code) {
|
||||
var updatedElement = element.copyWith(
|
||||
deviceType: event.deviceType,
|
||||
operationName: event.operation,
|
||||
deviceName: event.deviceName,
|
||||
icon: event.icon,
|
||||
|
||||
@ -41,7 +41,7 @@ class SmartSceneSelectBloc
|
||||
.read<CreateSceneBloc>();
|
||||
|
||||
createSceneBloc.add(TempHoldSceneTasksEvent(
|
||||
deviceType: '',
|
||||
deviceType:smartSceneEnable!.type ,
|
||||
deviceControlModel: DeviceControlModel(
|
||||
deviceId: smartSceneEnable?.entityId ?? '',
|
||||
code: CreateSceneEnum.smartSceneSelect.name,
|
||||
|
||||
@ -9,6 +9,7 @@ class ACFunctionsHelper {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'AC',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsAcPower,
|
||||
@ -30,6 +31,7 @@ class ACFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'AC',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsFreezing,
|
||||
@ -56,6 +58,7 @@ class ACFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'AC',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsTempreture,
|
||||
@ -72,6 +75,7 @@ class ACFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'AC',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsFanSpeed,
|
||||
@ -103,6 +107,7 @@ class ACFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'AC',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsChildLock,
|
||||
@ -130,6 +135,7 @@ class ACFunctionsHelper {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'AC',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsAcPower,
|
||||
@ -151,6 +157,7 @@ class ACFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'AC',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsFreezing,
|
||||
@ -177,6 +184,7 @@ class ACFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'AC',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsTempreture,
|
||||
@ -196,6 +204,7 @@ class ACFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'AC',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsCurrentTemp,
|
||||
@ -215,6 +224,7 @@ class ACFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'AC',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsFanSpeed,
|
||||
@ -246,6 +256,7 @@ class ACFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'AC',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsChildLock,
|
||||
|
||||
@ -8,6 +8,7 @@ class DoorLockHelperFunctions {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsIconsDoorLock,
|
||||
@ -16,8 +17,10 @@ class DoorLockHelperFunctions {
|
||||
code: 'normal_open_switch',
|
||||
operationDialogType: OperationDialogType.onOff,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||
SceneOperationalValue(icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||
],
|
||||
),
|
||||
];
|
||||
@ -28,6 +31,7 @@ class DoorLockHelperFunctions {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsFingerprintUnlock,
|
||||
@ -47,6 +51,7 @@ class DoorLockHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsPasswordUnlock,
|
||||
@ -66,6 +71,7 @@ class DoorLockHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsCardUnlock,
|
||||
@ -85,6 +91,7 @@ class DoorLockHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsLockAlarm,
|
||||
@ -101,6 +108,7 @@ class DoorLockHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsRemoteUnlockReq,
|
||||
@ -120,6 +128,7 @@ class DoorLockHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsResidualElectricity,
|
||||
@ -139,6 +148,7 @@ class DoorLockHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsDoubleLock,
|
||||
@ -160,6 +170,7 @@ class DoorLockHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsRemoteUnlockViaApp,
|
||||
@ -179,6 +190,7 @@ class DoorLockHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsHijackAlarm,
|
||||
@ -200,6 +212,7 @@ class DoorLockHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsDoorlockNormalOpen,
|
||||
@ -221,6 +234,7 @@ class DoorLockHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsDoorlockNormalOpen,
|
||||
@ -242,6 +256,7 @@ class DoorLockHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'DL',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsTempPasswordUnlock,
|
||||
|
||||
@ -0,0 +1,247 @@
|
||||
import 'package:syncrow_app/features/scene/enum/operation_dialog_type.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
|
||||
class FlushFunctionsHelper {
|
||||
static List<SceneStaticFunction> flushSceneHelperFunctions(
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'NCPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsPresenceState,
|
||||
operationName: 'Presence State',
|
||||
code: 'presence_state',
|
||||
functionValue: functionValue,
|
||||
operationDialogType: OperationDialogType.listOfOptions,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.nobodyTime, description: "None", value: 'none'),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.nobodyTime,
|
||||
description: "Presence",
|
||||
value: 'presence',
|
||||
),
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'NCPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.IlluminanceIcon,
|
||||
operationName: 'Illuminance Value',
|
||||
code: 'illum_value',
|
||||
functionValue: functionValue,
|
||||
operationDialogType: OperationDialogType.integerSteps,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: '',
|
||||
value: 0.0,
|
||||
description: "",
|
||||
minValue: 0.0,
|
||||
maxValue: 2000.0,
|
||||
stepValue: 1.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
static List<SceneStaticFunction> flushAutomationFunctions(
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'NCPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsSensitivityFunction,
|
||||
operationName: 'Sensitivity',
|
||||
code: 'sensitivity',
|
||||
functionValue: functionValue,
|
||||
operationDialogType: OperationDialogType.listOfOptions,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 1,
|
||||
description: 1.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 2,
|
||||
description: 2.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 3,
|
||||
description: 3.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 4,
|
||||
description: 4.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 5,
|
||||
description: 5.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 6,
|
||||
description: 6.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 7,
|
||||
description: 7.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 8,
|
||||
description: 8.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 9,
|
||||
description: 9.toString(),
|
||||
),
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'NCPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.currentDistanceIcon,
|
||||
operationName: 'Min Detection Distance',
|
||||
code: 'near_detection',
|
||||
functionValue: functionValue,
|
||||
operationDialogType: OperationDialogType.integerSteps,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: '',
|
||||
value: 0.0,
|
||||
description: "m",
|
||||
minValue: 0.0,
|
||||
maxValue: 9.5,
|
||||
stepValue: 0.10,
|
||||
),
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'NCPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.currentDistanceIcon,
|
||||
operationName: 'Max Detection Distance',
|
||||
code: 'far_detection',
|
||||
functionValue: functionValue,
|
||||
operationDialogType: OperationDialogType.integerSteps,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: '',
|
||||
value: 0.0,
|
||||
description: "m",
|
||||
minValue: 0.0,
|
||||
maxValue: 9.5,
|
||||
stepValue: 0.10,
|
||||
),
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'NCPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.levelIcon,
|
||||
operationName: 'Trigger Level',
|
||||
code: 'sensi_reduce',
|
||||
functionValue: functionValue,
|
||||
operationDialogType: OperationDialogType.listOfOptions,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 1,
|
||||
description: 1.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 2,
|
||||
description: 2.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 3,
|
||||
description: 3.toString(),
|
||||
),
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'NCPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.indentLevelIcon,
|
||||
operationName: 'Indent Level',
|
||||
code: 'occur_dist_reduce',
|
||||
functionValue: functionValue,
|
||||
operationDialogType: OperationDialogType.listOfOptions,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 1,
|
||||
description: 1.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 2,
|
||||
description: 2.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 3,
|
||||
description: 3.toString(),
|
||||
),
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'NCPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.targetConfirmTimeIcon,
|
||||
operationName: 'Target Confirm Time',
|
||||
code: 'presence_delay',
|
||||
functionValue: functionValue,
|
||||
operationDialogType: OperationDialogType.integerSteps,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: '',
|
||||
value: 0.0,
|
||||
description: "",
|
||||
minValue: 0.0,
|
||||
maxValue: 0.5,
|
||||
stepValue: 0.1,
|
||||
),
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'NCPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.delayIcon,
|
||||
operationName: 'Disappear Delay',
|
||||
code: 'none_delay',
|
||||
functionValue: functionValue,
|
||||
operationDialogType: OperationDialogType.integerSteps,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: '',
|
||||
value: 20.0,
|
||||
description: "",
|
||||
minValue: 20.0,
|
||||
maxValue: 300.0,
|
||||
stepValue: 1.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ class GatewayHelperFunctions {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'GW',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsSwitchAlarmSound,
|
||||
@ -22,6 +23,7 @@ class GatewayHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'GW',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsMasterState,
|
||||
@ -43,6 +45,7 @@ class GatewayHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'GW',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsFactoryReset,
|
||||
|
||||
@ -7,6 +7,7 @@ class HumanPresenceHelperFunctions {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsFarDetection,
|
||||
@ -66,6 +67,7 @@ class HumanPresenceHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsMotionDetection,
|
||||
@ -102,6 +104,7 @@ class HumanPresenceHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsMotionlessDetection,
|
||||
@ -143,6 +146,7 @@ class HumanPresenceHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsIndicator,
|
||||
@ -164,6 +168,7 @@ class HumanPresenceHelperFunctions {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsPresenceState,
|
||||
@ -185,6 +190,7 @@ class HumanPresenceHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsIconsPresenceSensorAssetsDistance,
|
||||
@ -204,6 +210,7 @@ class HumanPresenceHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsIconsPresenceSensorAssetsIlluminanceValue,
|
||||
@ -223,6 +230,7 @@ class HumanPresenceHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsIndicator,
|
||||
@ -238,6 +246,7 @@ class HumanPresenceHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsIconsPresenceSensorAssetsTime,
|
||||
|
||||
@ -7,6 +7,7 @@ class PresenceSensorHelperFunctions {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'CPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsSensitivityFunction,
|
||||
@ -74,6 +75,7 @@ class PresenceSensorHelperFunctions {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'CPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsIconsSensors,
|
||||
@ -100,6 +102,7 @@ class PresenceSensorHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'CPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsSensitivityFunction,
|
||||
@ -119,6 +122,7 @@ class PresenceSensorHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'CPS',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsSelfTestResult,
|
||||
|
||||
@ -7,6 +7,7 @@ class TowGangHelperFunctions {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: '2G',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsAcPower,
|
||||
@ -22,6 +23,7 @@ class TowGangHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: '2G',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsLightCountdown,
|
||||
@ -34,6 +36,7 @@ class TowGangHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: '2G',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsAcPower,
|
||||
@ -49,6 +52,7 @@ class TowGangHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: '2G',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsLightCountdown,
|
||||
@ -67,6 +71,7 @@ class TowGangHelperFunctions {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: '2G',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsAcPower,
|
||||
@ -82,6 +87,7 @@ class TowGangHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: '2G',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsLightCountdown,
|
||||
@ -101,6 +107,7 @@ class TowGangHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: '2G',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsAcPower,
|
||||
@ -116,6 +123,7 @@ class TowGangHelperFunctions {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: '2G',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsLightCountdown,
|
||||
|
||||
@ -7,6 +7,7 @@ class WaterHeaterFunctionsHelper {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WH',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsAcPower,
|
||||
@ -27,6 +28,7 @@ class WaterHeaterFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WH',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsLightCountdown,
|
||||
@ -45,6 +47,7 @@ class WaterHeaterFunctionsHelper {
|
||||
String deviceId, String deviceName, functionValue) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WH',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.refreshStatusIcon,
|
||||
@ -71,6 +74,7 @@ class WaterHeaterFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WH',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsAcPower,
|
||||
@ -86,6 +90,7 @@ class WaterHeaterFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WH',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsLightCountdown,
|
||||
@ -105,6 +110,7 @@ class WaterHeaterFunctionsHelper {
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
deviceType: 'WH',
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsIndicator,
|
||||
|
||||
@ -88,6 +88,7 @@ mixin SceneLogicHelper {
|
||||
final task = actions[index];
|
||||
if (task.deviceId == 'delay') {
|
||||
return CreateSceneAction(
|
||||
productType: task.deviceType,
|
||||
entityId: actions[index].deviceId,
|
||||
actionExecutor: 'delay',
|
||||
executorProperty: CreateSceneExecutorProperty(
|
||||
@ -99,6 +100,7 @@ mixin SceneLogicHelper {
|
||||
}
|
||||
if (task.code == CreateSceneEnum.smartSceneSelect.name) {
|
||||
return CreateSceneAction(
|
||||
productType: task.deviceType,
|
||||
actionType: task.operationName.toLowerCase() == 'automation'
|
||||
? 'automation'
|
||||
: 'scene',
|
||||
@ -107,6 +109,7 @@ mixin SceneLogicHelper {
|
||||
executorProperty: null);
|
||||
}
|
||||
return CreateSceneAction(
|
||||
productType: task.deviceType,
|
||||
entityId: task.deviceId,
|
||||
actionExecutor: 'device_issue',
|
||||
executorProperty: CreateSceneExecutorProperty(
|
||||
@ -119,6 +122,20 @@ mixin SceneLogicHelper {
|
||||
),
|
||||
],
|
||||
);
|
||||
for (var action in createAutomationModel.actions) {
|
||||
if (action.productType == 'NCPS') {
|
||||
if (action.executorProperty!.functionCode == 'near_detection' ||
|
||||
action.executorProperty!.functionCode == 'far_detection') {
|
||||
action.executorProperty!.functionValue =
|
||||
(action.executorProperty!.functionValue * 100).round();
|
||||
} else if (action.executorProperty!.functionCode ==
|
||||
'presence_delay' ||
|
||||
action.executorProperty!.functionCode == 'none_delay') {
|
||||
action.executorProperty!.functionValue =
|
||||
action.executorProperty!.functionValue * 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
sceneBloc.add(CreateSceneWithTasksEvent(
|
||||
createSceneModel: null,
|
||||
updateScene: updateScene,
|
||||
@ -139,6 +156,7 @@ mixin SceneLogicHelper {
|
||||
final task = actions[index];
|
||||
if (task.deviceId == 'delay') {
|
||||
return CreateSceneAction(
|
||||
productType: task.deviceType,
|
||||
entityId: actions[index].deviceId,
|
||||
actionExecutor: 'delay',
|
||||
executorProperty: CreateSceneExecutorProperty(
|
||||
@ -150,11 +168,14 @@ mixin SceneLogicHelper {
|
||||
}
|
||||
if (task.code == CreateSceneEnum.smartSceneSelect.name) {
|
||||
return CreateSceneAction(
|
||||
productType: task.deviceType,
|
||||
entityId: actions[index].deviceId,
|
||||
actionExecutor: actions[index].functionValue,
|
||||
executorProperty: null);
|
||||
}
|
||||
|
||||
return CreateSceneAction(
|
||||
productType: task.deviceType,
|
||||
entityId: task.deviceId,
|
||||
actionExecutor: 'device_issue',
|
||||
executorProperty: CreateSceneExecutorProperty(
|
||||
@ -167,6 +188,20 @@ mixin SceneLogicHelper {
|
||||
),
|
||||
],
|
||||
);
|
||||
for (var action in createSceneModel.actions) {
|
||||
if (action.productType == 'NCPS') {
|
||||
if (action.executorProperty!.functionCode == 'near_detection' ||
|
||||
action.executorProperty!.functionCode == 'far_detection') {
|
||||
action.executorProperty!.functionValue =
|
||||
action.executorProperty!.functionValue * 100;
|
||||
} else if (action.executorProperty!.functionCode ==
|
||||
'presence_delay' ||
|
||||
action.executorProperty!.functionCode == 'none_delay') {
|
||||
action.executorProperty!.functionValue =
|
||||
action.executorProperty!.functionValue * 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
sceneBloc.add(CreateSceneWithTasksEvent(
|
||||
createSceneModel: createSceneModel,
|
||||
createAutomationModel: null,
|
||||
|
||||
@ -4,6 +4,7 @@ import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
||||
import 'package:syncrow_app/features/scene/enum/operation_dialog_type.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/ac_functions.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/door_lock_functions.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/flush_functions_helper.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/gateway_functions.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/human_presence_functions.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/one_gang_functions.dart';
|
||||
@ -18,7 +19,7 @@ import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
mixin SceneOperationsDataHelper {
|
||||
final Map<DeviceType,
|
||||
Function(List<FunctionModel>, String, String, dynamic, bool)>
|
||||
Function(List<FunctionModel>, String, String, dynamic, bool, String)>
|
||||
_functionMap = {
|
||||
DeviceType.LightBulb: lightBulbFunctions,
|
||||
DeviceType.CeilingSensor: ceilingSensorFunctions,
|
||||
@ -31,6 +32,7 @@ mixin SceneOperationsDataHelper {
|
||||
DeviceType.OneGang: oneGangFunctions,
|
||||
DeviceType.TwoGang: towGangFunctions,
|
||||
DeviceType.WH: waterHeaterFunctions,
|
||||
DeviceType.FlushMountedSensor: flushFunctions
|
||||
};
|
||||
|
||||
final Map<DeviceType, String> _titleMap = {
|
||||
@ -45,14 +47,33 @@ mixin SceneOperationsDataHelper {
|
||||
DeviceType.OneGang: '1G Light Switch Conditions',
|
||||
DeviceType.TwoGang: '2G Light Switch Conditions',
|
||||
DeviceType.WH: 'Water Heater Conditions',
|
||||
DeviceType.FlushMountedSensor: 'Flush Presence Sensor Functions'
|
||||
};
|
||||
|
||||
static List<SceneStaticFunction> flushFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation,
|
||||
String productType,
|
||||
) {
|
||||
if (isAutomation) {
|
||||
return FlushFunctionsHelper.flushSceneHelperFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
}
|
||||
return FlushFunctionsHelper.flushAutomationFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
}
|
||||
|
||||
static List<SceneStaticFunction> waterHeaterFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation,
|
||||
String productType,
|
||||
) {
|
||||
if (isAutomation) {
|
||||
return WaterHeaterFunctionsHelper.waterHeaterAutomationFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
@ -63,11 +84,13 @@ mixin SceneOperationsDataHelper {
|
||||
|
||||
//one gang functions
|
||||
static List<SceneStaticFunction> oneGangFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation,
|
||||
String productType,
|
||||
) {
|
||||
if (isAutomation) {
|
||||
return OneGangHelperFunctions.oneGangAutomationFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
@ -77,11 +100,13 @@ mixin SceneOperationsDataHelper {
|
||||
}
|
||||
|
||||
static List<SceneStaticFunction> towGangFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation,
|
||||
String productType,
|
||||
) {
|
||||
if (isAutomation) {
|
||||
return TowGangHelperFunctions.towGangAutomationFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
@ -95,13 +120,14 @@ mixin SceneOperationsDataHelper {
|
||||
required List<FunctionModel> functions,
|
||||
required String deviceId,
|
||||
required String deviceName,
|
||||
required String productType,
|
||||
required bool isAutomation,
|
||||
}) {
|
||||
final functionValue = null;
|
||||
return _functionMap[type]?.call(
|
||||
functions, deviceId, deviceName, functionValue, isAutomation) ??
|
||||
lightBulbFunctions(
|
||||
functions, deviceId, deviceName, functionValue, isAutomation);
|
||||
return _functionMap[type]?.call(functions, deviceId, deviceName,
|
||||
functionValue, isAutomation, productType) ??
|
||||
lightBulbFunctions(functions, deviceId, deviceName, functionValue,
|
||||
isAutomation, productType);
|
||||
}
|
||||
|
||||
String getTitle({DeviceType? type}) {
|
||||
@ -109,11 +135,13 @@ mixin SceneOperationsDataHelper {
|
||||
}
|
||||
|
||||
static List<SceneStaticFunction> ceilingSensorFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation,
|
||||
String productType,
|
||||
) {
|
||||
if (isAutomation) {
|
||||
return PresenceSensorHelperFunctions.automationPresenceSensorFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
@ -123,20 +151,24 @@ mixin SceneOperationsDataHelper {
|
||||
}
|
||||
|
||||
static List<SceneStaticFunction> curtainFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation,
|
||||
String productType,
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
static List<SceneStaticFunction> doorLockFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation,
|
||||
String productType,
|
||||
) {
|
||||
if (isAutomation) {
|
||||
return DoorLockHelperFunctions.doorLockAutomationFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
@ -146,11 +178,13 @@ mixin SceneOperationsDataHelper {
|
||||
}
|
||||
|
||||
static List<SceneStaticFunction> wallSensorFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation,
|
||||
String productType,
|
||||
) {
|
||||
if (isAutomation) {
|
||||
return HumanPresenceHelperFunctions.automationHumanPresenceFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
@ -164,26 +198,31 @@ mixin SceneOperationsDataHelper {
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
bool isAutomation,
|
||||
String productType) {
|
||||
return [];
|
||||
}
|
||||
|
||||
static List<SceneStaticFunction> gatewayFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation,
|
||||
String productType,
|
||||
) {
|
||||
return GatewayHelperFunctions.tabToRunGatewayFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
}
|
||||
|
||||
static List<SceneStaticFunction> threeGangFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation,
|
||||
String productType,
|
||||
) {
|
||||
if (isAutomation) {
|
||||
return ThreeGangHelperFunctions.threeGangAutomationFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
@ -193,11 +232,13 @@ mixin SceneOperationsDataHelper {
|
||||
}
|
||||
|
||||
static List<SceneStaticFunction> acFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation,
|
||||
String productType,
|
||||
) {
|
||||
if (isAutomation) {
|
||||
return ACFunctionsHelper.automationAcFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
@ -212,7 +253,19 @@ mixin SceneOperationsDataHelper {
|
||||
List<Condition>? conditions,
|
||||
}) {
|
||||
List<SceneStaticFunction> functions = [];
|
||||
|
||||
for (var action in actions) {
|
||||
if (action.productType == "NCPS") {
|
||||
if (action.executorProperty!.functionCode == 'near_detection' ||
|
||||
action.executorProperty!.functionCode == 'far_detection') {
|
||||
action.executorProperty!.functionValue =
|
||||
action.executorProperty!.functionValue / 100;
|
||||
} else if (action.executorProperty!.functionCode == 'presence_delay' ||
|
||||
action.executorProperty!.functionCode == 'none_delay') {
|
||||
action.executorProperty!.functionValue =
|
||||
(action.executorProperty!.functionValue / 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Handle actions
|
||||
for (var action in actions) {
|
||||
if (action.entityId == 'delay') {
|
||||
@ -306,11 +359,9 @@ mixin SceneOperationsDataHelper {
|
||||
String? uniqueCustomId,
|
||||
}) {
|
||||
final executorProperty = action.executorProperty;
|
||||
|
||||
final Map<String,
|
||||
SceneStaticFunction Function(Action, bool, String?, String?)>
|
||||
functionMap = {
|
||||
'sensitivity': _createSensitivityFunction,
|
||||
'normal_open_switch': _createNormalOpenSwitchFunction,
|
||||
'unlock_fingerprint': _createUnlockFingerprintFunction,
|
||||
'unlock_password': _createUnlockPasswordFunction,
|
||||
@ -323,12 +374,21 @@ mixin SceneOperationsDataHelper {
|
||||
'hijack': _createHijackFunction,
|
||||
'doorbell': _createDoorbellFunction,
|
||||
'unlock_temporary': _createUnlockTemporaryFunction,
|
||||
'far_detection': _createFarDetectionFunction,
|
||||
'near_detection': _createNearDetectionOptions,
|
||||
if (action.productType == 'NCPS') ...{
|
||||
'far_detection': _createFarDetectionOptionsFlush,
|
||||
'presence_state': _createPresenceStateFunctionFlush,
|
||||
'illum_value': _createIlluminanceValueFunctionFlush,
|
||||
'sensitivity': _createSensitivityFunctionFlush,
|
||||
} else ...{
|
||||
'far_detection': _createFarDetectionFunction,
|
||||
'presence_state': _createPresenceStateFunction,
|
||||
'sensitivity': _createSensitivityFunction,
|
||||
},
|
||||
'motion_sensitivity_value': _createMotionSensitivityFunction,
|
||||
'motionless_sensitivity': _createMotionlessSensitivityFunction,
|
||||
'indicator': _createIndicatorFunction,
|
||||
'presence_time': _createPresenceTimeFunction,
|
||||
'presence_state': _createPresenceStateFunction,
|
||||
'dis_current': _createDisCurrentFunction,
|
||||
'illuminance_value': _createIlluminanceValueFunction,
|
||||
'checking_result': _createCheckingResultFunction,
|
||||
@ -349,6 +409,10 @@ mixin SceneOperationsDataHelper {
|
||||
'factory_reset': _createFactoryResetFunction,
|
||||
'switch_backlight': _createSwitchFunction,
|
||||
'relay_status': _relayStatusSwitchFunction,
|
||||
'sensi_reduce': _createTriggerLevelOptions,
|
||||
'occur_dist_reduce': _createIndentLevelOptions,
|
||||
'presence_delay': _createTargetConfirmTime,
|
||||
'none_delay': _createDisappeDelay
|
||||
};
|
||||
|
||||
final functionCode = executorProperty?.functionCode ?? '';
|
||||
@ -372,7 +436,6 @@ mixin SceneOperationsDataHelper {
|
||||
String? uniqueCustomId,
|
||||
]) {
|
||||
final productType = action.productType;
|
||||
|
||||
final functionValue = action.executorProperty?.functionValue;
|
||||
return SceneStaticFunction(
|
||||
deviceType: productType,
|
||||
@ -765,17 +828,36 @@ mixin SceneOperationsDataHelper {
|
||||
|
||||
SceneStaticFunction _createSwitchFunction(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.waterHeaterIcon,
|
||||
'Power',
|
||||
OperationDialogType.onOff,
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
switch (action.productType) {
|
||||
case "AC":
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.assetsIconsAC,
|
||||
'Switch',
|
||||
OperationDialogType.onOff,
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
|
||||
case "WH":
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.waterHeaterIcon,
|
||||
'Power',
|
||||
OperationDialogType.onOff,
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
|
||||
default:
|
||||
throw ArgumentError('Unsupported product type: ${action.productType}');
|
||||
}
|
||||
}
|
||||
|
||||
SceneStaticFunction _relayStatusSwitchFunction(Action action,
|
||||
@ -875,6 +957,19 @@ mixin SceneOperationsDataHelper {
|
||||
static SceneStaticFunction _createSwitch1Function(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
switch (action.productType) {
|
||||
case "AC":
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.acSwitchIcon,
|
||||
'Switch',
|
||||
OperationDialogType.onOff,
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
|
||||
case "WH":
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
@ -1349,6 +1444,21 @@ mixin SceneOperationsDataHelper {
|
||||
];
|
||||
}
|
||||
|
||||
List<SceneOperationalValue> _createPresenceStateOptionsFlush() {
|
||||
return [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsIconsPresenceSensorAssetsEmpty,
|
||||
value: 'none',
|
||||
description: 'None',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsPresence,
|
||||
value: 'presence',
|
||||
description: 'Presence',
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
List<SceneOperationalValue> _createPresenceStateOptions() {
|
||||
return [
|
||||
SceneOperationalValue(
|
||||
@ -1582,7 +1692,7 @@ mixin SceneOperationsDataHelper {
|
||||
return [
|
||||
_mapExecutorPropertyToSceneFunction(
|
||||
Action(
|
||||
deviceName: taskItem.deviceName,
|
||||
deviceName: taskItem.deviceName!,
|
||||
productType: taskItem.deviceType!,
|
||||
entityId: deviceId,
|
||||
executorProperty: ExecutorProperty(
|
||||
@ -1630,4 +1740,296 @@ mixin SceneOperationsDataHelper {
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
SceneStaticFunction _createNearDetectionOptions(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.flushIcon,
|
||||
'Min Detection distance',
|
||||
OperationDialogType.integerSteps,
|
||||
_createMinDetection(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createFarDetectionOptionsFlush(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.flushIcon,
|
||||
'Max Detection distance',
|
||||
OperationDialogType.integerSteps,
|
||||
_createFarDetection(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createTriggerLevelOptions(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.flushIcon,
|
||||
"Trigger Level",
|
||||
OperationDialogType.listOfOptions,
|
||||
_createTriggerLevelFunction(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
List<SceneOperationalValue> _createTriggerLevelFunction() {
|
||||
return [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
description: "1",
|
||||
value: 1,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
description: "2",
|
||||
value: 2,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
description: "3",
|
||||
value: 3,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
SceneStaticFunction _createIndentLevelOptions(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.flushIcon,
|
||||
'Indent Level',
|
||||
OperationDialogType.listOfOptions,
|
||||
_createIndentLevelFunction(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
List<SceneOperationalValue> _createIndentLevelFunction() {
|
||||
return [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
description: "1",
|
||||
value: 1,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
description: "2",
|
||||
value: 2,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
description: "3",
|
||||
value: 3,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
SceneStaticFunction _createTargetConfirmTime(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.flushIcon,
|
||||
'Target Confirm Time',
|
||||
OperationDialogType.integerSteps,
|
||||
_targetConfirmTimeFun(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createDisappeDelay(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.flushIcon,
|
||||
'Disappe Delay',
|
||||
OperationDialogType.integerSteps,
|
||||
_targetDisappeDelayFun(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
List<SceneOperationalValue> _targetDisappeDelayFun() {
|
||||
return [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.flushIcon,
|
||||
value: 0.0,
|
||||
description: '',
|
||||
minValue: 20,
|
||||
maxValue: 300,
|
||||
stepValue: 1,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
List<SceneOperationalValue> _createFarDetection() {
|
||||
return [
|
||||
SceneOperationalValue(
|
||||
icon: '',
|
||||
description: "m",
|
||||
value: 0.0,
|
||||
minValue: 0.0,
|
||||
maxValue: 9.5,
|
||||
stepValue: 1,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
List<SceneOperationalValue> _createMinDetection() {
|
||||
return [
|
||||
SceneOperationalValue(
|
||||
icon: '',
|
||||
description: "m",
|
||||
value: 0.0,
|
||||
minValue: 0.0,
|
||||
maxValue: 9.5,
|
||||
stepValue: 1,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
List<SceneOperationalValue> _targetConfirmTimeFun() {
|
||||
return [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsCelsiusDegrees,
|
||||
value: 0.0,
|
||||
description: '',
|
||||
minValue: 0.0,
|
||||
maxValue: 0.5,
|
||||
stepValue: 0.1,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
SceneStaticFunction _createPresenceStateFunctionFlush(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.flushIcon,
|
||||
'Presence State',
|
||||
OperationDialogType.listOfOptions,
|
||||
_createPresenceStateOptionsFlush(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createIlluminanceValueFunctionFlush(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.flushIcon,
|
||||
'Illuminance Value',
|
||||
OperationDialogType.integerSteps,
|
||||
_createIlluminanceValueOptionsFlush(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
List<SceneOperationalValue> _createIlluminanceValueOptionsFlush() {
|
||||
return [
|
||||
SceneOperationalValue(
|
||||
icon: '',
|
||||
value: 0.0,
|
||||
description: "Lux",
|
||||
minValue: 0,
|
||||
maxValue: 10000,
|
||||
stepValue: 1,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
SceneStaticFunction _createSensitivityFunctionFlush(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.flushIcon,
|
||||
'Sensitivity',
|
||||
isAutomation
|
||||
? OperationDialogType.integerSteps
|
||||
: OperationDialogType.listOfOptions,
|
||||
_createIntegerStepsOptionsFlush(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
List<SceneOperationalValue> _createIntegerStepsOptionsFlush() {
|
||||
return [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 1,
|
||||
description: 1.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 2,
|
||||
description: 2.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 3,
|
||||
description: 3.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 4,
|
||||
description: 4.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 5,
|
||||
description: 5.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 6,
|
||||
description: 6.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 7,
|
||||
description: 7.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 8,
|
||||
description: 8.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 9,
|
||||
description: 9.toString(),
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,6 +94,8 @@ class CreateSceneModel {
|
||||
}
|
||||
|
||||
class CreateSceneAction {
|
||||
final String? productType;
|
||||
|
||||
String entityId;
|
||||
String? actionType;
|
||||
String actionExecutor;
|
||||
@ -104,15 +106,18 @@ class CreateSceneAction {
|
||||
required this.entityId,
|
||||
required this.actionExecutor,
|
||||
required this.executorProperty,
|
||||
required this.productType,
|
||||
});
|
||||
|
||||
CreateSceneAction copyWith({
|
||||
String? productType,
|
||||
String? actionType,
|
||||
String? entityId,
|
||||
String? actionExecutor,
|
||||
CreateSceneExecutorProperty? executorProperty,
|
||||
}) {
|
||||
return CreateSceneAction(
|
||||
productType: productType,
|
||||
actionType: actionType,
|
||||
entityId: entityId ?? this.entityId,
|
||||
actionExecutor: actionExecutor ?? this.actionExecutor,
|
||||
@ -126,18 +131,21 @@ class CreateSceneAction {
|
||||
'entityId': entityId,
|
||||
'actionExecutor': actionExecutor,
|
||||
'executorProperty': executorProperty?.toMap(actionExecutor),
|
||||
// 'productType': productType,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
"actionType": actionType,
|
||||
'entityId': entityId,
|
||||
'actionExecutor': actionExecutor,
|
||||
// 'productType': productType,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
factory CreateSceneAction.fromMap(Map<String, dynamic> map) {
|
||||
return CreateSceneAction(
|
||||
productType: map['productType'] ?? '',
|
||||
entityId: map['entityId'] ?? '',
|
||||
actionExecutor: map['actionExecutor'] ?? '',
|
||||
executorProperty:
|
||||
|
||||
@ -75,7 +75,6 @@ class Action {
|
||||
String? name;
|
||||
String? type;
|
||||
final String productType;
|
||||
|
||||
final String deviceName;
|
||||
|
||||
Action({
|
||||
@ -91,39 +90,57 @@ class Action {
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
static Action? fromJson(Map<String, dynamic> json) {
|
||||
if (json['name'] != null && json['type'] != null) {
|
||||
return Action(
|
||||
actionExecutor: json["actionExecutor"] as String,
|
||||
entityId: json["entityId"] as String,
|
||||
name: json['name'] as String?,
|
||||
type: json['type'] as String?,
|
||||
productType: json['productType'] as String,
|
||||
deviceName: json['deviceName'] as String,
|
||||
);
|
||||
}
|
||||
if (json["executorProperty"] == null) {
|
||||
// Safely extract required fields with null checks
|
||||
final String? actionExecutor = json["actionExecutor"] as String?;
|
||||
final String? entityId = json["entityId"] as String?;
|
||||
final String? productType = json['productType'] as String?;
|
||||
final String? deviceName = json['deviceName'] as String?;
|
||||
|
||||
// Skip invalid actions with missing required fields
|
||||
if (actionExecutor == null ||
|
||||
entityId == null ||
|
||||
productType == null ||
|
||||
deviceName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Action(
|
||||
actionExecutor: json["actionExecutor"] as String,
|
||||
entityId: json["entityId"] as String,
|
||||
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
||||
productType: json['productType'] as String,
|
||||
deviceName: json['deviceName'] as String,
|
||||
);
|
||||
// Handle actions with 'name' and 'type'
|
||||
if (json['name'] != null && json['type'] != null) {
|
||||
return Action(
|
||||
actionExecutor: actionExecutor,
|
||||
entityId: entityId,
|
||||
name: json['name'] as String?,
|
||||
type: json['type'] as String?,
|
||||
productType: productType,
|
||||
deviceName: deviceName,
|
||||
);
|
||||
}
|
||||
|
||||
// Handle actions with 'executorProperty'
|
||||
if (json["executorProperty"] != null) {
|
||||
return Action(
|
||||
actionExecutor: actionExecutor,
|
||||
entityId: entityId,
|
||||
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
||||
productType: productType,
|
||||
deviceName: deviceName,
|
||||
);
|
||||
}
|
||||
|
||||
return null; // Skip invalid actions
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"actionExecutor": actionExecutor,
|
||||
"entityId": entityId,
|
||||
"executorProperty": executorProperty?.toJson(),
|
||||
// "productType": productType
|
||||
};
|
||||
}
|
||||
|
||||
class ExecutorProperty {
|
||||
final String? functionCode;
|
||||
final dynamic functionValue;
|
||||
dynamic functionValue;
|
||||
final dynamic delaySeconds;
|
||||
|
||||
ExecutorProperty({
|
||||
|
||||
@ -12,7 +12,7 @@ class SceneStaticFunction {
|
||||
final String deviceId;
|
||||
final String operationName;
|
||||
final String? uniqueCustomId;
|
||||
final dynamic functionValue;
|
||||
dynamic functionValue;
|
||||
final String? deviceIcon;
|
||||
final OperationDialogType operationDialogType;
|
||||
final String? comparator;
|
||||
@ -29,7 +29,7 @@ class SceneStaticFunction {
|
||||
this.deviceIcon,
|
||||
required this.operationDialogType,
|
||||
this.comparator,
|
||||
this.deviceType,
|
||||
this.deviceType,
|
||||
String? uniqueCustomId,
|
||||
}) : uniqueCustomId = uniqueCustomId ?? const Uuid().v4();
|
||||
|
||||
@ -127,7 +127,8 @@ class SceneStaticFunction {
|
||||
other.uniqueCustomId == uniqueCustomId &&
|
||||
other.operationDialogType == operationDialogType &&
|
||||
listEquals(other.operationalValues, operationalValues) &&
|
||||
other.deviceId == deviceId && other.deviceType == deviceType;
|
||||
other.deviceId == deviceId &&
|
||||
other.deviceType == deviceType;
|
||||
}
|
||||
|
||||
@override
|
||||
@ -142,7 +143,8 @@ class SceneStaticFunction {
|
||||
comparator.hashCode ^
|
||||
uniqueCustomId.hashCode ^
|
||||
operationDialogType.hashCode ^
|
||||
operationalValues.hashCode ^ deviceType.hashCode;
|
||||
operationalValues.hashCode ^
|
||||
deviceType.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -26,20 +26,20 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
Widget build(BuildContext context) {
|
||||
final device = (ModalRoute.of(context)?.settings.arguments as Map)['device']
|
||||
as DeviceModel;
|
||||
|
||||
final isAutomation = (ModalRoute.of(context)?.settings.arguments
|
||||
as Map)['isAutomationDeviceStatus'] as bool;
|
||||
|
||||
List<SceneStaticFunction> functions = [];
|
||||
if (device.functions.isNotEmpty) {
|
||||
functions = getFunctionsWithIcons(
|
||||
type: device.productType,
|
||||
functions: device.functions,
|
||||
deviceId: device.uuid ?? '',
|
||||
deviceName: device.name ?? '',
|
||||
isAutomation: isAutomation,
|
||||
);
|
||||
}
|
||||
// if (device.functions.isNotEmpty) {
|
||||
functions = getFunctionsWithIcons(
|
||||
productType: device.type ?? '',
|
||||
type: device.productType,
|
||||
functions: device.functions,
|
||||
deviceId: device.uuid ?? '',
|
||||
deviceName: device.name ?? '',
|
||||
isAutomation: isAutomation,
|
||||
);
|
||||
// }
|
||||
|
||||
return DefaultScaffold(
|
||||
title: getTitle(type: device.productType),
|
||||
@ -257,7 +257,7 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
deviceName: device.name ?? '',
|
||||
uniqueId: function.uniqueCustomId!,
|
||||
operationType: function.operationDialogType,
|
||||
deviceType: '',
|
||||
deviceType: function.deviceType!,
|
||||
));
|
||||
Navigator.pop(context);
|
||||
},
|
||||
@ -298,7 +298,7 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
return;
|
||||
}
|
||||
context.read<CreateSceneBloc>().add(TempHoldSceneTasksEvent(
|
||||
deviceType: device.productType!.name,
|
||||
deviceType: function.deviceType!,
|
||||
deviceControlModel: DeviceControlModel(
|
||||
deviceId: device.uuid,
|
||||
code: function.code,
|
||||
|
||||
@ -7,12 +7,12 @@ import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class AlertDialogSliderSteps extends StatefulWidget {
|
||||
const AlertDialogSliderSteps({
|
||||
super.key,
|
||||
this.functionValue,
|
||||
required this.taskItem,
|
||||
required this.isAutomation,
|
||||
});
|
||||
const AlertDialogSliderSteps(
|
||||
{super.key,
|
||||
this.functionValue,
|
||||
required this.taskItem,
|
||||
required this.isAutomation,
|
||||
});
|
||||
|
||||
final dynamic functionValue;
|
||||
final SceneStaticFunction taskItem;
|
||||
@ -108,67 +108,69 @@ class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ToggleButtons(
|
||||
isSelected: [
|
||||
selectedToggleIndex == 0,
|
||||
selectedToggleIndex == 1,
|
||||
selectedToggleIndex == 2
|
||||
],
|
||||
onPressed: (index) {
|
||||
setState(() {
|
||||
selectedToggleIndex = index;
|
||||
});
|
||||
context.read<CreateSceneBloc>().add(
|
||||
SelectedValueEvent(
|
||||
value: _deNormalizeValue(groupValue),
|
||||
code: widget.taskItem.code,
|
||||
isAutomation: widget.isAutomation,
|
||||
comparator: _indexToComparator(selectedToggleIndex),
|
||||
widget.isAutomation
|
||||
? ToggleButtons(
|
||||
isSelected: [
|
||||
selectedToggleIndex == 0,
|
||||
selectedToggleIndex == 1,
|
||||
selectedToggleIndex == 2
|
||||
],
|
||||
onPressed: (index) {
|
||||
setState(() {
|
||||
selectedToggleIndex = index;
|
||||
});
|
||||
context.read<CreateSceneBloc>().add(
|
||||
SelectedValueEvent(
|
||||
value: _deNormalizeValue(groupValue),
|
||||
code: widget.taskItem.code,
|
||||
isAutomation: widget.isAutomation,
|
||||
comparator: _indexToComparator(selectedToggleIndex),
|
||||
),
|
||||
);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
selectedColor: Colors.white,
|
||||
color: ColorsManager.blackColor,
|
||||
fillColor: ColorsManager.primaryColorWithOpacity,
|
||||
borderColor: ColorsManager.greyColor,
|
||||
constraints: BoxConstraints.tight(const Size(70, 30)),
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 70,
|
||||
height: 30,
|
||||
child: Container(
|
||||
color: selectedToggleIndex == 0
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.greyColor,
|
||||
alignment: Alignment.center,
|
||||
child: const Text("<"),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
selectedColor: Colors.white,
|
||||
color: ColorsManager.blackColor,
|
||||
fillColor: ColorsManager.primaryColorWithOpacity,
|
||||
borderColor: ColorsManager.greyColor,
|
||||
constraints: BoxConstraints.tight(const Size(70, 30)),
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 70,
|
||||
height: 30,
|
||||
child: Container(
|
||||
color: selectedToggleIndex == 0
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.greyColor,
|
||||
alignment: Alignment.center,
|
||||
child: const Text("<"),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 70,
|
||||
height: 30,
|
||||
child: Container(
|
||||
color: selectedToggleIndex == 1
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.greyColor,
|
||||
alignment: Alignment.center,
|
||||
child: const Text("="),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 70,
|
||||
height: 30,
|
||||
child: Container(
|
||||
color: selectedToggleIndex == 2
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.greyColor,
|
||||
alignment: Alignment.center,
|
||||
child: const Text(">"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 70,
|
||||
height: 30,
|
||||
child: Container(
|
||||
color: selectedToggleIndex == 1
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.greyColor,
|
||||
alignment: Alignment.center,
|
||||
child: const Text("="),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 70,
|
||||
height: 30,
|
||||
child: Container(
|
||||
color: selectedToggleIndex == 2
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.greyColor,
|
||||
alignment: Alignment.center,
|
||||
child: const Text(">"),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: SizedBox(),
|
||||
const SizedBox(height: 12),
|
||||
...widget.taskItem.operationalValues.map(
|
||||
(operation) => BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
|
||||
@ -1156,4 +1156,9 @@ class Assets {
|
||||
'assets/icons/target_confirm_time_icon.svg';
|
||||
static const String disappeDelayIcon = 'assets/icons/disappe_delay_icon.svg';
|
||||
static const String flushIcon = 'assets/icons/flush_icon.svg';
|
||||
static const String IlluminanceIcon = 'assets/icons/Illuminance_icon.svg';
|
||||
static const String nobodyTime = "assets/icons/nobody_time.svg";
|
||||
static const String currentDistanceIcon = 'assets/icons/distance_icon.svg';
|
||||
static const String delayIcon = 'assets/icons/delay_icon.svg';
|
||||
static const String levelIcon = 'assets/icons/level_icon.svg';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user