diff --git a/lib/screens/metering/components/camera_container/components/camera_controls/components/exposure_offset_slider/widget_slider_exposure_offset.dart b/lib/screens/metering/components/camera_container/components/camera_controls/components/exposure_offset_slider/widget_slider_exposure_offset.dart index b68673e..0d40881 100644 --- a/lib/screens/metering/components/camera_container/components/camera_controls/components/exposure_offset_slider/widget_slider_exposure_offset.dart +++ b/lib/screens/metering/components/camera_container/components/camera_controls/components/exposure_offset_slider/widget_slider_exposure_offset.dart @@ -1,39 +1,17 @@ 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 StatelessWidget { - final RangeValues range; - final double value; - final ValueChanged onChanged; - - const ExposureOffsetSlider({ - required this.range, - required this.value, - required this.onChanged, +class ExposureOffsetSlider extends RulerSlider { + ExposureOffsetSlider({ + required super.range, + required super.value, + required super.onChanged, super.key, - }); - - @override - Widget build(BuildContext context) { - return Column( - 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), - ), - ), - ], - ); - } + }) : super( + icon: Icons.light_mode, + defaultValue: 0, + rulerValueAdapter: (value) => value.toStringSignedAsFixed(0), + valueAdapter: (value) => value.toStringSignedAsFixed(1), + ); } diff --git a/lib/screens/metering/components/camera_container/components/camera_controls/components/zoom_slider/widget_slider_zoom.dart b/lib/screens/metering/components/camera_container/components/camera_controls/components/zoom_slider/widget_slider_zoom.dart index 7a30ea6..60c5b51 100644 --- a/lib/screens/metering/components/camera_container/components/camera_controls/components/zoom_slider/widget_slider_zoom.dart +++ b/lib/screens/metering/components/camera_container/components/camera_controls/components/zoom_slider/widget_slider_zoom.dart @@ -1,36 +1,16 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/screens/shared/ruler_slider/widget_slider_ruler.dart'; -class ZoomSlider extends StatelessWidget { - final RangeValues range; - final double value; - final ValueChanged onChanged; - - const ZoomSlider({ - required this.range, - required this.value, - required this.onChanged, +class ZoomSlider extends RulerSlider { + ZoomSlider({ + required super.range, + required super.value, + required super.onChanged, super.key, - }); - - @override - Widget build(BuildContext context) { - return Column( - 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', - ), - ), - ], - ); - } + }) : super( + icon: Icons.search, + defaultValue: range.start, + rulerValueAdapter: (value) => value.toStringAsFixed(0), + valueAdapter: (value) => 'x${value.toStringAsFixed(1)}', + ); } diff --git a/lib/screens/metering/components/camera_container/widget_container_camera.dart b/lib/screens/metering/components/camera_container/widget_container_camera.dart index c45de84..95cff57 100644 --- a/lib/screens/metering/components/camera_container/widget_container_camera.dart +++ b/lib/screens/metering/components/camera_container/widget_container_camera.dart @@ -159,9 +159,9 @@ class _CameraControlsBuilder extends StatelessWidget { return Padding( padding: const EdgeInsets.fromLTRB( Dimens.paddingL, - Dimens.paddingM, - 0, Dimens.paddingL, + 0, + Dimens.paddingM, ), child: BlocBuilder( builder: (context, state) { diff --git a/lib/screens/shared/ruler_slider/widget_slider_ruler.dart b/lib/screens/shared/ruler_slider/widget_slider_ruler.dart index 9c6e318..7603567 100644 --- a/lib/screens/shared/ruler_slider/widget_slider_ruler.dart +++ b/lib/screens/shared/ruler_slider/widget_slider_ruler.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/shared/centered_slider/widget_slider_centered.dart'; @@ -6,34 +7,55 @@ class RulerSlider extends StatelessWidget { final IconData icon; final RangeValues range; final double value; + final double defaultValue; final ValueChanged onChanged; final String Function(double value) rulerValueAdapter; + final String Function(double value) valueAdapter; const RulerSlider({ required this.icon, required this.range, required this.value, + required this.defaultValue, required this.onChanged, required this.rulerValueAdapter, + required this.valueAdapter, super.key, }); @override Widget build(BuildContext context) { - return Row( + return Column( children: [ - _Ruler( - range.start, - range.end, - rulerValueAdapter, + Text( + valueAdapter(value), + style: Theme.of(context).textTheme.labelLarge, ), - CenteredSlider( - isVertical: true, - icon: Icon(icon), - value: value, - min: range.start, - max: range.end, - onChanged: onChanged, + const SizedBox(height: Dimens.grid8), + Expanded( + child: Row( + children: [ + _Ruler( + range.start, + 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, ), ], );