mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +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/condition_toggle.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/function_slider.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/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 {
|
class SliderValueSelector extends StatelessWidget {
|
||||||
final String? currentCondition;
|
final String? currentCondition;
|
||||||
@ -32,88 +30,26 @@ class SliderValueSelector extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (dialogType == 'IF') {
|
return Column(
|
||||||
return Column(
|
spacing: 16,
|
||||||
spacing: 16,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
||||||
children: [
|
if (dialogType == 'IF')
|
||||||
ConditionToggle(
|
ConditionToggle(
|
||||||
currentCondition: currentCondition,
|
currentCondition: currentCondition,
|
||||||
onChanged: onConditionChanged,
|
onChanged: onConditionChanged,
|
||||||
),
|
),
|
||||||
ValueDisplay(
|
ValueDisplay(
|
||||||
value: initialValue,
|
value: initialValue,
|
||||||
label: displayedValue,
|
label: displayedValue,
|
||||||
unit: unit,
|
unit: unit,
|
||||||
),
|
),
|
||||||
FunctionSlider(
|
FunctionSlider(
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
range: sliderRange,
|
range: sliderRange,
|
||||||
onChanged: onSliderChanged,
|
onChanged: onSliderChanged,
|
||||||
dividendOfRange: dividendOfRange,
|
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const Spacer(),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user