show sliders values

This commit is contained in:
Vadim 2024-03-22 17:42:11 +01:00
parent 26175c2c3e
commit d6ed053079
4 changed files with 58 additions and 78 deletions

View file

@ -1,39 +1,17 @@
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 StatelessWidget { class ExposureOffsetSlider extends RulerSlider {
final RangeValues range; ExposureOffsetSlider({
final double value; required super.range,
final ValueChanged<double> onChanged; required super.value,
required super.onChanged,
const ExposureOffsetSlider({
required this.range,
required this.value,
required this.onChanged,
super.key, super.key,
}); }) : super(
icon: Icons.light_mode,
@override defaultValue: 0,
Widget build(BuildContext context) { rulerValueAdapter: (value) => value.toStringSignedAsFixed(0),
return Column( valueAdapter: (value) => value.toStringSignedAsFixed(1),
children: [ );
IconButton(
icon: const Icon(Icons.sync),
onPressed: value != 0.0 ? () => onChanged(0.0) : null,
tooltip: S.of(context).tooltipResetToZero,
),
Expanded(
child: RulerSlider(
icon: Icons.light_mode,
range: range,
value: value,
onChanged: onChanged,
rulerValueAdapter: (value) => value.toStringSignedAsFixed(0),
),
),
],
);
}
} }

View file

@ -1,36 +1,16 @@
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 StatelessWidget { class ZoomSlider extends RulerSlider {
final RangeValues range; ZoomSlider({
final double value; required super.range,
final ValueChanged<double> onChanged; required super.value,
required super.onChanged,
const ZoomSlider({
required this.range,
required this.value,
required this.onChanged,
super.key, super.key,
}); }) : super(
icon: Icons.search,
@override defaultValue: range.start,
Widget build(BuildContext context) { rulerValueAdapter: (value) => value.toStringAsFixed(0),
return Column( valueAdapter: (value) => 'x${value.toStringAsFixed(1)}',
children: [ );
const IconButton(
icon: Icon(Icons.lock_open),
onPressed: null,
),
Expanded(
child: RulerSlider(
icon: Icons.search,
range: range,
value: value,
onChanged: onChanged,
rulerValueAdapter: (value) => '${value.toStringAsFixed(0)}x',
),
),
],
);
}
} }

View file

@ -159,9 +159,9 @@ class _CameraControlsBuilder extends StatelessWidget {
return Padding( return Padding(
padding: const EdgeInsets.fromLTRB( padding: const EdgeInsets.fromLTRB(
Dimens.paddingL, Dimens.paddingL,
Dimens.paddingM,
0,
Dimens.paddingL, Dimens.paddingL,
0,
Dimens.paddingM,
), ),
child: BlocBuilder<CameraContainerBloc, CameraContainerState>( child: BlocBuilder<CameraContainerBloc, CameraContainerState>(
builder: (context, state) { builder: (context, state) {

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/screens/shared/centered_slider/widget_slider_centered.dart'; import 'package:lightmeter/screens/shared/centered_slider/widget_slider_centered.dart';
@ -6,34 +7,55 @@ class RulerSlider extends StatelessWidget {
final IconData icon; final IconData icon;
final RangeValues range; final RangeValues range;
final double value; final double value;
final double defaultValue;
final ValueChanged<double> onChanged; final ValueChanged<double> onChanged;
final String Function(double value) rulerValueAdapter; final String Function(double value) rulerValueAdapter;
final String Function(double value) valueAdapter;
const RulerSlider({ const RulerSlider({
required this.icon, required this.icon,
required this.range, required this.range,
required this.value, required this.value,
required this.defaultValue,
required this.onChanged, required this.onChanged,
required this.rulerValueAdapter, required this.rulerValueAdapter,
required this.valueAdapter,
super.key, super.key,
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return Column(
children: [ children: [
_Ruler( Text(
range.start, valueAdapter(value),
range.end, style: Theme.of(context).textTheme.labelLarge,
rulerValueAdapter,
), ),
CenteredSlider( const SizedBox(height: Dimens.grid8),
isVertical: true, Expanded(
icon: Icon(icon), child: Row(
value: value, children: [
min: range.start, _Ruler(
max: range.end, range.start,
onChanged: onChanged, range.end,
rulerValueAdapter,
),
CenteredSlider(
isVertical: true,
icon: Icon(icon),
value: value,
min: range.start,
max: range.end,
onChanged: onChanged,
),
],
),
),
const SizedBox(height: Dimens.grid4),
IconButton(
icon: const Icon(Icons.sync),
onPressed: value != defaultValue ? () => onChanged(defaultValue) : null,
tooltip: S.of(context).tooltipResetToZero,
), ),
], ],
); );