mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Refactor SliderValueSelector and ValueDisplay to include unit handling and improve UI consistency across sensor dialogs.
This commit is contained in:
@ -32,9 +32,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
|
||||
|
||||
if (_isSliderFunction(selectedFunction)) {
|
||||
return SliderValueSelector(
|
||||
selectedFunction: selectedFunction,
|
||||
functionData: functionData,
|
||||
device: device,
|
||||
currentCondition: functionData.condition,
|
||||
dialogType: dialogType,
|
||||
sliderRange: sliderRange,
|
||||
displayedValue: getDisplayText,
|
||||
@ -61,6 +59,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
unit: _unit,
|
||||
);
|
||||
}
|
||||
|
||||
@ -86,10 +85,17 @@ class WpsValueSelectorWidget extends StatelessWidget {
|
||||
String get getDisplayText {
|
||||
final intValue = int.tryParse('${functionData.value ?? ''}');
|
||||
return switch (functionData.functionCode) {
|
||||
'presence_time' => '${intValue ?? '0'} Min',
|
||||
'dis_current' => '${intValue ?? '250'} CM',
|
||||
'illuminance_value' => '${intValue ?? '0'} Lux',
|
||||
'presence_time' => '${intValue ?? '0'}',
|
||||
'dis_current' => '${intValue ?? '250'}',
|
||||
'illuminance_value' => '${intValue ?? '0'}',
|
||||
_ => '$intValue',
|
||||
};
|
||||
}
|
||||
|
||||
String get _unit => switch (functionData.functionCode) {
|
||||
'presence_time' => 'Min',
|
||||
'dis_current' => 'CM',
|
||||
'illuminance_value' => 'Lux',
|
||||
_ => '',
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user