more accurate sliders values

This commit is contained in:
Vadim 2024-03-22 22:53:28 +01:00
parent 5614ef8ef3
commit cb220f9e9e
3 changed files with 48 additions and 22 deletions

View file

@ -1,17 +1,30 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/screens/shared/ruler_slider/widget_slider_ruler.dart';
import 'package:lightmeter/utils/to_string_signed.dart';
class ExposureOffsetSlider extends RulerSlider {
ExposureOffsetSlider({
required super.range,
required super.value,
required super.onChanged,
class ExposureOffsetSlider extends StatelessWidget {
final RangeValues range;
final double value;
final ValueChanged<double> onChanged;
const ExposureOffsetSlider({
required this.range,
required this.value,
required this.onChanged,
super.key,
}) : super(
icon: Icons.light_mode,
defaultValue: 0,
rulerValueAdapter: (value) => value.toStringSignedAsFixed(0),
valueAdapter: (value) => value.toStringSignedAsFixed(1),
);
});
@override
Widget build(BuildContext context) {
return RulerSlider(
range: range,
value: value,
onChanged: onChanged,
icon: Icons.light_mode,
defaultValue: 0,
rulerValueAdapter: (value) => value.toStringSignedAsFixed(0),
valueAdapter: (value) => S.of(context).evValue(value.toStringSignedAsFixed(1)),
);
}
}

View file

@ -1,16 +1,28 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/screens/shared/ruler_slider/widget_slider_ruler.dart';
class ZoomSlider extends RulerSlider {
ZoomSlider({
required super.range,
required super.value,
required super.onChanged,
class ZoomSlider extends StatelessWidget {
final RangeValues range;
final double value;
final ValueChanged<double> onChanged;
const ZoomSlider({
required this.range,
required this.value,
required this.onChanged,
super.key,
}) : super(
icon: Icons.search,
defaultValue: range.start,
rulerValueAdapter: (value) => value.toStringAsFixed(0),
valueAdapter: (value) => 'x${value.toStringAsFixed(1)}',
);
});
@override
Widget build(BuildContext context) {
return RulerSlider(
range: range,
value: value,
onChanged: onChanged,
icon: Icons.search,
defaultValue: range.start,
rulerValueAdapter: (value) => value.toStringAsFixed(0),
valueAdapter: (value) => 'x${value.toStringAsFixed(2)}',
);
}
}

View file

@ -26,6 +26,7 @@ class RulerSlider extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
valueAdapter(value),