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:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/screens/shared/ruler_slider/widget_slider_ruler.dart'; import 'package:lightmeter/screens/shared/ruler_slider/widget_slider_ruler.dart';
import 'package:lightmeter/utils/to_string_signed.dart'; import 'package:lightmeter/utils/to_string_signed.dart';
class ExposureOffsetSlider extends RulerSlider { class ExposureOffsetSlider extends StatelessWidget {
ExposureOffsetSlider({ final RangeValues range;
required super.range, final double value;
required super.value, final ValueChanged<double> onChanged;
required super.onChanged,
const ExposureOffsetSlider({
required this.range,
required this.value,
required this.onChanged,
super.key, super.key,
}) : super( });
icon: Icons.light_mode,
defaultValue: 0, @override
rulerValueAdapter: (value) => value.toStringSignedAsFixed(0), Widget build(BuildContext context) {
valueAdapter: (value) => value.toStringSignedAsFixed(1), 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:flutter/material.dart';
import 'package:lightmeter/screens/shared/ruler_slider/widget_slider_ruler.dart'; import 'package:lightmeter/screens/shared/ruler_slider/widget_slider_ruler.dart';
class ZoomSlider extends RulerSlider { class ZoomSlider extends StatelessWidget {
ZoomSlider({ final RangeValues range;
required super.range, final double value;
required super.value, final ValueChanged<double> onChanged;
required super.onChanged,
const ZoomSlider({
required this.range,
required this.value,
required this.onChanged,
super.key, super.key,
}) : super( });
icon: Icons.search,
defaultValue: range.start, @override
rulerValueAdapter: (value) => value.toStringAsFixed(0), Widget build(BuildContext context) {
valueAdapter: (value) => 'x${value.toStringAsFixed(1)}', 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Text( Text(
valueAdapter(value), valueAdapter(value),