mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 07:20:39 +00:00
show sliders values
This commit is contained in:
parent
26175c2c3e
commit
d6ed053079
4 changed files with 58 additions and 78 deletions
|
@ -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<double> 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),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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<double> 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)}',
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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<CameraContainerBloc, CameraContainerState>(
|
||||
builder: (context, state) {
|
||||
|
|
|
@ -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<double> 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,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue