mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Refactor mappable stepped functions to a static constant for improved readability and maintainability
This commit is contained in:
@ -153,10 +153,7 @@ class _CeilingSensorDialogState extends State<CeilingSensorDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DeviceFunctionData> _updateValuesForAddedFunctions(
|
static const _mappableSteppedFunctions = <String>{
|
||||||
List<DeviceFunctionData> addedFunctions,
|
|
||||||
) {
|
|
||||||
const mappableSteppedFunctions = <String>{
|
|
||||||
'static_max_dis',
|
'static_max_dis',
|
||||||
'presence_reference',
|
'presence_reference',
|
||||||
'moving_reference',
|
'moving_reference',
|
||||||
@ -167,9 +164,16 @@ class _CeilingSensorDialogState extends State<CeilingSensorDialog> {
|
|||||||
'none_body_time',
|
'none_body_time',
|
||||||
'moving_max_dis',
|
'moving_max_dis',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
List<DeviceFunctionData> _updateValuesForAddedFunctions(
|
||||||
|
List<DeviceFunctionData> addedFunctions,
|
||||||
|
) {
|
||||||
return addedFunctions.map((function) {
|
return addedFunctions.map((function) {
|
||||||
if (mappableSteppedFunctions.contains(function.functionCode)) {
|
final shouldMapValue = _mappableSteppedFunctions.contains(
|
||||||
final mappedValue = mapSteppedValue(
|
function.functionCode,
|
||||||
|
);
|
||||||
|
if (shouldMapValue) {
|
||||||
|
final mappedValue = _mapSteppedValue(
|
||||||
value: function.value,
|
value: function.value,
|
||||||
inputStep: CpsSliderHelpers.dividendOfRange(function.functionCode),
|
inputStep: CpsSliderHelpers.dividendOfRange(function.functionCode),
|
||||||
inputRange: CpsSliderHelpers.sliderRange(function.functionCode),
|
inputRange: CpsSliderHelpers.sliderRange(function.functionCode),
|
||||||
@ -189,7 +193,7 @@ class _CeilingSensorDialogState extends State<CeilingSensorDialog> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
int mapSteppedValue({
|
int _mapSteppedValue({
|
||||||
required (double min, double max) inputRange,
|
required (double min, double max) inputRange,
|
||||||
required double inputStep,
|
required double inputStep,
|
||||||
required (double min, double max, double dividend) outputRange,
|
required (double min, double max, double dividend) outputRange,
|
||||||
|
Reference in New Issue
Block a user