mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 23:10:40 +00:00
split EquipmentListTiles
widget
This commit is contained in:
parent
37219920a5
commit
fe98bf163f
4 changed files with 154 additions and 160 deletions
|
@ -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<ApertureValue> selectedApertureValues;
|
||||
final List<IsoValue> selectedIsoValues;
|
||||
final List<NdValue> selectedNdValues;
|
||||
final List<ShutterSpeedValue> selectedShutterSpeedValues;
|
||||
final ValueChanged<List<ApertureValue>> onApertureValuesSelected;
|
||||
final ValueChanged<List<IsoValue>> onIsoValuesSelecred;
|
||||
final ValueChanged<List<NdValue>> onNdValuesSelected;
|
||||
final ValueChanged<List<ShutterSpeedValue>> 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<IsoValue>(
|
||||
icon: Icons.iso,
|
||||
title: S.of(context).isoValues,
|
||||
description: S.of(context).isoValuesFilterDescription,
|
||||
values: IsoValue.values,
|
||||
selectedValues: selectedIsoValues,
|
||||
rangeSelect: false,
|
||||
onChanged: onIsoValuesSelecred,
|
||||
),
|
||||
_EquipmentListTile<NdValue>(
|
||||
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<ApertureValue>(
|
||||
icon: Icons.camera,
|
||||
title: S.of(context).apertureValues,
|
||||
description: S.of(context).apertureValuesFilterDescription,
|
||||
values: ApertureValue.values,
|
||||
selectedValues: selectedApertureValues,
|
||||
rangeSelect: true,
|
||||
onChanged: onApertureValuesSelected,
|
||||
),
|
||||
_EquipmentListTile<ShutterSpeedValue>(
|
||||
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<T extends PhotographyValue> extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String description;
|
||||
final List<T> selectedValues;
|
||||
final List<T> values;
|
||||
final ValueChanged<List<T>> 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<List<T>>(
|
||||
context: context,
|
||||
builder: (_) => rangeSelect
|
||||
? DialogRangePicker<T>(
|
||||
icon: Icon(icon),
|
||||
title: title,
|
||||
description: description,
|
||||
values: values,
|
||||
selectedValues: selectedValues,
|
||||
titleAdapter: (_, value) => value.toString(),
|
||||
)
|
||||
: DialogFilter<T>(
|
||||
icon: Icon(icon),
|
||||
title: title,
|
||||
description: description,
|
||||
values: values,
|
||||
selectedValues: selectedValues,
|
||||
titleAdapter: (_, value) => value.toString(),
|
||||
),
|
||||
).then((values) {
|
||||
if (values != null) {
|
||||
onChanged(values);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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<T extends PhotographyValue> extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String description;
|
||||
final List<T> selectedValues;
|
||||
final List<T> values;
|
||||
final ValueChanged<List<T>> 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<List<T>>(
|
||||
context: context,
|
||||
builder: (_) => DialogFilter<T>(
|
||||
icon: Icon(icon),
|
||||
title: title,
|
||||
description: description,
|
||||
values: values,
|
||||
selectedValues: selectedValues,
|
||||
titleAdapter: (_, value) => value.toString(),
|
||||
),
|
||||
).then((values) {
|
||||
if (values != null) {
|
||||
onChanged(values);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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<T extends PhotographyValue> extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String description;
|
||||
final List<T> selectedValues;
|
||||
final List<T> values;
|
||||
final ValueChanged<List<T>> 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<List<T>>(
|
||||
context: context,
|
||||
builder: (_) => DialogRangePicker<T>(
|
||||
icon: Icon(icon),
|
||||
title: title,
|
||||
description: description,
|
||||
values: values,
|
||||
selectedValues: selectedValues,
|
||||
titleAdapter: (_, value) => value.toString(),
|
||||
),
|
||||
).then((values) {
|
||||
if (values != null) {
|
||||
onChanged(values);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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<EquipmentProfileContainer> createState() => EquipmentProfileContainerState();
|
||||
}
|
||||
|
||||
class EquipmentProfileContainerState extends State<EquipmentProfileContainer>
|
||||
with TickerProviderStateMixin {
|
||||
class EquipmentProfileContainerState extends State<EquipmentProfileContainer> with TickerProviderStateMixin {
|
||||
late EquipmentProfile _equipmentData = EquipmentProfile(
|
||||
id: widget.data.id,
|
||||
name: widget.data.name,
|
||||
|
@ -37,6 +38,7 @@ class EquipmentProfileContainerState extends State<EquipmentProfileContainer>
|
|||
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<EquipmentProfileContainer>
|
|||
ndValues: widget.data.ndValues,
|
||||
shutterSpeedValues: widget.data.shutterSpeedValues,
|
||||
isoValues: widget.data.isoValues,
|
||||
lensZoom: widget.data.lensZoom,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -113,6 +116,10 @@ class EquipmentProfileContainerState extends State<EquipmentProfileContainer>
|
|||
_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<EquipmentProfileContainer>
|
|||
}
|
||||
|
||||
class _AnimatedNameLeading extends AnimatedWidget {
|
||||
const _AnimatedNameLeading({required AnimationController controller})
|
||||
: super(listenable: controller);
|
||||
const _AnimatedNameLeading({required AnimationController controller}) : super(listenable: controller);
|
||||
|
||||
Animation<double> get _progress => listenable as Animation<double>;
|
||||
|
||||
|
@ -200,6 +206,7 @@ class _AnimatedEquipmentListTiles extends AnimatedWidget {
|
|||
final ValueChanged<List<IsoValue>> onIsoValuesSelecred;
|
||||
final ValueChanged<List<NdValue>> onNdValuesSelected;
|
||||
final ValueChanged<List<ShutterSpeedValue>> onShutterSpeedValuesSelected;
|
||||
final ValueChanged<double> 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<IsoValue>(
|
||||
icon: Icons.iso,
|
||||
title: S.of(context).isoValues,
|
||||
description: S.of(context).isoValuesFilterDescription,
|
||||
values: IsoValue.values,
|
||||
selectedValues: equipmentData.isoValues,
|
||||
onChanged: onIsoValuesSelecred,
|
||||
),
|
||||
FilterListTile<NdValue>(
|
||||
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<ApertureValue>(
|
||||
icon: Icons.camera,
|
||||
title: S.of(context).apertureValues,
|
||||
description: S.of(context).apertureValuesFilterDescription,
|
||||
values: ApertureValue.values,
|
||||
selectedValues: equipmentData.apertureValues,
|
||||
onChanged: onApertureValuesSelected,
|
||||
),
|
||||
RangePickerListTile<ShutterSpeedValue>(
|
||||
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),
|
||||
|
|
Loading…
Reference in a new issue