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 deleted file mode 100644 index d202b39..0000000 --- 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 +++ /dev/null @@ -1,146 +0,0 @@ -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 { - final List selectedApertureValues; - final List selectedIsoValues; - final List selectedNdValues; - final List selectedShutterSpeedValues; - final ValueChanged> onApertureValuesSelected; - final ValueChanged> onIsoValuesSelecred; - final ValueChanged> onNdValuesSelected; - final ValueChanged> onShutterSpeedValuesSelected; - - const EquipmentListTiles({ - required this.selectedApertureValues, - required this.selectedIsoValues, - required this.selectedNdValues, - required this.selectedShutterSpeedValues, - required this.onApertureValuesSelected, - required this.onIsoValuesSelecred, - required this.onNdValuesSelected, - required this.onShutterSpeedValuesSelected, - super.key, - }); - - @override - Widget build(BuildContext context) { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - _EquipmentListTile( - icon: Icons.iso, - title: S.of(context).isoValues, - description: S.of(context).isoValuesFilterDescription, - values: IsoValue.values, - selectedValues: selectedIsoValues, - rangeSelect: false, - onChanged: onIsoValuesSelecred, - ), - _EquipmentListTile( - icon: Icons.filter_b_and_w, - title: S.of(context).ndFilters, - description: S.of(context).ndFiltersFilterDescription, - values: NdValue.values, - selectedValues: selectedNdValues, - rangeSelect: false, - onChanged: onNdValuesSelected, - ), - _EquipmentListTile( - icon: Icons.camera, - title: S.of(context).apertureValues, - description: S.of(context).apertureValuesFilterDescription, - values: ApertureValue.values, - selectedValues: selectedApertureValues, - rangeSelect: true, - onChanged: onApertureValuesSelected, - ), - _EquipmentListTile( - icon: Icons.shutter_speed, - title: S.of(context).shutterSpeedValues, - description: S.of(context).shutterSpeedValuesFilterDescription, - values: ShutterSpeedValue.values, - selectedValues: selectedShutterSpeedValues, - 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)}', - ), - ], - ); - } -} - -class _EquipmentListTile extends StatelessWidget { - final IconData icon; - final String title; - final String description; - final List selectedValues; - final List values; - final ValueChanged> onChanged; - final bool rangeSelect; - - const _EquipmentListTile({ - required this.icon, - required this.title, - required this.description, - required this.selectedValues, - required this.values, - required this.onChanged, - required this.rangeSelect, - super.key, - }); - - @override - Widget build(BuildContext context) { - return ListTile( - leading: Icon(icon), - title: Text(title), - trailing: rangeSelect - ? Text("${selectedValues.first} - ${selectedValues.last}") - : Text( - values.length == selectedValues.length - ? S.of(context).equipmentProfileAllValues - : selectedValues.length.toString(), - ), - onTap: () { - showDialog>( - context: context, - builder: (_) => rangeSelect - ? DialogRangePicker( - icon: Icon(icon), - title: title, - description: description, - values: values, - selectedValues: selectedValues, - titleAdapter: (_, value) => value.toString(), - ) - : DialogFilter( - icon: Icon(icon), - title: title, - description: description, - values: values, - selectedValues: selectedValues, - titleAdapter: (_, value) => value.toString(), - ), - ).then((values) { - if (values != null) { - onChanged(values); - } - }); - }, - ); - } -} diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/filter_list_tile/widget_list_tile_filter.dart b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/filter_list_tile/widget_list_tile_filter.dart new file mode 100644 index 0000000..238f395 --- /dev/null +++ b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/filter_list_tile/widget_list_tile_filter.dart @@ -0,0 +1,53 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart'; +import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; + +class FilterListTile extends StatelessWidget { + final IconData icon; + final String title; + final String description; + final List selectedValues; + final List values; + final ValueChanged> onChanged; + + const FilterListTile({ + required this.icon, + required this.title, + required this.description, + required this.selectedValues, + required this.values, + required this.onChanged, + super.key, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + leading: Icon(icon), + title: Text(title), + trailing: Text( + values.length == selectedValues.length + ? S.of(context).equipmentProfileAllValues + : selectedValues.length.toString(), + ), + onTap: () { + showDialog>( + context: context, + builder: (_) => DialogFilter( + icon: Icon(icon), + title: title, + description: description, + values: values, + selectedValues: selectedValues, + titleAdapter: (_, value) => value.toString(), + ), + ).then((values) { + if (values != null) { + onChanged(values); + } + }); + }, + ); + } +} diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/range_picker_list_tile/widget_list_tile_range_picker.dart b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/range_picker_list_tile/widget_list_tile_range_picker.dart new file mode 100644 index 0000000..bad6081 --- /dev/null +++ b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/range_picker_list_tile/widget_list_tile_range_picker.dart @@ -0,0 +1,48 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/screens/settings/components/shared/dialog_range_picker/widget_dialog_picker_range.dart'; +import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; + +class RangePickerListTile extends StatelessWidget { + final IconData icon; + final String title; + final String description; + final List selectedValues; + final List values; + final ValueChanged> onChanged; + + const RangePickerListTile({ + required this.icon, + required this.title, + required this.description, + required this.selectedValues, + required this.values, + required this.onChanged, + super.key, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + leading: Icon(icon), + title: Text(title), + trailing: Text("${selectedValues.first} - ${selectedValues.last}"), + onTap: () { + showDialog>( + context: context, + builder: (_) => DialogRangePicker( + icon: Icon(icon), + title: title, + description: description, + values: values, + selectedValues: selectedValues, + titleAdapter: (_, value) => value.toString(), + ), + ).then((values) { + if (values != null) { + onChanged(values); + } + }); + }, + ); + } +} 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 110ea64..7e807f6 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 @@ -4,7 +4,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/res/dimens.dart'; -import 'package:lightmeter/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/equipment_list_tiles/widget_list_tiles_equipments.dart'; +import 'package:lightmeter/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/filter_list_tile/widget_list_tile_filter.dart'; +import 'package:lightmeter/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/components/range_picker_list_tile/widget_list_tile_range_picker.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/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_name_dialog/widget_dialog_equipment_profile_name.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; @@ -28,8 +30,7 @@ class EquipmentProfileContainer extends StatefulWidget { State createState() => EquipmentProfileContainerState(); } -class EquipmentProfileContainerState extends State - with TickerProviderStateMixin { +class EquipmentProfileContainerState extends State with TickerProviderStateMixin { late EquipmentProfile _equipmentData = EquipmentProfile( id: widget.data.id, name: widget.data.name, @@ -37,6 +38,7 @@ class EquipmentProfileContainerState extends State ndValues: widget.data.ndValues, shutterSpeedValues: widget.data.shutterSpeedValues, isoValues: widget.data.isoValues, + lensZoom: widget.data.lensZoom, ); late final AnimationController _controller = AnimationController( @@ -55,6 +57,7 @@ class EquipmentProfileContainerState extends State ndValues: widget.data.ndValues, shutterSpeedValues: widget.data.shutterSpeedValues, isoValues: widget.data.isoValues, + lensZoom: widget.data.lensZoom, ); } @@ -113,6 +116,10 @@ class EquipmentProfileContainerState extends State _equipmentData = _equipmentData.copyWith(shutterSpeedValues: value); widget.onUpdate(_equipmentData); }, + onLensZoomChanged: (value) { + _equipmentData = _equipmentData.copyWith(lensZoom: value); + widget.onUpdate(_equipmentData); + }, onCopy: widget.onCopy, onDelete: widget.onDelete, ), @@ -154,8 +161,7 @@ class EquipmentProfileContainerState extends State } class _AnimatedNameLeading extends AnimatedWidget { - const _AnimatedNameLeading({required AnimationController controller}) - : super(listenable: controller); + const _AnimatedNameLeading({required AnimationController controller}) : super(listenable: controller); Animation get _progress => listenable as Animation; @@ -200,6 +206,7 @@ class _AnimatedEquipmentListTiles extends AnimatedWidget { final ValueChanged> onIsoValuesSelecred; final ValueChanged> onNdValuesSelected; final ValueChanged> onShutterSpeedValuesSelected; + final ValueChanged onLensZoomChanged; final VoidCallback onCopy; final VoidCallback onDelete; @@ -210,6 +217,7 @@ class _AnimatedEquipmentListTiles extends AnimatedWidget { required this.onIsoValuesSelecred, required this.onNdValuesSelected, required this.onShutterSpeedValuesSelected, + required this.onLensZoomChanged, required this.onCopy, required this.onDelete, }) : super(listenable: controller); @@ -229,15 +237,46 @@ class _AnimatedEquipmentListTiles extends AnimatedWidget { opacity: _progress.value, child: Column( children: [ - EquipmentListTiles( - selectedApertureValues: equipmentData.apertureValues, - selectedIsoValues: equipmentData.isoValues, - selectedNdValues: equipmentData.ndValues, - selectedShutterSpeedValues: equipmentData.shutterSpeedValues, - onApertureValuesSelected: onApertureValuesSelected, - onIsoValuesSelecred: onIsoValuesSelecred, - onNdValuesSelected: onNdValuesSelected, - onShutterSpeedValuesSelected: onShutterSpeedValuesSelected, + FilterListTile( + icon: Icons.iso, + title: S.of(context).isoValues, + description: S.of(context).isoValuesFilterDescription, + values: IsoValue.values, + selectedValues: equipmentData.isoValues, + onChanged: onIsoValuesSelecred, + ), + FilterListTile( + icon: Icons.filter_b_and_w, + title: S.of(context).ndFilters, + description: S.of(context).ndFiltersFilterDescription, + values: NdValue.values, + selectedValues: equipmentData.ndValues, + onChanged: onNdValuesSelected, + ), + RangePickerListTile( + icon: Icons.camera, + title: S.of(context).apertureValues, + description: S.of(context).apertureValuesFilterDescription, + values: ApertureValue.values, + selectedValues: equipmentData.apertureValues, + onChanged: onApertureValuesSelected, + ), + RangePickerListTile( + icon: Icons.shutter_speed, + title: S.of(context).shutterSpeedValues, + description: S.of(context).shutterSpeedValuesFilterDescription, + values: ShutterSpeedValue.values, + selectedValues: equipmentData.shutterSpeedValues, + onChanged: onShutterSpeedValuesSelected, + ), + SliderPickerListTile( + icon: Icons.zoom_in, + title: S.of(context).lensZoom, + description: S.of(context).lensZoomDescription, + value: equipmentData.lensZoom, + range: const RangeValues(1, 7), + onChanged: onLensZoomChanged, + valueAdapter: (context, value) => 'x${value.toStringAsFixed(2)}', ), ListTile( contentPadding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM),