mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
add autoamtion tasks
This commit is contained in:
@ -44,7 +44,8 @@ class DeviceModel {
|
|||||||
|
|
||||||
if (type == DeviceType.LightBulb) {
|
if (type == DeviceType.LightBulb) {
|
||||||
tempIcon = Assets.assetsIconsLight;
|
tempIcon = Assets.assetsIconsLight;
|
||||||
} else if (type == DeviceType.CeilingSensor || type == DeviceType.WallSensor) {
|
} else if (type == DeviceType.CeilingSensor ||
|
||||||
|
type == DeviceType.WallSensor) {
|
||||||
tempIcon = Assets.assetsIconsSensors;
|
tempIcon = Assets.assetsIconsSensors;
|
||||||
} else if (type == DeviceType.AC) {
|
} else if (type == DeviceType.AC) {
|
||||||
tempIcon = Assets.assetsIconsAC;
|
tempIcon = Assets.assetsIconsAC;
|
||||||
@ -93,5 +94,6 @@ class DeviceModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FunctionModel> getFunctions(DeviceType type) => devicesFunctionsMap[productType] ?? [];
|
List<FunctionModel> getFunctions(DeviceType type) =>
|
||||||
|
devicesFunctionsMap[productType] ?? [];
|
||||||
}
|
}
|
||||||
|
@ -40,19 +40,25 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
|
|
||||||
FutureOr<void> _onAddSceneTask(
|
FutureOr<void> _onAddSceneTask(
|
||||||
AddTaskEvent event, Emitter<CreateSceneState> emit) {
|
AddTaskEvent event, Emitter<CreateSceneState> emit) {
|
||||||
|
emit(CreateSceneLoading());
|
||||||
if (event.isAutomation == true) {
|
if (event.isAutomation == true) {
|
||||||
final copyList = List<SceneStaticFunction>.from(automationTempTasksList);
|
final copyList = List<SceneStaticFunction>.from(automationTempTasksList);
|
||||||
automationTasksList.addAll(copyList);
|
automationTasksList.addAll(copyList);
|
||||||
automationTempTasksList.clear();
|
automationTempTasksList.clear();
|
||||||
automationSelectedValues.clear();
|
automationSelectedValues.clear();
|
||||||
emit(AddSceneTask(
|
emit(AddSceneTask(
|
||||||
tasksList: tasksList, automationTasksList: automationTasksList));
|
automationTasksList: automationTasksList,
|
||||||
|
tasksList: tasksList,
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
final copyList = List<SceneStaticFunction>.from(tempTasksList);
|
final copyList = List<SceneStaticFunction>.from(tempTasksList);
|
||||||
tasksList.addAll(copyList);
|
tasksList.addAll(copyList);
|
||||||
tempTasksList.clear();
|
tempTasksList.clear();
|
||||||
selectedValues.clear();
|
selectedValues.clear();
|
||||||
emit(AddSceneTask(tasksList: tasksList));
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList,
|
||||||
|
automationTasksList: automationTasksList,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,198 +117,9 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
tempTasksList.add(newElement);
|
tempTasksList.add(newElement);
|
||||||
selectedValues[newElement.code] = event.deviceControlModel.value;
|
selectedValues[newElement.code] = event.deviceControlModel.value;
|
||||||
}
|
}
|
||||||
emit(TempHoldSceneTask(tempTasksList: tempTasksList));
|
|
||||||
emit(AddSceneTask(tasksList: tasksList));
|
|
||||||
}
|
|
||||||
|
|
||||||
FutureOr<void> _selectedValue(
|
emit(AddSceneTask(
|
||||||
SelectedValueEvent event, Emitter<CreateSceneState> emit) {
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
if (event.isAutomation == true) {
|
|
||||||
automationSelectedValues[event.code] = event.value;
|
|
||||||
emit(SelectedTaskValueState(value: event.value));
|
|
||||||
emit(AddSceneTask(
|
|
||||||
tasksList: tasksList, automationTasksList: automationTasksList));
|
|
||||||
} else {
|
|
||||||
selectedValues[event.code] = event.value;
|
|
||||||
emit(SelectedTaskValueState(value: event.value));
|
|
||||||
emit(AddSceneTask(tasksList: tasksList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FutureOr<void> _removeTaskById(
|
|
||||||
RemoveTaskByIdEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
emit(CreateSceneLoading());
|
|
||||||
if (event.isAutomation == true) {
|
|
||||||
for (var element in automationTasksList) {
|
|
||||||
if (element.uniqueCustomId == event.taskId) {
|
|
||||||
automationTasksList.remove(element);
|
|
||||||
emit(AddSceneTask(
|
|
||||||
tasksList: tasksList, automationTasksList: automationTasksList));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (var element in tasksList) {
|
|
||||||
if (element.uniqueCustomId == event.taskId) {
|
|
||||||
tasksList.remove(element);
|
|
||||||
|
|
||||||
emit(AddSceneTask(tasksList: tasksList));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FutureOr<void> _removeTempTaskById(
|
|
||||||
RemoveTempTaskByIdEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
if (event.isAutomation == true) {
|
|
||||||
for (var element in automationTempTasksList) {
|
|
||||||
if (element.uniqueCustomId == event.code) {
|
|
||||||
automationTempTasksList.remove(element);
|
|
||||||
emit(AddSceneTask(
|
|
||||||
tasksList: tasksList, automationTasksList: automationTasksList));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (var element in tempTasksList) {
|
|
||||||
if (element.code == event.code) {
|
|
||||||
tempTasksList.remove(element);
|
|
||||||
|
|
||||||
emit(AddSceneTask(tasksList: tasksList));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FutureOr<void> _createSceneWithTasks(
|
|
||||||
CreateSceneWithTasksEvent event, Emitter<CreateSceneState> emit) async {
|
|
||||||
emit(CreateSceneLoading());
|
|
||||||
try {
|
|
||||||
final response = event.updateScene
|
|
||||||
? await SceneApi.updateScene(event.createSceneModel, event.sceneId)
|
|
||||||
: await SceneApi.createScene(event.createSceneModel);
|
|
||||||
if (response['success'] == true) {
|
|
||||||
tasksList.clear();
|
|
||||||
tempTasksList.clear();
|
|
||||||
selectedValues.clear();
|
|
||||||
emit(const CreateSceneWithTasks(success: true));
|
|
||||||
} else {
|
|
||||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
|
||||||
emit(AddSceneTask(tasksList: tasksList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FutureOr<void> _clearTaskList(
|
|
||||||
ClearTaskListEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
if (event.isAutomation == true) {
|
|
||||||
automationTasksList.clear();
|
|
||||||
emit(AddSceneTask(
|
|
||||||
tasksList: tasksList, automationTasksList: automationTasksList));
|
|
||||||
} else {
|
|
||||||
tasksList.clear();
|
|
||||||
emit(AddSceneTask(tasksList: tasksList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FutureOr<void> _fetchSceneTasks(
|
|
||||||
FetchSceneTasksEvent event, Emitter<CreateSceneState> emit) async {
|
|
||||||
emit(CreateSceneLoading());
|
|
||||||
|
|
||||||
try {
|
|
||||||
final response = await SceneApi.getSceneDetails(event.sceneId);
|
|
||||||
if (response.id.isNotEmpty) {
|
|
||||||
tasksList = List<SceneStaticFunction>.from(
|
|
||||||
getTaskListFunctionsFromApi(actions: response.actions));
|
|
||||||
emit(AddSceneTask(
|
|
||||||
tasksList: tasksList,
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FutureOr<void> _clearTempTaskList(
|
|
||||||
ClearTempTaskListEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
if (event.isAutomation == true) {
|
|
||||||
automationTempTasksList.clear();
|
|
||||||
automationSelectedValues.clear();
|
|
||||||
emit(AddSceneTask(
|
|
||||||
tasksList: tasksList, automationTasksList: automationTasksList));
|
|
||||||
} else {
|
|
||||||
tempTasksList.clear();
|
|
||||||
selectedValues.clear();
|
|
||||||
emit(AddSceneTask(tasksList: tempTasksList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FutureOr<void> _removeFromSelectedValueById(
|
|
||||||
RemoveFromSelectedValueById event, Emitter<CreateSceneState> emit) {
|
|
||||||
if (event.isAutomation == true) {
|
|
||||||
if (automationSelectedValues.containsKey(event.code)) {
|
|
||||||
automationSelectedValues.remove(event.code);
|
|
||||||
emit(const SelectedTaskValueState(value: null));
|
|
||||||
emit(AddSceneTask(
|
|
||||||
tasksList: tasksList, automationTasksList: automationTasksList));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (selectedValues.containsKey(event.code)) {
|
|
||||||
selectedValues.remove(event.code);
|
|
||||||
emit(const SelectedTaskValueState(value: null));
|
|
||||||
emit(AddSceneTask(tasksList: tasksList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FutureOr<void> _deleteScene(
|
|
||||||
DeleteSceneEvent event, Emitter<CreateSceneState> emit) async {
|
|
||||||
emit(DeleteSceneLoading());
|
|
||||||
|
|
||||||
try {
|
|
||||||
final response = await SceneApi.deleteScene(
|
|
||||||
sceneId: event.sceneId, unitUuid: event.unitUuid);
|
|
||||||
if (response == true) {
|
|
||||||
emit(const DeleteSceneSuccess(true));
|
|
||||||
} else {
|
|
||||||
emit(const DeleteSceneError(message: 'Something went wrong'));
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
emit(const DeleteSceneError(message: 'Something went wrong'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FutureOr<void> _updateTaskValue(
|
|
||||||
UpdateTaskEvent event, Emitter<CreateSceneState> emit) {
|
|
||||||
if (event.isAutomation == true) {
|
|
||||||
for (var i = 0; i < automationTasksList.length; i++) {
|
|
||||||
if (automationTasksList[i].uniqueCustomId == event.taskId) {
|
|
||||||
automationTasksList[i] = automationTasksList[i].copyWith(
|
|
||||||
functionValue: event.newValue,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit(AddSceneTask(
|
|
||||||
tasksList: tasksList, automationTasksList: automationTasksList));
|
|
||||||
} else {
|
|
||||||
for (var i = 0; i < tasksList.length; i++) {
|
|
||||||
if (tasksList[i].uniqueCustomId == event.taskId) {
|
|
||||||
tasksList[i] = tasksList[i].copyWith(
|
|
||||||
functionValue: event.newValue,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit(AddSceneTask(tasksList: tasksList));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToTempAutomationTaskList(
|
void addToTempAutomationTaskList(
|
||||||
@ -354,10 +171,200 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
automationSelectedValues[newElement.code] =
|
automationSelectedValues[newElement.code] =
|
||||||
event.deviceControlModel.value;
|
event.deviceControlModel.value;
|
||||||
}
|
}
|
||||||
emit(TempHoldSceneTask(
|
|
||||||
tempTasksList: tempTasksList,
|
|
||||||
automationTempTasksList: automationTempTasksList));
|
|
||||||
emit(AddSceneTask(
|
emit(AddSceneTask(
|
||||||
tasksList: tasksList, automationTasksList: automationTasksList));
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _selectedValue(
|
||||||
|
SelectedValueEvent event, Emitter<CreateSceneState> emit) {
|
||||||
|
if (event.isAutomation == true) {
|
||||||
|
automationSelectedValues[event.code] = event.value;
|
||||||
|
emit(SelectedTaskValueState(value: event.value));
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
} else {
|
||||||
|
selectedValues[event.code] = event.value;
|
||||||
|
emit(SelectedTaskValueState(value: event.value));
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _removeTaskById(
|
||||||
|
RemoveTaskByIdEvent event, Emitter<CreateSceneState> emit) {
|
||||||
|
emit(CreateSceneLoading());
|
||||||
|
if (event.isAutomation == true) {
|
||||||
|
for (var element in automationTasksList) {
|
||||||
|
if (element.uniqueCustomId == event.taskId) {
|
||||||
|
automationTasksList.remove(element);
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var element in tasksList) {
|
||||||
|
if (element.uniqueCustomId == event.taskId) {
|
||||||
|
tasksList.remove(element);
|
||||||
|
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _removeTempTaskById(
|
||||||
|
RemoveTempTaskByIdEvent event, Emitter<CreateSceneState> emit) {
|
||||||
|
if (event.isAutomation == true) {
|
||||||
|
for (var element in automationTempTasksList) {
|
||||||
|
if (element.uniqueCustomId == event.code) {
|
||||||
|
automationTempTasksList.remove(element);
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var element in tempTasksList) {
|
||||||
|
if (element.code == event.code) {
|
||||||
|
tempTasksList.remove(element);
|
||||||
|
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _createSceneWithTasks(
|
||||||
|
CreateSceneWithTasksEvent event, Emitter<CreateSceneState> emit) async {
|
||||||
|
emit(CreateSceneLoading());
|
||||||
|
try {
|
||||||
|
final response = event.updateScene
|
||||||
|
? await SceneApi.updateScene(event.createSceneModel, event.sceneId)
|
||||||
|
: await SceneApi.createScene(event.createSceneModel);
|
||||||
|
if (response['success'] == true) {
|
||||||
|
tasksList.clear();
|
||||||
|
tempTasksList.clear();
|
||||||
|
selectedValues.clear();
|
||||||
|
emit(const CreateSceneWithTasks(success: true));
|
||||||
|
} else {
|
||||||
|
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _clearTaskList(
|
||||||
|
ClearTaskListEvent event, Emitter<CreateSceneState> emit) {
|
||||||
|
automationTasksList.clear();
|
||||||
|
tasksList.clear();
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _fetchSceneTasks(
|
||||||
|
FetchSceneTasksEvent event, Emitter<CreateSceneState> emit) async {
|
||||||
|
emit(CreateSceneLoading());
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await SceneApi.getSceneDetails(event.sceneId);
|
||||||
|
if (response.id.isNotEmpty) {
|
||||||
|
tasksList = List<SceneStaticFunction>.from(getTaskListFunctionsFromApi(
|
||||||
|
actions: response.actions, isAutomation: false));
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _clearTempTaskList(
|
||||||
|
ClearTempTaskListEvent event, Emitter<CreateSceneState> emit) {
|
||||||
|
if (event.isAutomation == true) {
|
||||||
|
automationTempTasksList.clear();
|
||||||
|
automationSelectedValues.clear();
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
} else {
|
||||||
|
tempTasksList.clear();
|
||||||
|
selectedValues.clear();
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _removeFromSelectedValueById(
|
||||||
|
RemoveFromSelectedValueById event, Emitter<CreateSceneState> emit) {
|
||||||
|
if (event.isAutomation == true) {
|
||||||
|
if (automationSelectedValues.containsKey(event.code)) {
|
||||||
|
automationSelectedValues.remove(event.code);
|
||||||
|
emit(const SelectedTaskValueState(value: null));
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (selectedValues.containsKey(event.code)) {
|
||||||
|
selectedValues.remove(event.code);
|
||||||
|
emit(const SelectedTaskValueState(value: null));
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _deleteScene(
|
||||||
|
DeleteSceneEvent event, Emitter<CreateSceneState> emit) async {
|
||||||
|
emit(DeleteSceneLoading());
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await SceneApi.deleteScene(
|
||||||
|
sceneId: event.sceneId, unitUuid: event.unitUuid);
|
||||||
|
if (response == true) {
|
||||||
|
emit(const DeleteSceneSuccess(true));
|
||||||
|
} else {
|
||||||
|
emit(const DeleteSceneError(message: 'Something went wrong'));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(const DeleteSceneError(message: 'Something went wrong'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _updateTaskValue(
|
||||||
|
UpdateTaskEvent event, Emitter<CreateSceneState> emit) {
|
||||||
|
if (event.isAutomation == true) {
|
||||||
|
for (var i = 0; i < automationTasksList.length; i++) {
|
||||||
|
if (automationTasksList[i].uniqueCustomId == event.taskId) {
|
||||||
|
automationTasksList[i] = automationTasksList[i].copyWith(
|
||||||
|
functionValue: event.newValue,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < tasksList.length; i++) {
|
||||||
|
if (tasksList[i].uniqueCustomId == event.taskId) {
|
||||||
|
tasksList[i] = tasksList[i].copyWith(
|
||||||
|
functionValue: event.newValue,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit(AddSceneTask(
|
||||||
|
tasksList: tasksList, automationTasksList: automationTasksList));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,10 +113,12 @@ class CreateSceneWithTasksEvent extends CreateSceneEvent {
|
|||||||
final CreateSceneModel createSceneModel;
|
final CreateSceneModel createSceneModel;
|
||||||
final bool updateScene;
|
final bool updateScene;
|
||||||
final String sceneId;
|
final String sceneId;
|
||||||
|
//final bool isAutomation;
|
||||||
const CreateSceneWithTasksEvent({
|
const CreateSceneWithTasksEvent({
|
||||||
required this.createSceneModel,
|
required this.createSceneModel,
|
||||||
required this.updateScene,
|
required this.updateScene,
|
||||||
required this.sceneId,
|
required this.sceneId,
|
||||||
|
// required this.isAutomation,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -157,18 +157,6 @@ class HumanPresenceHelperFunctions {
|
|||||||
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsNobodyTime,
|
|
||||||
operationName: 'Nobody Time',
|
|
||||||
code: 'presence_time',
|
|
||||||
functionValue: functionValue,
|
|
||||||
operationDialogType: OperationDialogType.countdown,
|
|
||||||
operationalValues: [
|
|
||||||
SceneOperationalValue(icon: '', value: 0),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,142 +222,6 @@ class HumanPresenceHelperFunctions {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsFarDetection,
|
|
||||||
operationName: 'Far Detection',
|
|
||||||
code: 'far_detection',
|
|
||||||
functionValue: functionValue,
|
|
||||||
operationDialogType: OperationDialogType.listOfOptions,
|
|
||||||
operationalValues: [
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 75,
|
|
||||||
description: '75cm',
|
|
||||||
iconValue: '75',
|
|
||||||
),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 150,
|
|
||||||
description: '150cm',
|
|
||||||
iconValue: '150',
|
|
||||||
),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 225,
|
|
||||||
description: '225cm',
|
|
||||||
iconValue: '225',
|
|
||||||
),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 300,
|
|
||||||
description: '300cm',
|
|
||||||
iconValue: '300',
|
|
||||||
),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 375,
|
|
||||||
description: '375cm',
|
|
||||||
iconValue: '375',
|
|
||||||
),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 450,
|
|
||||||
description: '450cm',
|
|
||||||
iconValue: '450',
|
|
||||||
),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 525,
|
|
||||||
description: '525cm',
|
|
||||||
iconValue: '525',
|
|
||||||
),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 600,
|
|
||||||
description: '600cm',
|
|
||||||
iconValue: '600',
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsMotionDetection,
|
|
||||||
operationName: 'Motion Detection Sensitivity',
|
|
||||||
code: 'motion_sensitivity_value',
|
|
||||||
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(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsMotionlessDetection,
|
|
||||||
operationName: 'Motionless Detection Sensitivity',
|
|
||||||
code: 'motionless_sensitivity',
|
|
||||||
functionValue: functionValue,
|
|
||||||
operationDialogType: OperationDialogType.listOfOptions,
|
|
||||||
operationalValues: [
|
|
||||||
SceneOperationalValue(
|
|
||||||
iconValue: '1',
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 1,
|
|
||||||
description: '1',
|
|
||||||
),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 2,
|
|
||||||
description: '2',
|
|
||||||
iconValue: '2',
|
|
||||||
),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 3,
|
|
||||||
description: '3',
|
|
||||||
iconValue: '3',
|
|
||||||
),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 4,
|
|
||||||
description: '4',
|
|
||||||
iconValue: '4',
|
|
||||||
),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
|
||||||
value: 5,
|
|
||||||
description: '5',
|
|
||||||
iconValue: '5',
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
@ -395,13 +247,12 @@ class HumanPresenceHelperFunctions {
|
|||||||
operationDialogType: OperationDialogType.integerSteps,
|
operationDialogType: OperationDialogType.integerSteps,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: '',
|
icon: '',
|
||||||
value: 0.0,
|
value: 0.0,
|
||||||
minValue: 0.0,
|
minValue: 0.0,
|
||||||
maxValue: 65535,
|
maxValue: 65535,
|
||||||
stepValue: 1,
|
stepValue: 1,
|
||||||
description: 'min'
|
description: 'min'),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
@ -81,9 +81,8 @@ mixin SceneLogicHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget getTheCorrectDialogBody(
|
Widget getTheCorrectDialogBody(
|
||||||
SceneStaticFunction taskItem,
|
SceneStaticFunction taskItem, dynamic functionValue,
|
||||||
dynamic functionValue,
|
{required bool isAutomation}) {
|
||||||
) {
|
|
||||||
if (taskItem.operationDialogType == OperationDialogType.temperature) {
|
if (taskItem.operationDialogType == OperationDialogType.temperature) {
|
||||||
return AlertDialogTemperatureBody(
|
return AlertDialogTemperatureBody(
|
||||||
taskItem: taskItem,
|
taskItem: taskItem,
|
||||||
@ -102,12 +101,14 @@ mixin SceneLogicHelper {
|
|||||||
return AlertDialogSliderSteps(
|
return AlertDialogSliderSteps(
|
||||||
taskItem: taskItem,
|
taskItem: taskItem,
|
||||||
functionValue: functionValue ?? taskItem.functionValue,
|
functionValue: functionValue ?? taskItem.functionValue,
|
||||||
|
isAutomation: isAutomation,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return AlertDialogFunctionsOperationsBody(
|
return AlertDialogFunctionsOperationsBody(
|
||||||
taskItem: taskItem,
|
taskItem: taskItem,
|
||||||
functionValue: functionValue ?? taskItem.functionValue,
|
functionValue: functionValue ?? taskItem.functionValue,
|
||||||
|
isAutomation: isAutomation,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,29 +3,11 @@ import 'dart:convert';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
class CreateSceneModel {
|
class CreateSceneModel {
|
||||||
/*
|
|
||||||
{
|
|
||||||
"unitUuid": "string",
|
|
||||||
"sceneName": "string",
|
|
||||||
"decisionExpr": "string",
|
|
||||||
"actions": [
|
|
||||||
{
|
|
||||||
"entityId": "string",
|
|
||||||
"actionExecutor": "string",
|
|
||||||
"executorProperty": {
|
|
||||||
"functionCode": "string",
|
|
||||||
"functionValue": {},
|
|
||||||
"delaySeconds": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
String unitUuid;
|
String unitUuid;
|
||||||
String sceneName;
|
String sceneName;
|
||||||
String decisionExpr;
|
String decisionExpr;
|
||||||
List<CreateSceneAction> actions;
|
List<CreateSceneAction> actions;
|
||||||
|
|
||||||
CreateSceneModel({
|
CreateSceneModel({
|
||||||
required this.unitUuid,
|
required this.unitUuid,
|
||||||
required this.sceneName,
|
required this.sceneName,
|
||||||
@ -100,6 +82,7 @@ class CreateSceneAction {
|
|||||||
String entityId;
|
String entityId;
|
||||||
String actionExecutor;
|
String actionExecutor;
|
||||||
CreateSceneExecutorProperty executorProperty;
|
CreateSceneExecutorProperty executorProperty;
|
||||||
|
|
||||||
CreateSceneAction({
|
CreateSceneAction({
|
||||||
required this.entityId,
|
required this.entityId,
|
||||||
required this.actionExecutor,
|
required this.actionExecutor,
|
||||||
@ -122,7 +105,7 @@ class CreateSceneAction {
|
|||||||
return {
|
return {
|
||||||
'entityId': entityId,
|
'entityId': entityId,
|
||||||
'actionExecutor': actionExecutor,
|
'actionExecutor': actionExecutor,
|
||||||
'executorProperty': executorProperty.toMap(),
|
'executorProperty': executorProperty.toMap(actionExecutor),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +146,7 @@ class CreateSceneExecutorProperty {
|
|||||||
String functionCode;
|
String functionCode;
|
||||||
dynamic functionValue;
|
dynamic functionValue;
|
||||||
int delaySeconds;
|
int delaySeconds;
|
||||||
|
|
||||||
CreateSceneExecutorProperty({
|
CreateSceneExecutorProperty({
|
||||||
required this.functionCode,
|
required this.functionCode,
|
||||||
required this.functionValue,
|
required this.functionValue,
|
||||||
@ -181,12 +165,14 @@ class CreateSceneExecutorProperty {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap(String actionExecutor) {
|
||||||
return {
|
final map = <String, dynamic>{};
|
||||||
if (functionCode.isNotEmpty == true) 'functionCode': functionCode,
|
if (functionCode.isNotEmpty) map['functionCode'] = functionCode;
|
||||||
if (functionValue != '') 'functionValue': functionValue,
|
if (functionValue != null) map['functionValue'] = functionValue;
|
||||||
if (delaySeconds > 0) 'delaySeconds': delaySeconds,
|
if (actionExecutor == 'delay' && delaySeconds > 0) {
|
||||||
};
|
map['delaySeconds'] = delaySeconds;
|
||||||
|
}
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
factory CreateSceneExecutorProperty.fromMap(Map<String, dynamic> map) {
|
factory CreateSceneExecutorProperty.fromMap(Map<String, dynamic> map) {
|
||||||
@ -197,7 +183,7 @@ class CreateSceneExecutorProperty {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String toJson() => json.encode(toMap());
|
String toJson(String actionExecutor) => json.encode(toMap(actionExecutor));
|
||||||
|
|
||||||
factory CreateSceneExecutorProperty.fromJson(String source) =>
|
factory CreateSceneExecutorProperty.fromJson(String source) =>
|
||||||
CreateSceneExecutorProperty.fromMap(json.decode(source));
|
CreateSceneExecutorProperty.fromMap(json.decode(source));
|
||||||
|
@ -188,6 +188,7 @@ class DeviceFunctionsView extends StatelessWidget
|
|||||||
alertBody: getTheCorrectDialogBody(
|
alertBody: getTheCorrectDialogBody(
|
||||||
function,
|
function,
|
||||||
functionValues,
|
functionValues,
|
||||||
|
isAutomation: false,
|
||||||
),
|
),
|
||||||
title: function.operationName,
|
title: function.operationName,
|
||||||
onConfirm: () {
|
onConfirm: () {
|
||||||
@ -237,6 +238,7 @@ class DeviceFunctionsView extends StatelessWidget
|
|||||||
alertBody: getTheCorrectDialogBody(
|
alertBody: getTheCorrectDialogBody(
|
||||||
function,
|
function,
|
||||||
automationFunctionValues,
|
automationFunctionValues,
|
||||||
|
isAutomation: true,
|
||||||
),
|
),
|
||||||
title: function.operationName,
|
title: function.operationName,
|
||||||
onConfirm: () {
|
onConfirm: () {
|
||||||
|
@ -11,10 +11,12 @@ class AlertDialogFunctionsOperationsBody extends StatefulWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
this.functionValue,
|
this.functionValue,
|
||||||
required this.taskItem,
|
required this.taskItem,
|
||||||
|
required this.isAutomation,
|
||||||
});
|
});
|
||||||
|
|
||||||
dynamic functionValue;
|
dynamic functionValue;
|
||||||
final SceneStaticFunction taskItem;
|
final SceneStaticFunction taskItem;
|
||||||
|
final bool isAutomation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AlertDialogFunctionsOperationsBody> createState() =>
|
State<AlertDialogFunctionsOperationsBody> createState() =>
|
||||||
@ -26,25 +28,46 @@ class _AlertDialogFunctionsOperationsBodyState
|
|||||||
@override
|
@override
|
||||||
didChangeDependencies() {
|
didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
|
if (widget.isAutomation) {
|
||||||
final tempTaskList = context.read<CreateSceneBloc>().tempTasksList;
|
final automationTempTasksList =
|
||||||
|
context.read<CreateSceneBloc>().automationTempTasksList;
|
||||||
|
|
||||||
if (tempTaskList.isNotEmpty) {
|
if (automationTempTasksList.isNotEmpty) {
|
||||||
for (var element in tempTaskList) {
|
for (var element in automationTempTasksList) {
|
||||||
if (element.code == widget.taskItem.code) {
|
if (element.code == widget.taskItem.code) {
|
||||||
groupValue = element.functionValue;
|
groupValue = element.functionValue;
|
||||||
} else {
|
} else {
|
||||||
context
|
context.read<CreateSceneBloc>().add(RemoveFromSelectedValueById(
|
||||||
.read<CreateSceneBloc>()
|
code: widget.taskItem.code, isAutomation: widget.isAutomation));
|
||||||
.add(RemoveFromSelectedValueById(code: widget.taskItem.code));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (widget.functionValue != null) {
|
if (widget.functionValue != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
groupValue = widget.functionValue;
|
groupValue = widget.functionValue;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
final tempTaskList = context.read<CreateSceneBloc>().tempTasksList;
|
||||||
|
|
||||||
|
if (tempTaskList.isNotEmpty) {
|
||||||
|
for (var element in tempTaskList) {
|
||||||
|
if (element.code == widget.taskItem.code) {
|
||||||
|
groupValue = element.functionValue;
|
||||||
|
} else {
|
||||||
|
context
|
||||||
|
.read<CreateSceneBloc>()
|
||||||
|
.add(RemoveFromSelectedValueById(code: widget.taskItem.code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widget.functionValue != null) {
|
||||||
|
setState(() {
|
||||||
|
groupValue = widget.functionValue;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +100,9 @@ class _AlertDialogFunctionsOperationsBodyState
|
|||||||
groupValue = value;
|
groupValue = value;
|
||||||
});
|
});
|
||||||
context.read<CreateSceneBloc>().add(SelectedValueEvent(
|
context.read<CreateSceneBloc>().add(SelectedValueEvent(
|
||||||
value: value!, code: widget.taskItem.code));
|
value: value!,
|
||||||
|
code: widget.taskItem.code,
|
||||||
|
isAutomation: widget.isAutomation));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -85,7 +110,9 @@ class _AlertDialogFunctionsOperationsBodyState
|
|||||||
groupValue = operation.value;
|
groupValue = operation.value;
|
||||||
});
|
});
|
||||||
context.read<CreateSceneBloc>().add(SelectedValueEvent(
|
context.read<CreateSceneBloc>().add(SelectedValueEvent(
|
||||||
value: groupValue, code: widget.taskItem.code));
|
value: groupValue,
|
||||||
|
code: widget.taskItem.code,
|
||||||
|
isAutomation: widget.isAutomation));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -11,10 +11,12 @@ class AlertDialogSliderSteps extends StatefulWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
this.functionValue,
|
this.functionValue,
|
||||||
required this.taskItem,
|
required this.taskItem,
|
||||||
|
required this.isAutomation,
|
||||||
});
|
});
|
||||||
|
|
||||||
final dynamic functionValue;
|
final dynamic functionValue;
|
||||||
final SceneStaticFunction taskItem;
|
final SceneStaticFunction taskItem;
|
||||||
|
final bool isAutomation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AlertDialogSliderSteps> createState() => _AlertDialogSliderStepsState();
|
State<AlertDialogSliderSteps> createState() => _AlertDialogSliderStepsState();
|
||||||
@ -27,24 +29,27 @@ class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
|
|||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
final tempTaskList = context.read<CreateSceneBloc>().tempTasksList;
|
|
||||||
if (tempTaskList.isNotEmpty) {
|
if (widget.isAutomation) {
|
||||||
for (var element in tempTaskList) {
|
final automationTempTaskList =
|
||||||
if (element.code == widget.taskItem.code) {
|
context.read<CreateSceneBloc>().automationTempTasksList;
|
||||||
groupValue = element.functionValue;
|
if (automationTempTaskList.isNotEmpty) {
|
||||||
} else {
|
for (var element in automationTempTaskList) {
|
||||||
context
|
if (element.code == widget.taskItem.code) {
|
||||||
.read<CreateSceneBloc>()
|
groupValue = element.functionValue;
|
||||||
.add(RemoveFromSelectedValueById(code: widget.taskItem.code));
|
} else {
|
||||||
|
context.read<CreateSceneBloc>().add(RemoveFromSelectedValueById(
|
||||||
|
code: widget.taskItem.code, isAutomation: widget.isAutomation));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (widget.functionValue != null) {
|
||||||
if (widget.functionValue != null) {
|
setState(() {
|
||||||
setState(() {
|
groupValue = widget.functionValue;
|
||||||
groupValue = widget.functionValue;
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
groupValue = widget.taskItem.operationalValues[0].minValue;
|
||||||
groupValue = widget.taskItem.operationalValues[0].minValue;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,8 +159,12 @@ class _AlertDialogSliderStepsState extends State<AlertDialogSliderSteps> {
|
|||||||
: null,
|
: null,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
groupValue = value;
|
groupValue = value.round().toDouble();
|
||||||
});
|
});
|
||||||
|
context.read<CreateSceneBloc>().add(SelectedValueEvent(
|
||||||
|
value: groupValue,
|
||||||
|
code: widget.taskItem.code,
|
||||||
|
isAutomation: widget.isAutomation));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -14,14 +14,10 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|||||||
class AlertDialogTemperatureBody extends StatefulWidget {
|
class AlertDialogTemperatureBody extends StatefulWidget {
|
||||||
AlertDialogTemperatureBody({
|
AlertDialogTemperatureBody({
|
||||||
super.key,
|
super.key,
|
||||||
//required this.index,
|
|
||||||
// required this.functions,
|
|
||||||
this.functionValue,
|
this.functionValue,
|
||||||
required this.taskItem,
|
required this.taskItem,
|
||||||
});
|
});
|
||||||
|
|
||||||
//final List<SceneStaticFunction> functions;
|
|
||||||
// final int index;
|
|
||||||
final SceneStaticFunction taskItem;
|
final SceneStaticFunction taskItem;
|
||||||
dynamic functionValue;
|
dynamic functionValue;
|
||||||
|
|
||||||
@ -32,14 +28,16 @@ class AlertDialogTemperatureBody extends StatefulWidget {
|
|||||||
|
|
||||||
class _AlertDialogTemperatureBodyState
|
class _AlertDialogTemperatureBodyState
|
||||||
extends State<AlertDialogTemperatureBody> {
|
extends State<AlertDialogTemperatureBody> {
|
||||||
|
int temperature = 24;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
final tempTaskList = context.read<CreateSceneBloc>().tempTasksList;
|
final tempTaskList = context.read<CreateSceneBloc>().tempTasksList;
|
||||||
|
|
||||||
for (var element in tempTaskList) {
|
for (var element in tempTaskList) {
|
||||||
if (element.code == widget.taskItem.code) {
|
if (element.code == widget.taskItem.code) {
|
||||||
temperature = element.functionValue;
|
temperature = _normalizeTemperature(element.functionValue);
|
||||||
} else {
|
} else {
|
||||||
context
|
context
|
||||||
.read<CreateSceneBloc>()
|
.read<CreateSceneBloc>()
|
||||||
@ -48,12 +46,18 @@ class _AlertDialogTemperatureBodyState
|
|||||||
}
|
}
|
||||||
if (widget.functionValue != null) {
|
if (widget.functionValue != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
temperature = widget.functionValue;
|
temperature = _normalizeTemperature(widget.functionValue);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int temperature = 24;
|
int _normalizeTemperature(dynamic value) {
|
||||||
|
if (value is int && value >= 100) {
|
||||||
|
return value ~/ 10;
|
||||||
|
}
|
||||||
|
return value as int? ?? 24;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
@ -98,8 +102,7 @@ class _AlertDialogTemperatureBodyState
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
subtitle: BodyLarge(
|
subtitle: BodyLarge(
|
||||||
text: widget.taskItem.operationalValues[0].description
|
text: widget.taskItem.operationalValues[0].description.toString(),
|
||||||
.toString(),
|
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
@ -110,8 +113,7 @@ class _AlertDialogTemperatureBodyState
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
context.read<CreateSceneBloc>().add(SelectedValueEvent(
|
context.read<CreateSceneBloc>().add(SelectedValueEvent(
|
||||||
value: temperature * 10,
|
value: temperature * 10, code: widget.taskItem.code));
|
||||||
code: widget.taskItem.code));
|
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.add,
|
Icons.add,
|
||||||
|
@ -34,7 +34,7 @@ class ThenAddedTasksContainer extends StatelessWidget
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final createSceneBloc = context.read<CreateSceneBloc>();
|
final createSceneBloc = context.read<CreateSceneBloc>();
|
||||||
String operationValue = '';
|
String operationValue = '';
|
||||||
if (taskItem.code.contains('countdown') ||
|
if ((taskItem.code.contains('countdown') && isAutomation != true) ||
|
||||||
taskItem.deviceId.contains('delay')) {
|
taskItem.deviceId.contains('delay')) {
|
||||||
final functionValue =
|
final functionValue =
|
||||||
taskItem.functionValue ?? taskItem.operationalValues.first.value;
|
taskItem.functionValue ?? taskItem.operationalValues.first.value;
|
||||||
@ -64,7 +64,8 @@ class ThenAddedTasksContainer extends StatelessWidget
|
|||||||
|
|
||||||
/// show alert dialog based on type
|
/// show alert dialog based on type
|
||||||
context.customAlertDialog(
|
context.customAlertDialog(
|
||||||
alertBody: getTheCorrectDialogBody(functionOperation.first, null),
|
alertBody: getTheCorrectDialogBody(functionOperation.first, null,
|
||||||
|
isAutomation: isAutomation ?? false),
|
||||||
title: functionOperation.first.operationName,
|
title: functionOperation.first.operationName,
|
||||||
onConfirm: () {
|
onConfirm: () {
|
||||||
final savedCode = functionOperation.first.deviceId.contains('delay')
|
final savedCode = functionOperation.first.deviceId.contains('delay')
|
||||||
|
@ -2,8 +2,8 @@ import 'package:flutter/foundation.dart';
|
|||||||
|
|
||||||
abstract class ApiEndpoints {
|
abstract class ApiEndpoints {
|
||||||
static const String baseUrl = kReleaseMode
|
static const String baseUrl = kReleaseMode
|
||||||
? 'https://syncrow-staging.azurewebsites.net/api'
|
? 'https://syncrow-staging.azurewebsites.net'
|
||||||
: 'https://syncrow-dev.azurewebsites.net/api';
|
: 'https://syncrow-dev.azurewebsites.net';
|
||||||
// static const String baseUrl = 'http://100.107.182.63:4001'; //Localhost
|
// static const String baseUrl = 'http://100.107.182.63:4001'; //Localhost
|
||||||
|
|
||||||
////////////////////////////////////// Authentication ///////////////////////////////
|
////////////////////////////////////// Authentication ///////////////////////////////
|
||||||
|
@ -12,7 +12,7 @@ class SceneApi {
|
|||||||
try {
|
try {
|
||||||
final response = await _httpService.post(
|
final response = await _httpService.post(
|
||||||
path: ApiEndpoints.createScene,
|
path: ApiEndpoints.createScene,
|
||||||
body: createSceneModel.toJson(),
|
body: createSceneModel.toMap(),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json;
|
||||||
|
Reference in New Issue
Block a user