From b563cc378eba27fe358266310bd31feb31a95c0c Mon Sep 17 00:00:00 2001 From: Abdullah Alassaf Date: Tue, 11 Mar 2025 23:41:21 +0300 Subject: [PATCH] Added current temp to AC functions --- .../all_devices/models/devices_model.dart | 1 + .../dialog_helper/device_dialog_helper.dart | 5 ++++ lib/pages/routines/models/ac/ac_function.dart | 29 +++++++++++++++++++ .../widgets/routine_dialogs/ac_dialog.dart | 4 +-- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lib/pages/device_managment/all_devices/models/devices_model.dart b/lib/pages/device_managment/all_devices/models/devices_model.dart index 7bcf1b3d..e71d5af8 100644 --- a/lib/pages/device_managment/all_devices/models/devices_model.dart +++ b/lib/pages/device_managment/all_devices/models/devices_model.dart @@ -244,6 +244,7 @@ SOS SwitchFunction(deviceId: uuid ?? '', deviceName: name ?? ''), ModeFunction(deviceId: uuid ?? '', deviceName: name ?? ''), TempSetFunction(deviceId: uuid ?? '', deviceName: name ?? ''), + CurrentTempFunction(deviceId: uuid ?? '', deviceName: name ?? ''), LevelFunction(deviceId: uuid ?? '', deviceName: name ?? ''), ChildLockFunction(deviceId: uuid ?? '', deviceName: name ?? ''), ]; diff --git a/lib/pages/routines/helper/dialog_helper/device_dialog_helper.dart b/lib/pages/routines/helper/dialog_helper/device_dialog_helper.dart index ed2af95a..933b35d7 100644 --- a/lib/pages/routines/helper/dialog_helper/device_dialog_helper.dart +++ b/lib/pages/routines/helper/dialog_helper/device_dialog_helper.dart @@ -41,6 +41,11 @@ class DeviceDialogHelper { final deviceSelectedFunctions = routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? []; + if (removeComparetors) { + //remove the current temp function in the 'if container' + functions.removeAt(3); + } + switch (productType) { case 'AC': return ACHelper.showACFunctionsDialog(context, functions, data['device'], diff --git a/lib/pages/routines/models/ac/ac_function.dart b/lib/pages/routines/models/ac/ac_function.dart index 43b58394..0af1ff69 100644 --- a/lib/pages/routines/models/ac/ac_function.dart +++ b/lib/pages/routines/models/ac/ac_function.dart @@ -151,3 +151,32 @@ class ChildLockFunction extends ACFunction { ), ]; } + +class CurrentTempFunction extends ACFunction { + final int min; + final int max; + final int step; + + CurrentTempFunction({required super.deviceId, required super.deviceName}) + : min = -100, + max = 990, + step = 1, + super( + code: 'temp_current', + operationName: 'Current Temperature', + icon: Assets.currentTemp, + ); + + @override + List getOperationalValues() { + List values = []; + for (int temp = min; temp <= max; temp += step) { + values.add(ACOperationalValue( + icon: Assets.currentTemp, + description: "${temp / 10}°C", + value: temp, + )); + } + return values; + } +} diff --git a/lib/pages/routines/widgets/routine_dialogs/ac_dialog.dart b/lib/pages/routines/widgets/routine_dialogs/ac_dialog.dart index 5f28e539..90c56ede 100644 --- a/lib/pages/routines/widgets/routine_dialogs/ac_dialog.dart +++ b/lib/pages/routines/widgets/routine_dialogs/ac_dialog.dart @@ -329,8 +329,8 @@ class ACHelper { ) { return Slider( value: initialValue is int ? initialValue.toDouble() : 200.0, - min: 200, - max: 300, + min: selectCode == 'temp_current' ? -100 : 200, + max: selectCode == 'temp_current' ? 900 : 300, divisions: 10, label: '${((initialValue ?? 160) / 10).toInt()}°C', onChanged: (value) {