mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 22:14:55 +00:00
push fixes
This commit is contained in:
@ -250,6 +250,15 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < tasksList.length; i++) {
|
||||
if (tasksList[i].code == event.code) {
|
||||
tasksList[i] = tasksList[i].copyWith(
|
||||
comparator: event.comparator ?? '==',
|
||||
functionValue: event.value,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedValues[event.code] = event.value;
|
||||
}
|
||||
@ -330,15 +339,6 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
CreateSceneWithTasksEvent event, Emitter<CreateSceneState> emit) async {
|
||||
emit(CreateSceneLoading());
|
||||
try {
|
||||
// Check for empty conditions or actions
|
||||
if (event.createAutomationModel != null) {
|
||||
if (event.createAutomationModel!.conditions.isEmpty) {
|
||||
throw Exception('Conditions are required');
|
||||
}
|
||||
if (event.createAutomationModel!.actions.isEmpty) {
|
||||
throw Exception('Actions are required');
|
||||
}
|
||||
}
|
||||
dynamic response;
|
||||
if (event.createSceneModel != null) {
|
||||
response = event.updateScene
|
||||
@ -367,11 +367,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
} else {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
emit(CreateSceneError(message: e.toString()));
|
||||
} catch (e) {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
} finally {
|
||||
emit(AddSceneTask(
|
||||
tasksList: tasksList,
|
||||
automationTasksList: automationTasksList,
|
||||
@ -397,6 +394,18 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
emit(CreateSceneLoading());
|
||||
|
||||
try {
|
||||
tasksList.clear();
|
||||
tempTasksList.clear();
|
||||
selectedValues.clear();
|
||||
automationTasksList.clear();
|
||||
automationTempTasksList.clear();
|
||||
automationSelectedValues.clear();
|
||||
automationComparatorValues.clear();
|
||||
effectiveTime =
|
||||
EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||
sceneType = CreateSceneEnum.none;
|
||||
conditionRule = 'or';
|
||||
|
||||
final response = event.isAutomation
|
||||
? await SceneApi.getAutomationDetails(event.sceneId)
|
||||
: await SceneApi.getSceneDetails(event.sceneId);
|
||||
@ -421,16 +430,16 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
)
|
||||
: EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||
|
||||
// Set Custom Time and reset days first
|
||||
BlocProvider.of<EffectPeriodBloc>(
|
||||
NavigationService.navigatorKey.currentContext!)
|
||||
.add(SetCustomTime(effectiveTime!.start, effectiveTime!.end));
|
||||
|
||||
// Set the days directly from the API response
|
||||
BlocProvider.of<EffectPeriodBloc>(
|
||||
NavigationService.navigatorKey.currentContext!)
|
||||
.add(SetDays(response.effectiveTime?.loops ?? '1111111'));
|
||||
|
||||
// Set Custom Time and reset days first
|
||||
BlocProvider.of<EffectPeriodBloc>(
|
||||
NavigationService.navigatorKey.currentContext!)
|
||||
.add(SetCustomTime(effectiveTime!.start, effectiveTime!.end));
|
||||
|
||||
emit(AddSceneTask(
|
||||
automationTasksList: automationTasksList,
|
||||
tasksList: tasksList,
|
||||
@ -536,6 +545,14 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < tasksList.length; i++) {
|
||||
if (tasksList[i].uniqueCustomId == event.taskId) {
|
||||
tasksList[i] = tasksList[i].copyWith(
|
||||
functionValue: event.newValue,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < tasksList.length; i++) {
|
||||
if (tasksList[i].uniqueCustomId == event.taskId) {
|
||||
@ -571,7 +588,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
|
||||
FutureOr<void> _sceneTypeEvent(
|
||||
SceneTypeEvent event, Emitter<CreateSceneState> emit) {
|
||||
emit(CreateSceneInitial());
|
||||
// emit(CreateSceneInitial());
|
||||
|
||||
if (event.type == CreateSceneEnum.tabToRun) {
|
||||
sceneType = CreateSceneEnum.tabToRun;
|
||||
@ -581,7 +598,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
sceneType = CreateSceneEnum.none;
|
||||
}
|
||||
|
||||
emit(SceneTypeState(event.type));
|
||||
// emit(SceneTypeState(event.type));
|
||||
}
|
||||
|
||||
FutureOr<void> _onEffectiveTimeEvent(
|
||||
|
||||
@ -42,6 +42,27 @@ mixin SceneLogicHelper {
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (isAutomation == true && conditions.isEmpty) {
|
||||
context.showCustomSnackbar(
|
||||
message: 'Conditions Must not be empty!',
|
||||
icon: const Icon(
|
||||
Icons.error,
|
||||
color: Colors.red,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isAutomation == true && actions.isEmpty) {
|
||||
context.showCustomSnackbar(
|
||||
message: 'Actions Must not be empty!',
|
||||
icon: const Icon(
|
||||
Icons.error,
|
||||
color: Colors.red,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isAutomation) {
|
||||
final createAutomationModel = CreateAutomationModel(
|
||||
|
||||
@ -247,10 +247,12 @@ mixin SceneOperationsDataHelper {
|
||||
Action action,
|
||||
bool isAutomation, {
|
||||
String? comparator,
|
||||
String? uniqueCustomId,
|
||||
}) {
|
||||
final executorProperty = action.executorProperty;
|
||||
|
||||
final Map<String, SceneStaticFunction Function(Action, bool, String?)>
|
||||
final Map<String,
|
||||
SceneStaticFunction Function(Action, bool, String?, String?)>
|
||||
functionMap = {
|
||||
'sensitivity': _createSensitivityFunction,
|
||||
'normal_open_switch': _createNormalOpenSwitchFunction,
|
||||
@ -294,7 +296,7 @@ mixin SceneOperationsDataHelper {
|
||||
final functionCode = executorProperty?.functionCode ?? '';
|
||||
final createFunction = functionMap[functionCode];
|
||||
if (createFunction != null) {
|
||||
return createFunction(action, isAutomation, comparator);
|
||||
return createFunction(action, isAutomation, comparator, uniqueCustomId);
|
||||
} else {
|
||||
throw ArgumentError('Unsupported function code: $functionCode');
|
||||
}
|
||||
@ -309,9 +311,11 @@ mixin SceneOperationsDataHelper {
|
||||
List<SceneOperationalValue> operationalValues,
|
||||
bool isAutomation, [
|
||||
String? comparator,
|
||||
String? uniqueCustomId,
|
||||
]) {
|
||||
final functionValue = action.executorProperty?.functionValue;
|
||||
return SceneStaticFunction(
|
||||
uniqueCustomId: uniqueCustomId,
|
||||
deviceId: action.entityId,
|
||||
deviceName: deviceName,
|
||||
deviceIcon: icon,
|
||||
@ -325,8 +329,8 @@ mixin SceneOperationsDataHelper {
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createSensitivityFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createSensitivityFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Presence Sensor',
|
||||
@ -338,11 +342,12 @@ mixin SceneOperationsDataHelper {
|
||||
isAutomation ? _createIntegerStepsOptions() : _createSensitivityOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createNormalOpenSwitchFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createNormalOpenSwitchFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -352,6 +357,7 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
@ -394,8 +400,8 @@ mixin SceneOperationsDataHelper {
|
||||
];
|
||||
}
|
||||
|
||||
SceneStaticFunction _createUnlockFingerprintFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createUnlockFingerprintFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -405,11 +411,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createFingerprintUnlockOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createUnlockPasswordFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createUnlockPasswordFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -419,11 +426,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createPasswordUnlockOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createUnlockCardFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createUnlockCardFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -433,11 +441,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createCardUnlockOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createAlarmLockFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createAlarmLockFunction(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -447,11 +456,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createLockAlarmOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createUnlockRequestFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createUnlockRequestFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -461,11 +471,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createUnlockRequestOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createResidualElectricityFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createResidualElectricityFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -475,11 +486,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createResidualElectricityOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createReverseLockFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createReverseLockFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -489,11 +501,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createUnlockAppFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createUnlockAppFunction(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -503,11 +516,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createUnlockAppOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createHijackFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createHijackFunction(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -517,11 +531,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createDoorbellFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createDoorbellFunction(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -531,11 +546,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createUnlockTemporaryFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createUnlockTemporaryFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'WIFI LOCK PRO',
|
||||
@ -545,11 +561,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createTemporaryPasswordUnlockOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createFarDetectionFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createFarDetectionFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Human Presence Sensor',
|
||||
@ -559,11 +576,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createFarDetectionOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createMotionSensitivityFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createMotionSensitivityFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Human Presence Sensor',
|
||||
@ -573,11 +591,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createSensitivityOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createMotionlessSensitivityFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createMotionlessSensitivityFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Human Presence Sensor',
|
||||
@ -587,11 +606,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createSensitivityOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createIndicatorFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createIndicatorFunction(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Human Presence Sensor',
|
||||
@ -601,11 +621,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createPresenceTimeFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createPresenceTimeFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Human Presence Sensor',
|
||||
@ -615,11 +636,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createCountdownOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createPresenceStateFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createPresenceStateFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Human Presence Sensor',
|
||||
@ -629,11 +651,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createPresenceStateOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createDisCurrentFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createDisCurrentFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Human Presence Sensor',
|
||||
@ -645,11 +668,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createCurrentDistanceOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createIlluminanceValueFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createIlluminanceValueFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Human Presence Sensor',
|
||||
@ -659,11 +683,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createIlluminanceValueOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createCheckingResultFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createCheckingResultFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Human Presence Sensor',
|
||||
@ -673,11 +698,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createSelfTestResultOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createSwitchFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createSwitchFunction(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Smart AC Thermostat - Grey - Model A',
|
||||
@ -687,11 +713,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createTempSetFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createTempSetFunction(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Smart AC Thermostat - Grey - Model A',
|
||||
@ -705,11 +732,12 @@ mixin SceneOperationsDataHelper {
|
||||
: _createTemperatureOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createTempCurrentFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createTempCurrentFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Smart AC Thermostat - Grey - Model A',
|
||||
@ -719,11 +747,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createCurrentTemperatureOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createModeFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createModeFunction(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Smart AC Thermostat - Grey - Model A',
|
||||
@ -733,11 +762,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createAcModeOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createLevelFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createLevelFunction(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Smart AC Thermostat - Grey - Model A',
|
||||
@ -747,11 +777,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createFanSpeedOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createChildLockFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createChildLockFunction(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Smart AC Thermostat - Grey - Model A',
|
||||
@ -761,11 +792,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createSwitch1Function(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createSwitch1Function(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'3 Gang Button Switch L-L',
|
||||
@ -775,11 +807,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createSwitch2Function(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createSwitch2Function(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'3 Gang Button Switch L-L',
|
||||
@ -789,11 +822,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createSwitch3Function(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createSwitch3Function(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'3 Gang Button Switch L-L',
|
||||
@ -803,11 +837,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createCountdown1Function(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createCountdown1Function(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'3 Gang Button Switch L-L',
|
||||
@ -821,11 +856,12 @@ mixin SceneOperationsDataHelper {
|
||||
: _createCountdownOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createCountdown2Function(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createCountdown2Function(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'3 Gang Button Switch L-L',
|
||||
@ -839,11 +875,12 @@ mixin SceneOperationsDataHelper {
|
||||
: _createCountdownOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createCountdown3Function(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createCountdown3Function(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'3 Gang Button Switch L-L',
|
||||
@ -857,11 +894,12 @@ mixin SceneOperationsDataHelper {
|
||||
: _createCountdownOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createSwitchAlarmSoundFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createSwitchAlarmSoundFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Gateway',
|
||||
@ -871,11 +909,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createMasterStateFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createMasterStateFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Gateway',
|
||||
@ -885,11 +924,12 @@ mixin SceneOperationsDataHelper {
|
||||
_createMasterStateOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createFactoryResetFunction(
|
||||
Action action, bool isAutomation, String? comparator) {
|
||||
SceneStaticFunction _createFactoryResetFunction(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
'Gateway',
|
||||
@ -899,6 +939,7 @@ mixin SceneOperationsDataHelper {
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
}
|
||||
|
||||
@ -1181,6 +1222,7 @@ mixin SceneOperationsDataHelper {
|
||||
if (deviceId.contains('delay')) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
uniqueCustomId: taskItem.uniqueCustomId,
|
||||
deviceId: taskItem.deviceId,
|
||||
deviceName: 'delay',
|
||||
deviceIcon: Assets.delay,
|
||||
@ -1202,6 +1244,7 @@ mixin SceneOperationsDataHelper {
|
||||
if (taskItem.code == CreateSceneEnum.smartSceneSelect.name) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
uniqueCustomId: taskItem.uniqueCustomId,
|
||||
deviceId: taskItem.deviceId,
|
||||
deviceName: taskItem.deviceName.toString(),
|
||||
deviceIcon: taskItem.operationName == 'automation'
|
||||
@ -1241,6 +1284,7 @@ mixin SceneOperationsDataHelper {
|
||||
),
|
||||
isAutomation,
|
||||
comparator: taskItem.comparator,
|
||||
uniqueCustomId: taskItem.uniqueCustomId,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ class SceneStaticFunction {
|
||||
final List<SceneOperationalValue> operationalValues;
|
||||
final String deviceId;
|
||||
final String operationName;
|
||||
final String uniqueCustomId;
|
||||
final String? uniqueCustomId;
|
||||
final dynamic functionValue;
|
||||
final String? deviceIcon;
|
||||
final OperationDialogType operationDialogType;
|
||||
@ -28,7 +28,8 @@ class SceneStaticFunction {
|
||||
this.deviceIcon,
|
||||
required this.operationDialogType,
|
||||
this.comparator,
|
||||
}) : uniqueCustomId = const Uuid().v4();
|
||||
String? uniqueCustomId,
|
||||
}) : uniqueCustomId = uniqueCustomId ?? const Uuid().v4();
|
||||
|
||||
SceneStaticFunction copyWith({
|
||||
String? icon,
|
||||
@ -42,6 +43,7 @@ class SceneStaticFunction {
|
||||
String? deviceName,
|
||||
OperationDialogType? operationDialogType,
|
||||
String? comparator,
|
||||
String? uniqueCustomId,
|
||||
}) {
|
||||
return SceneStaticFunction(
|
||||
icon: icon ?? this.icon,
|
||||
@ -54,6 +56,7 @@ class SceneStaticFunction {
|
||||
deviceIcon: deviceIcon ?? this.deviceIcon,
|
||||
operationDialogType: operationDialogType ?? this.operationDialogType,
|
||||
comparator: comparator ?? this.comparator,
|
||||
uniqueCustomId: uniqueCustomId ?? const Uuid().v4(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -68,7 +71,8 @@ class SceneStaticFunction {
|
||||
'functionValue': functionValue,
|
||||
'deviceIcon': deviceIcon,
|
||||
'operationDialogType': operationDialogType.name,
|
||||
'comparator': comparator
|
||||
'comparator': comparator,
|
||||
'uniqueCustomId': uniqueCustomId,
|
||||
};
|
||||
}
|
||||
|
||||
@ -88,6 +92,7 @@ class SceneStaticFunction {
|
||||
? OperationDialogType.values.byName(map['operationDialogType'])
|
||||
: OperationDialogType.none,
|
||||
comparator: map['comparator'],
|
||||
uniqueCustomId: map['uniqueCustomId'] ?? const Uuid().v4(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -98,7 +103,7 @@ class SceneStaticFunction {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SceneStaticFunction(icon: $icon, name: $deviceName, code: $code, operationalValues: $operationalValues, deviceId: $deviceId, operationName: $operationName, functionValue: $functionValue, deviceIcon: $deviceIcon, operationDialogType: $operationDialogType, comparator: $comparator)';
|
||||
return 'SceneStaticFunction(icon: $icon, name: $deviceName, code: $code, operationalValues: $operationalValues, deviceId: $deviceId, operationName: $operationName, functionValue: $functionValue, deviceIcon: $deviceIcon, operationDialogType: $operationDialogType, comparator: $comparator, uniqueCustomId: $uniqueCustomId)';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -113,6 +118,7 @@ class SceneStaticFunction {
|
||||
other.functionValue == functionValue &&
|
||||
other.deviceIcon == deviceIcon &&
|
||||
other.comparator == comparator &&
|
||||
other.uniqueCustomId == uniqueCustomId &&
|
||||
other.operationDialogType == operationDialogType &&
|
||||
listEquals(other.operationalValues, operationalValues) &&
|
||||
other.deviceId == deviceId;
|
||||
@ -128,6 +134,7 @@ class SceneStaticFunction {
|
||||
functionValue.hashCode ^
|
||||
deviceIcon.hashCode ^
|
||||
comparator.hashCode ^
|
||||
uniqueCustomId.hashCode ^
|
||||
operationDialogType.hashCode ^
|
||||
operationalValues.hashCode;
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
operation: function.operationName,
|
||||
icon: device.icon ?? '',
|
||||
deviceName: device.name ?? '',
|
||||
uniqueId: function.uniqueCustomId,
|
||||
uniqueId: function.uniqueCustomId!,
|
||||
operationType: function.operationDialogType,
|
||||
));
|
||||
Navigator.pop(context);
|
||||
@ -253,7 +253,7 @@ class DeviceFunctionsView extends StatelessWidget
|
||||
operation: function.operationName,
|
||||
icon: device.icon ?? '',
|
||||
deviceName: device.name ?? '',
|
||||
uniqueId: function.uniqueCustomId,
|
||||
uniqueId: function.uniqueCustomId!,
|
||||
operationType: function.operationDialogType,
|
||||
isAutomation: true,
|
||||
));
|
||||
|
||||
@ -29,6 +29,9 @@ class SceneTasksView extends StatelessWidget {
|
||||
|
||||
final isAutomation =
|
||||
sceneSettings.sceneType == CreateSceneEnum.deviceStatusChanges.name;
|
||||
// context.read<CreateSceneBloc>().add(SceneTypeEvent(isAutomation
|
||||
// ? CreateSceneEnum.deviceStatusChanges
|
||||
// : CreateSceneEnum.tabToRun));
|
||||
|
||||
return DefaultScaffold(
|
||||
title: sceneSettings.sceneName.isNotEmpty
|
||||
|
||||
@ -31,6 +31,10 @@ class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
|
||||
super.didChangeDependencies();
|
||||
final createSceneBloc = context.read<CreateSceneBloc>();
|
||||
|
||||
if (widget.taskItem.comparator != null) {
|
||||
selectedToggleIndex = _comparatorToIndex(widget.taskItem.comparator);
|
||||
}
|
||||
|
||||
if (widget.isAutomation) {
|
||||
final automationTempTaskList = createSceneBloc.automationTempTasksList;
|
||||
final automationComparatorValues =
|
||||
@ -52,10 +56,6 @@ class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
|
||||
_normalizeValue(widget.taskItem.operationalValues[0].minValue);
|
||||
}
|
||||
|
||||
if (widget.taskItem.comparator != null) {
|
||||
selectedToggleIndex = _comparatorToIndex(widget.taskItem.comparator);
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
|
||||
context.read<CreateSceneBloc>().add(
|
||||
@ -69,7 +69,7 @@ class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
|
||||
}
|
||||
|
||||
double _normalizeValue(dynamic value) {
|
||||
if (((widget.taskItem.code == "temp_set" && value > 200) ||
|
||||
if (((widget.taskItem.code == "temp_set" && value > 199) ||
|
||||
widget.taskItem.code == "temp_current")) {
|
||||
return (value) / 10;
|
||||
}
|
||||
|
||||
@ -49,13 +49,18 @@ class _AlertDialogTemperatureBodyState
|
||||
temperature = _normalizeTemperature(widget.functionValue);
|
||||
});
|
||||
}
|
||||
|
||||
// context.read<CreateSceneBloc>().add(SelectedValueEvent(
|
||||
// value: temperature * 10,
|
||||
// code: widget.taskItem.code,
|
||||
// ));
|
||||
}
|
||||
|
||||
int _normalizeTemperature(dynamic value) {
|
||||
if (value is int && value >= 100) {
|
||||
if (value >= 100) {
|
||||
return value ~/ 10;
|
||||
}
|
||||
return value as int? ?? 24;
|
||||
return value ?? 24;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -129,7 +129,7 @@ class CustomBottomSheetWidget extends StatelessWidget {
|
||||
operation: functions[0].operationName,
|
||||
icon: Assets.delay,
|
||||
deviceName: 'Delay The Action',
|
||||
uniqueId: functions[0].uniqueCustomId,
|
||||
uniqueId: functions[0].uniqueCustomId!,
|
||||
operationType: functions[0].operationDialogType,
|
||||
));
|
||||
context.read<CreateSceneBloc>().add(const AddTaskEvent());
|
||||
|
||||
@ -48,14 +48,10 @@ class _CreateSceneSaveButtonState extends State<CreateSceneSaveButton>
|
||||
if (state is CreateSceneWithTasks) {
|
||||
if (state.success == true) {
|
||||
navigateToRoute(context, Routes.homeRoute);
|
||||
context.showCustomSnackbar(
|
||||
message: 'Scene created successfully',
|
||||
icon: const Icon(
|
||||
Icons.check,
|
||||
color: Colors.green,
|
||||
),
|
||||
);
|
||||
sceneNameController.text = '';
|
||||
CustomSnackBar.greenSnackBar('Scene created successfully');
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (state is CreateSceneError) {
|
||||
CustomSnackBar.displaySnackBar(state.message);
|
||||
|
||||
@ -19,6 +19,8 @@ import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
import '../../../../navigation/navigation_service.dart';
|
||||
|
||||
class ThenAddedTasksContainer extends StatelessWidget
|
||||
with SceneOperationsDataHelper, SceneLogicHelper {
|
||||
ThenAddedTasksContainer({
|
||||
@ -121,7 +123,7 @@ class ThenAddedTasksContainer extends StatelessWidget
|
||||
createSceneBloc.add(
|
||||
UpdateTaskEvent(
|
||||
newValue: automationSelectedValue,
|
||||
taskId: taskItem.uniqueCustomId,
|
||||
taskId: taskItem.uniqueCustomId!,
|
||||
isAutomation: true,
|
||||
),
|
||||
);
|
||||
@ -136,7 +138,7 @@ class ThenAddedTasksContainer extends StatelessWidget
|
||||
createSceneBloc.add(
|
||||
UpdateTaskEvent(
|
||||
newValue: selectedValue,
|
||||
taskId: taskItem.uniqueCustomId,
|
||||
taskId: taskItem.uniqueCustomId!,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
@ -144,7 +146,10 @@ class ThenAddedTasksContainer extends StatelessWidget
|
||||
}
|
||||
}
|
||||
|
||||
Navigator.pop(context);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Navigator.pop(
|
||||
NavigationService.navigatorKey.currentContext!);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -172,7 +177,7 @@ class ThenAddedTasksContainer extends StatelessWidget
|
||||
),
|
||||
direction: DismissDirection.endToStart,
|
||||
onDismissed: (direction) {
|
||||
String removeFunctionById = taskItem.uniqueCustomId;
|
||||
String removeFunctionById = taskItem.uniqueCustomId!;
|
||||
|
||||
if (isAutomation == true) {
|
||||
context.read<CreateSceneBloc>().add(RemoveTaskByIdEvent(
|
||||
|
||||
@ -47,7 +47,7 @@ class ThenDefaultContainer extends StatelessWidget {
|
||||
return GestureDetector(
|
||||
onTap: isClickable
|
||||
? () => context.customBottomSheet(
|
||||
child: CustomBottomSheetWidget(sceneId:sceneId),
|
||||
child: CustomBottomSheetWidget(sceneId: sceneId),
|
||||
)
|
||||
: null,
|
||||
child: SvgPicture.asset(
|
||||
@ -99,7 +99,9 @@ class ThenDefaultContainer extends StatelessWidget {
|
||||
builder: (context) => const CreateSceneView()));
|
||||
} else {
|
||||
context.customBottomSheet(
|
||||
child: CustomBottomSheetWidget(sceneId: sceneId,),
|
||||
child: CustomBottomSheetWidget(
|
||||
sceneId: sceneId,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@ -35,6 +35,19 @@ class SceneItem extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultContainer(
|
||||
onTap: () {
|
||||
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
||||
if (disablePlayButton == false) {
|
||||
BlocProvider.of<CreateSceneBloc>(context).add(
|
||||
FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false));
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(const SceneTypeEvent(CreateSceneEnum.tabToRun));
|
||||
} else {
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(FetchSceneTasksEvent(sceneId: scene.id, isAutomation: true));
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(const SceneTypeEvent(CreateSceneEnum.deviceStatusChanges));
|
||||
}
|
||||
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.sceneTasksRoute,
|
||||
@ -46,18 +59,6 @@ class SceneItem extends StatelessWidget {
|
||||
sceneName: scene.name,
|
||||
),
|
||||
);
|
||||
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
||||
if (disablePlayButton == false) {
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(const SceneTypeEvent(CreateSceneEnum.tabToRun));
|
||||
BlocProvider.of<CreateSceneBloc>(context).add(
|
||||
FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false));
|
||||
} else {
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(const SceneTypeEvent(CreateSceneEnum.deviceStatusChanges));
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(FetchSceneTasksEvent(sceneId: scene.id, isAutomation: true));
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
@ -30,7 +30,7 @@ class CustomSnackBar {
|
||||
Text(
|
||||
message,
|
||||
style: Theme.of(currentContext).textTheme.bodySmall!.copyWith(
|
||||
fontSize: 14, fontWeight: FontWeight.w500, color: Colors.green),
|
||||
fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white),
|
||||
)
|
||||
]),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user