From 37219920a5ba2ced6c30df91ac0b1793f4b84207 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Sat, 6 Apr 2024 22:32:08 +0200 Subject: [PATCH] added zoom slider to equipment profiles settings --- lib/l10n/intl_en.arb | 2 + .../widget_list_tiles_equipments.dart | 11 +++ .../widget_list_tile_slider_picker.dart | 49 +++++++++++ .../widget_container_equipment_profile.dart | 2 +- .../widget_dialog_slider_picker.dart | 85 +++++++++++++++++++ 5 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/slider_picker_list_tile/widget_list_tile_slider_picker.dart create mode 100644 lib/screens/settings/components/shared/dialog_slider_picker/widget_dialog_slider_picker.dart diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 2f12693..ba429c9 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -60,6 +60,8 @@ "shutterSpeedValuesFilterDescription": "Select the range of shutter speed values to display. This is usually determined by the camera body you are using.", "isoValues": "ISO values", "isoValuesFilterDescription": "Select the ISO values to display. These may be your most commonly used values or those supported by your camera.", + "lensZoom": "Lens zoom", + "lensZoomDescription": "Set the zoom level relative to the phone's camera to match your camera's viewfinder.", "equipmentProfile": "Equipment profile", "equipmentProfiles": "Equipment profiles", "tapToAdd": "Tap to add", diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/equipment_list_tiles/widget_list_tiles_equipments.dart b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/equipment_list_tiles/widget_list_tiles_equipments.dart index bb3651d..d202b39 100644 --- a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/equipment_list_tiles/widget_list_tiles_equipments.dart +++ b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/equipment_list_tiles/widget_list_tiles_equipments.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/slider_picker_list_tile/widget_list_tile_slider_picker.dart'; import 'package:lightmeter/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart'; import 'package:lightmeter/screens/settings/components/shared/dialog_range_picker/widget_dialog_picker_range.dart'; +import 'package:lightmeter/screens/settings/components/shared/dialog_slider_picker/widget_dialog_slider_picker.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; class EquipmentListTiles extends StatelessWidget { @@ -67,6 +69,15 @@ class EquipmentListTiles extends StatelessWidget { rangeSelect: true, onChanged: onShutterSpeedValuesSelected, ), + SliderPickerListTile( + icon: Icons.zoom_in, + title: S.of(context).lensZoom, + description: S.of(context).lensZoomDescription, + value: 1.0, + range: const RangeValues(1, 7), + onChanged: (value) {}, + valueAdapter: (context, value) => 'x${value.toStringAsFixed(2)}', + ), ], ); } diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/slider_picker_list_tile/widget_list_tile_slider_picker.dart b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/slider_picker_list_tile/widget_list_tile_slider_picker.dart new file mode 100644 index 0000000..a651e99 --- /dev/null +++ b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/slider_picker_list_tile/widget_list_tile_slider_picker.dart @@ -0,0 +1,49 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/screens/settings/components/shared/dialog_slider_picker/widget_dialog_slider_picker.dart'; + +class SliderPickerListTile extends StatelessWidget { + final IconData icon; + final String title; + final String description; + final double value; + final RangeValues range; + final ValueChanged onChanged; + final String Function(BuildContext, double) valueAdapter; + + const SliderPickerListTile({ + required this.icon, + required this.title, + required this.description, + required this.value, + required this.range, + required this.onChanged, + required this.valueAdapter, + super.key, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + leading: Icon(icon), + title: Text(title), + trailing: Text(value.toString()), + onTap: () { + showDialog( + context: context, + builder: (_) => DialogSliderPicker( + icon: Icon(icon), + title: title, + description: description, + value: value, + range: range, + valueAdapter: valueAdapter, + ), + ).then((value) { + if (value != null) { + onChanged(value); + } + }); + }, + ); + } +} diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/widget_container_equipment_profile.dart b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/widget_container_equipment_profile.dart index 48a9c80..110ea64 100644 --- a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/widget_container_equipment_profile.dart +++ b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/widget_container_equipment_profile.dart @@ -222,7 +222,7 @@ class _AnimatedEquipmentListTiles extends AnimatedWidget { alignment: Alignment.topCenter, size: Size( double.maxFinite, - _progress.value * Dimens.grid56 * 5, + _progress.value * Dimens.grid56 * 6, ), // https://github.com/gskinnerTeam/flutter-folio/pull/62 child: Opacity( diff --git a/lib/screens/settings/components/shared/dialog_slider_picker/widget_dialog_slider_picker.dart b/lib/screens/settings/components/shared/dialog_slider_picker/widget_dialog_slider_picker.dart new file mode 100644 index 0000000..7923e95 --- /dev/null +++ b/lib/screens/settings/components/shared/dialog_slider_picker/widget_dialog_slider_picker.dart @@ -0,0 +1,85 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/res/dimens.dart'; + +class DialogSliderPicker extends StatefulWidget { + final Icon icon; + final String title; + final String description; + final double value; + final RangeValues range; + final String Function(BuildContext context, double value) valueAdapter; + + const DialogSliderPicker({ + required this.icon, + required this.title, + required this.description, + required this.value, + required this.range, + required this.valueAdapter, + super.key, + }); + + @override + State createState() => _DialogSliderPickerState(); +} + +class _DialogSliderPickerState extends State { + late double value = widget.value; + + @override + Widget build(BuildContext context) { + return AlertDialog( + icon: widget.icon, + titlePadding: Dimens.dialogIconTitlePadding, + title: Text(widget.title), + contentPadding: EdgeInsets.zero, + content: SizedBox( + width: double.maxFinite, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: Dimens.dialogIconTitlePadding, + child: Text(widget.description), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingL), + child: Text( + widget.valueAdapter(context, value), + style: Theme.of(context).textTheme.bodyLarge, + ), + ), + Row( + children: [ + Expanded( + child: Slider( + value: value, + min: widget.range.start, + max: widget.range.end, + onChanged: (value) { + setState(() { + this.value = value; + }); + }, + ), + ), + ], + ), + ], + ), + ), + actionsPadding: Dimens.dialogActionsPadding, + actions: [ + TextButton( + onPressed: Navigator.of(context).pop, + child: Text(S.of(context).cancel), + ), + TextButton( + onPressed: () => Navigator.of(context).pop(value), + child: Text(S.of(context).save), + ), + ], + ); + } +}