nc-photos/lib/widget/popup_menu_zoom.dart

53 lines
1.1 KiB
Dart
Raw Normal View History

2021-04-10 06:28:12 +02:00
import 'package:flutter/material.dart';
class PopupMenuZoom extends PopupMenuEntry<void> {
PopupMenuZoom({
Key key,
@required this.initialValue,
2021-04-28 14:55:26 +02:00
@required this.minValue,
@required this.maxValue,
2021-04-10 06:28:12 +02:00
this.onChanged,
}) : super(key: key);
@override
represents(void value) => false;
@override
createState() => _PopupMenuZoomState();
@override
// this value doesn't seems to do anything?
final double height = 48.0;
final int initialValue;
2021-04-28 14:55:26 +02:00
final double minValue;
final double maxValue;
2021-04-10 06:28:12 +02:00
final void Function(double) onChanged;
}
class _PopupMenuZoomState extends State<PopupMenuZoom> {
@override
initState() {
super.initState();
_value = widget.initialValue.toDouble();
}
@override
build(BuildContext context) {
return Slider(
value: _value,
2021-04-28 14:55:26 +02:00
min: widget.minValue,
max: widget.maxValue,
divisions: (widget.maxValue - widget.minValue).round(),
2021-04-10 06:28:12 +02:00
onChanged: (value) {
setState(() {
_value = value;
});
widget.onChanged?.call(value);
},
);
}
var _value = 0.0;
}