push door lock automation functions

This commit is contained in:
ashrafzarkanisala
2024-07-14 02:48:26 +03:00
parent 2438dcf83d
commit acbd4a9968
9 changed files with 460 additions and 161 deletions

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
import 'package:syncrow_app/features/scene/enum/operation_dialog_type.dart';
import 'package:syncrow_app/features/scene/helper/scene_operations_data_helper.dart';
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
@ -68,11 +69,30 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
}
if (!updated) {
// Add new function if not found
OperationDialogType getOperationDialogType(String? code, [value]) {
if (code == null) {
return OperationDialogType.none;
}
if (code.contains('delay')) {
return OperationDialogType.delay;
} else if (code.contains('countdown')) {
return OperationDialogType.countdown;
} else if (code.contains('set_temp')) {
return OperationDialogType.temperature;
} else if (value.toString().toLowerCase().trim() == 'on' ||
value.toString().toLowerCase().trim() == 'off') {
return OperationDialogType.onOff;
}
return OperationDialogType.listOfOptions;
}
var newElement = SceneStaticFunction(
operationName: event.operation,
deviceName: event.deviceName,
icon: event.icon,
code: event.deviceControlModel.code ?? '',
operationDialogType: getOperationDialogType(
event.deviceControlModel.code, event.deviceControlModel.value),
deviceId: event.deviceId,
functionValue: event.deviceControlModel.value,
operationalValues: [