Refactor mappable stepped functions to a static constant for improved readability and maintainability

This commit is contained in:
Faris Armoush
2025-04-15 10:03:47 +03:00
parent ceb1e1d23a
commit e2ec986bb9

View File

@ -153,23 +153,27 @@ class _CeilingSensorDialogState extends State<CeilingSensorDialog> {
);
}
static const _mappableSteppedFunctions = <String>{
'static_max_dis',
'presence_reference',
'moving_reference',
'perceptual_boundary',
'moving_boundary',
'moving_rigger_time',
'moving_static_time',
'none_body_time',
'moving_max_dis',
};
List<DeviceFunctionData> _updateValuesForAddedFunctions(
List<DeviceFunctionData> addedFunctions,
) {
const mappableSteppedFunctions = <String>{
'static_max_dis',
'presence_reference',
'moving_reference',
'perceptual_boundary',
'moving_boundary',
'moving_rigger_time',
'moving_static_time',
'none_body_time',
'moving_max_dis',
};
return addedFunctions.map((function) {
if (mappableSteppedFunctions.contains(function.functionCode)) {
final mappedValue = mapSteppedValue(
final shouldMapValue = _mappableSteppedFunctions.contains(
function.functionCode,
);
if (shouldMapValue) {
final mappedValue = _mapSteppedValue(
value: function.value,
inputStep: CpsSliderHelpers.dividendOfRange(function.functionCode),
inputRange: CpsSliderHelpers.sliderRange(function.functionCode),
@ -189,7 +193,7 @@ class _CeilingSensorDialogState extends State<CeilingSensorDialog> {
}).toList();
}
int mapSteppedValue({
int _mapSteppedValue({
required (double min, double max) inputRange,
required double inputStep,
required (double min, double max, double dividend) outputRange,