This repository has been archived on 2023-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
ha_client/lib/entities/universal_slider.widget.dart

58 lines
1.5 KiB
Dart
Raw Normal View History

2019-09-09 18:50:35 +03:00
part of '../main.dart';
2018-11-17 22:40:33 +02:00
class UniversalSlider extends StatelessWidget {
final onChanged;
final onChangeEnd;
final Widget leading;
final Widget closing;
final String title;
final double min;
final double max;
final double value;
2019-02-10 17:15:52 +02:00
final EdgeInsets padding;
2018-11-17 22:40:33 +02:00
2019-02-10 17:15:52 +02:00
const UniversalSlider({Key key, this.onChanged, this.onChangeEnd, this.leading, this.closing, this.title, this.min, this.max, this.value, this.padding: const EdgeInsets.fromLTRB(Sizes.leftWidgetPadding, Sizes.rowPadding, Sizes.rightWidgetPadding, 0.0)}) : super(key: key);
2018-11-17 22:40:33 +02:00
@override
Widget build(BuildContext context) {
List <Widget> row = [];
if (leading != null) {
row.add(leading);
}
row.add(
Flexible(
child: Slider(
value: value,
min: min,
max: max,
onChanged: (value) => onChanged(value),
onChangeEnd: (value) => onChangeEnd(value),
),
)
);
if (closing != null) {
row.add(closing);
}
2019-02-10 17:15:52 +02:00
return Padding(
padding: padding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(height: Sizes.rowPadding,),
Text(
"$title",
style: TextStyle(fontSize: Sizes.stateFontSize),
),
Container(height: Sizes.rowPadding,),
Row(
mainAxisSize: MainAxisSize.min,
children: row,
),
Container(height: Sizes.rowPadding,)
],
),
2018-11-17 22:40:33 +02:00
);
}
}