mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Refactor SliderValueSelector layout for improved readability and maintainability
This commit is contained in:
@ -3,8 +3,6 @@ import 'package:flutter/services.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/condition_toggle.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/function_slider.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/value_display.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class SliderValueSelector extends StatelessWidget {
|
||||
final String? currentCondition;
|
||||
@ -32,88 +30,26 @@ class SliderValueSelector extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (dialogType == 'IF') {
|
||||
return Column(
|
||||
spacing: 16,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
return Column(
|
||||
spacing: 16,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (dialogType == 'IF')
|
||||
ConditionToggle(
|
||||
currentCondition: currentCondition,
|
||||
onChanged: onConditionChanged,
|
||||
),
|
||||
ValueDisplay(
|
||||
value: initialValue,
|
||||
label: displayedValue,
|
||||
unit: unit,
|
||||
),
|
||||
FunctionSlider(
|
||||
initialValue: initialValue,
|
||||
range: sliderRange,
|
||||
onChanged: onSliderChanged,
|
||||
dividendOfRange: dividendOfRange,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Spacer(),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextFormField(
|
||||
onChanged: (value) => onSliderChanged(double.tryParse(value) ?? 0),
|
||||
expands: false,
|
||||
onTapOutside: (_) => FocusScope.of(context).unfocus(),
|
||||
initialValue: displayedValue,
|
||||
style: context.textTheme.headlineMedium!.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
),
|
||||
inputFormatters: [
|
||||
RangeInputFormatter(min: sliderRange.$1, max: sliderRange.$2),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: ColorsManager.textFieldGreyColor.withOpacity(0.5),
|
||||
suffixText: unit,
|
||||
suffixStyle: context.textTheme.headlineMedium!.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Min: ${sliderRange.$1}',
|
||||
style: context.textTheme.labelSmall!.copyWith(
|
||||
color: ColorsManager.lightGrayColor,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
'Max: ${sliderRange.$2}',
|
||||
style: context.textTheme.labelSmall!.copyWith(
|
||||
color: ColorsManager.lightGrayColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
ValueDisplay(
|
||||
value: initialValue,
|
||||
label: displayedValue,
|
||||
unit: unit,
|
||||
),
|
||||
FunctionSlider(
|
||||
initialValue: initialValue,
|
||||
range: sliderRange,
|
||||
onChanged: onSliderChanged,
|
||||
dividendOfRange: dividendOfRange,
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user