mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
refactor function tap handlers to use RoutineTapFunctionHelper
for improved code reuse and readability, and to remove code duplication.
This commit is contained in:
@ -9,6 +9,7 @@ import 'package:syncrow_web/pages/routines/models/ac/ac_operational_value.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/helpers/routine_tap_function_helper.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
@ -76,30 +77,23 @@ class ACHelper {
|
||||
acFunctions: acFunctions,
|
||||
device: device,
|
||||
onFunctionSelected: (functionCode, operationName) {
|
||||
context.read<FunctionBloc>().add(
|
||||
SelectFunction(
|
||||
functionCode: functionCode,
|
||||
operationName: operationName,
|
||||
),
|
||||
);
|
||||
if (functionCode == 'temp_set' ||
|
||||
functionCode == 'temp_current') {
|
||||
context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
entityId: device?.uuid ?? '',
|
||||
functionCode: functionCode,
|
||||
operationName: operationName,
|
||||
value: functionCode == 'temp_set'
|
||||
? 200
|
||||
: -100,
|
||||
condition: '==',
|
||||
valueDescription: selectedFunctionData
|
||||
.valueDescription,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
RoutineTapFunctionHelper.onTapFunction(
|
||||
context,
|
||||
functionCode: functionCode,
|
||||
functionOperationName: operationName,
|
||||
functionValueDescription:
|
||||
selectedFunctionData.valueDescription,
|
||||
deviceUuid: device?.uuid,
|
||||
codesToAddIntoFunctionsWithDefaultValue: [
|
||||
'temp_set',
|
||||
'temp_current',
|
||||
],
|
||||
defaultValue: functionCode == 'temp_set'
|
||||
? 200
|
||||
: functionCode == 'temp_current'
|
||||
? -100
|
||||
: 0,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user