mirror of
https://github.com/SyncrowIOT/web.git
synced 2026-10-24 15:17:56 +00:00
Refactor SliderValueSelector and ValueDisplay to include unit handling and improve UI consistency across sensor dialogs.
This commit is contained in:
+20
-10
@@ -29,13 +29,12 @@ class CpsDialogSliderSelector extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliderValueSelector(
|
||||
selectedFunction: selectedFunction,
|
||||
functionData: selectedFunctionData,
|
||||
device: device,
|
||||
currentCondition: selectedFunctionData.condition,
|
||||
dialogType: dialogType,
|
||||
sliderRange: _sliderRange,
|
||||
displayedValue: _displayText,
|
||||
initialValue: selectedFunctionData.value ?? 0,
|
||||
unit: _unit,
|
||||
onConditionChanged: (condition) => context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
@@ -58,13 +57,10 @@ class CpsDialogSliderSelector extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
double get sliderStepper {
|
||||
return 1;
|
||||
}
|
||||
|
||||
(double, double) get _sliderRange => switch (selectedFunctionData.functionCode) {
|
||||
'moving_speed' => (0, 32),
|
||||
'space_static_val' => (0, 255),
|
||||
@@ -94,12 +90,26 @@ class CpsDialogSliderSelector extends StatelessWidget {
|
||||
'presence_range' ||
|
||||
'perceptual_boundary' ||
|
||||
'moving_boundary' =>
|
||||
'${parsedValue?.toStringAsFixed(1) ?? '0'} M',
|
||||
'moving_rigger_time' => '${parsedValue?.toStringAsFixed(3) ?? '0'} s',
|
||||
'${parsedValue?.toStringAsFixed(1) ?? '0'}',
|
||||
'moving_rigger_time' => '${parsedValue?.toStringAsFixed(3) ?? '0'}',
|
||||
'moving_static_time' ||
|
||||
'none_body_time' =>
|
||||
'${parsedValue?.toStringAsFixed(0) ?? '0'} s',
|
||||
'${parsedValue?.toStringAsFixed(0) ?? '0'}',
|
||||
_ => '${parsedValue ?? 0}',
|
||||
};
|
||||
}
|
||||
|
||||
String get _unit {
|
||||
return switch (selectedFunctionData.functionCode) {
|
||||
'moving_max_dis' ||
|
||||
'static_max_dis' ||
|
||||
'moving_range' ||
|
||||
'presence_range' ||
|
||||
'perceptual_boundary' ||
|
||||
'moving_boundary' =>
|
||||
'M',
|
||||
'moving_rigger_time' || 'moving_static_time' || 'none_body_time' => 'sec',
|
||||
_ => '',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user