63 lines
1.6 KiB
Dart
63 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/Components/rounded_input_field.dart';
|
|
import 'package:manager_app/constants.dart';
|
|
|
|
class SliderInputContainer extends StatefulWidget {
|
|
final Color color;
|
|
final String label;
|
|
final double initialValue;
|
|
final int min;
|
|
final int max;
|
|
final ValueChanged<double> onChanged;
|
|
const SliderInputContainer({
|
|
Key key,
|
|
this.color = kSecond,
|
|
this.label,
|
|
this.initialValue,
|
|
this.min,
|
|
this.max,
|
|
this.onChanged,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
_SliderInputContainerState createState() => _SliderInputContainerState();
|
|
}
|
|
|
|
class _SliderInputContainerState extends State<SliderInputContainer> {
|
|
double currentValue;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
currentValue = widget.initialValue;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
child: Row(
|
|
children: [
|
|
Align(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
child: Text(widget.label, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: Slider(
|
|
value: currentValue,
|
|
onChanged: (value) {
|
|
setState(() => currentValue = value);
|
|
widget.onChanged(value);
|
|
},
|
|
divisions: widget.max - widget.min,
|
|
min: widget.min.toDouble(),
|
|
max: widget.max.toDouble(),
|
|
label: "$currentValue",
|
|
activeColor: widget.color,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |