From bf05f945860c019a9db8a41726f6e416e5938c71 Mon Sep 17 00:00:00 2001 From: ashrafzarkanisala Date: Mon, 1 Jul 2024 20:51:14 +0300 Subject: [PATCH] finished sending the delay in correct way --- lib/features/scene/helper/scene_logic_helper.dart | 10 ++++++---- .../widgets/alert_dialogs/alert_dialog_countdown.dart | 4 ++-- lib/features/scene/widgets/bottom_sheet_widget.dart | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/features/scene/helper/scene_logic_helper.dart b/lib/features/scene/helper/scene_logic_helper.dart index 0477738..4978b19 100644 --- a/lib/features/scene/helper/scene_logic_helper.dart +++ b/lib/features/scene/helper/scene_logic_helper.dart @@ -15,7 +15,8 @@ import 'package:syncrow_app/utils/context_extension.dart'; mixin SceneLogicHelper { bool isOnlyDelayOrDelayLast(List tasks) { final lastTask = tasks.last; - return tasks.every((task) => task.code == 'delay') || lastTask.code == 'delay'; + return tasks.every((task) => task.code == 'delay') || + lastTask.code == 'delay'; } void handleSaveButtonPress( @@ -44,12 +45,12 @@ mixin SceneLogicHelper { tasks.length, (index) { final task = tasks[index]; - if (task.code == 'delay') { + if (task.deviceId == 'delay') { return CreateSceneAction( entityId: tasks[index].deviceId, actionExecutor: 'delay', executorProperty: CreateSceneExecutorProperty( - functionCode: task.code, + functionCode: '', functionValue: task.operationalValues.first.value, delaySeconds: 0, ), @@ -121,7 +122,8 @@ mixin SceneLogicHelper { ); } else { return AlertDialogCountdown( - durationValue: listOfSceneStaticFunction[index].functionValue ?? taskItem.functionValue, + durationValue: listOfSceneStaticFunction[index].functionValue ?? + taskItem.functionValue, functionValue: taskItem.functionValue, function: listOfSceneStaticFunction[index], ); diff --git a/lib/features/scene/widgets/alert_dialogs/alert_dialog_countdown.dart b/lib/features/scene/widgets/alert_dialogs/alert_dialog_countdown.dart index 30304b0..e83e9a1 100644 --- a/lib/features/scene/widgets/alert_dialogs/alert_dialog_countdown.dart +++ b/lib/features/scene/widgets/alert_dialogs/alert_dialog_countdown.dart @@ -60,8 +60,8 @@ class _AlertDialogCountdownState extends State { setState(() { durationInSeconds = newDuration.inSeconds; }); - context.read().add(SelectedValueEvent( - value: newDuration.inSeconds, code: widget.function.code)); + context.read().add( + SelectedValueEvent(value: newDuration.inSeconds, code: 'delay')); }, ), ); diff --git a/lib/features/scene/widgets/bottom_sheet_widget.dart b/lib/features/scene/widgets/bottom_sheet_widget.dart index 887fa27..2b3ba88 100644 --- a/lib/features/scene/widgets/bottom_sheet_widget.dart +++ b/lib/features/scene/widgets/bottom_sheet_widget.dart @@ -111,11 +111,11 @@ class CustomBottomSheetWidget extends StatelessWidget { title: functions[0].operationName, onConfirm: () { final selectedValue = - context.read().selectedValues[functions[0].code]; + context.read().selectedValues['delay']; context.read().add(TempHoldSceneTasksEvent( deviceControlModel: DeviceControlModel( - deviceId: 'delay', - code: functions[0].code, + deviceId: '', + code: '', value: selectedValue, ), deviceId: 'delay',