diff --git a/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart b/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart index e29ee08..1310107 100644 --- a/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart +++ b/lib/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart @@ -88,8 +88,12 @@ class AcInterfaceTempUnit extends StatelessWidget { if (valueAsString.endsWith(".0") || valueAsString.endsWith(".5")) { value = double.parse(valueAsString); - // DevicesCubit.getInstance() - // .setACTemp(DeviceModel, value); + DevicesCubit.getInstance().deviceControl( + DeviceControlModel( + deviceId: acDevice.id, + code: 'temp_set', + value: value * 10), + acDevice.id!); } }, ), @@ -104,6 +108,15 @@ class AcInterfaceTempUnit extends StatelessWidget { dimension: 24, child: InkWell( onTap: () { + //TODO refactor the loading check + if (state is GetDeviceStatusLoading && + state.code == 'temp_set' || + state is DeviceControlSuccess && + state.code == 'temp_set' || + state is DeviceControlLoading && + state.code == 'temp_set') { + return; + } if (setToTemp > 20) { DevicesCubit.getInstance().deviceControl( DeviceControlModel( @@ -124,8 +137,14 @@ class AcInterfaceTempUnit extends StatelessWidget { // text: "${DeviceModel.coolTo}° C", text: '$setToTemp° C', style: context.bodyLarge.copyWith( - color: - ColorsManager.primaryColor.withOpacity(0.6), + color: state is GetDeviceStatusLoading && + state.code == 'temp_set' || + state is DeviceControlSuccess && + state.code == 'temp_set' || + state is DeviceControlLoading && + state.code == 'temp_set' + ? Colors.grey + : ColorsManager.primaryColor.withOpacity(0.6), fontWeight: FontsManager.bold, fontSize: 30, height: 0), @@ -140,10 +159,14 @@ class AcInterfaceTempUnit extends StatelessWidget { dimension: 24, child: InkWell( onTap: () { - // DevicesCubit.getInstance() - // .setACTemp(DeviceModel, DeviceModel.coolTo); - // DeviceModel.coolTo += .5; - + if (state is GetDeviceStatusLoading && + state.code == 'temp_set' || + state is DeviceControlSuccess && + state.code == 'temp_set' || + state is DeviceControlLoading && + state.code == 'temp_set') { + return; + } if (setToTemp < 30) { DevicesCubit.getInstance().deviceControl( DeviceControlModel(