diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 2e214c0..cd638e7 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -37,6 +37,17 @@ "equipment": "Equipment", "equipmentProfileName": "Equipment profile name", "equipmentProfileNameHint": "Praktica MTL5B", + "equipmentProfileValuesCount": "{count} values", + "@equipmentProfileValuesCount": { + "count": { + "min": { + "type": "int", + "format": "decimalPattern" + } + } + }, + + "equipmentProfileAllValues": "All", "apertureValues": "Aperture values", "apertureValuesFilterDescription": "Select the range of aperture values to display. This is usually determined by the lens you are using.", "ndFilters": "ND filters", 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 53f8559..3e936cd 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 @@ -35,6 +35,9 @@ class EquipmentListTiles extends StatelessWidget { title: S.of(context).isoValues, description: S.of(context).isoValuesFilterDescription, values: isoValues, + valuesCount: selectedIsoValues.length == isoValues.length + ? S.of(context).equipmentProfileAllValues + : S.of(context).equipmentProfileValuesCount(selectedIsoValues.length), selectedValues: selectedIsoValues, rangeSelect: false, onChanged: onIsoValuesSelecred, @@ -44,6 +47,9 @@ class EquipmentListTiles extends StatelessWidget { title: S.of(context).ndFilters, description: S.of(context).ndFiltersFilterDescription, values: ndValues, + valuesCount: selectedNdValues.length == ndValues.length + ? S.of(context).equipmentProfileAllValues + : S.of(context).equipmentProfileValuesCount(selectedNdValues.length), selectedValues: selectedNdValues, rangeSelect: false, onChanged: onNdValuesSelected, @@ -53,6 +59,9 @@ class EquipmentListTiles extends StatelessWidget { title: S.of(context).apertureValues, description: S.of(context).apertureValuesFilterDescription, values: apertureValues, + valuesCount: selectedApertureValues.length == apertureValues.length + ? S.of(context).equipmentProfileAllValues + : S.of(context).equipmentProfileValuesCount(selectedApertureValues.length), selectedValues: selectedApertureValues, rangeSelect: true, onChanged: onApertureValuesSelected, @@ -62,6 +71,9 @@ class EquipmentListTiles extends StatelessWidget { title: S.of(context).shutterSpeedValues, description: S.of(context).shutterSpeedValuesFilterDescription, values: shutterSpeedValues, + valuesCount: selectedShutterSpeedValues.length == shutterSpeedValues.length + ? S.of(context).equipmentProfileAllValues + : S.of(context).equipmentProfileValuesCount(selectedShutterSpeedValues.length), selectedValues: selectedShutterSpeedValues, rangeSelect: true, onChanged: onShutterSpeedValuesSelected, @@ -74,6 +86,7 @@ class EquipmentListTiles extends StatelessWidget { class _EquipmentListTile extends StatelessWidget { final IconData icon; final String title; + final String valuesCount; final String description; final List selectedValues; final List values; @@ -83,6 +96,7 @@ class _EquipmentListTile extends StatelessWidget { const _EquipmentListTile({ required this.icon, required this.title, + required this.valuesCount, required this.description, required this.selectedValues, required this.values, @@ -96,6 +110,7 @@ class _EquipmentListTile extends StatelessWidget { return ListTile( leading: Icon(icon), title: Text(title), + trailing: Text(valuesCount), onTap: () { showDialog( context: context, 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 d3e8dd0..0fd185b 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 @@ -1,18 +1,21 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; +import 'package:lightmeter/generated/l10n.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'components/equipment_list_tiles/widget_list_tiles_equipments.dart'; class EquipmentProfileContainer extends StatefulWidget { final EquipmentProfileData data; - final VoidCallback onExpand; + final ValueChanged onUpdate; final VoidCallback onDelete; + final VoidCallback onExpand; const EquipmentProfileContainer({ required this.data, - required this.onExpand, + required this.onUpdate, required this.onDelete, + required this.onExpand, super.key, }); @@ -21,7 +24,7 @@ class EquipmentProfileContainer extends StatefulWidget { } class EquipmentProfileContainerState extends State { - final TextEditingController _nameController = TextEditingController(text: 'Default'); + late final TextEditingController _nameController = TextEditingController(text: widget.data.name); final FocusNode _fieldFocusNode = FocusNode(); bool _expanded = false; @@ -57,8 +60,8 @@ class EquipmentProfileContainerState extends State { focusNode: _fieldFocusNode, controller: _nameController, onChanged: (value) {}, - decoration: const InputDecoration( - hintText: 'Profile name', + decoration: InputDecoration( + hintText: S.of(context).equipmentProfileNameHint, border: InputBorder.none, ), ), diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_name_dialog/widget_dialog_equipment_profile_name.dart b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_name_dialog/widget_dialog_equipment_profile_name.dart index caf62bb..40e9d78 100644 --- a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_name_dialog/widget_dialog_equipment_profile_name.dart +++ b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_name_dialog/widget_dialog_equipment_profile_name.dart @@ -34,7 +34,7 @@ class _EquipmentProfileNameDialogState extends State valueListenable: _nameController, builder: (_, value, __) => TextButton( onPressed: value.text.isNotEmpty - ? () => Navigator.of(context).pop(value.text.isNotEmpty) + ? () => Navigator.of(context).pop(value.text) : null, child: Text(S.of(context).save), ), diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart index be88b63..a200e65 100644 --- a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart +++ b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart @@ -17,7 +17,6 @@ class _EquipmentProfileScreenState extends State { static const maxProfiles = 5; // replace with a constant from iap late List> profileContainersKeys = []; - int get profilesCount => EquipmentProfiles.of(context)?.length ?? 0; @override @@ -56,32 +55,42 @@ class _EquipmentProfileScreenState extends State { key: profileContainersKeys[index], data: EquipmentProfiles.of(context)![index], onExpand: () => _keepExpandedAt(index), - onDelete: () { - EquipmentProfileProvider.of(context) - .deleteProfile(EquipmentProfiles.of(context)![index]); - profileContainersKeys.removeAt(index); - }, + onUpdate: _updateProfile, + onDelete: () => _removeProfileAt(index), ), ), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, floatingActionButton: profilesCount < maxProfiles ? FloatingActionButton( - onPressed: () { - showDialog(context: context, builder: (_) => const EquipmentProfileNameDialog()) - .then((value) { - if (value != null) { - EquipmentProfileProvider.of(context).addProfile(value); - profileContainersKeys.add(GlobalKey()); - } - }); - }, + onPressed: _addProfile, child: const Icon(Icons.add), ) : null, ); } + void _addProfile() { + showDialog( + context: context, + builder: (_) => const EquipmentProfileNameDialog(), + ).then((value) { + if (value != null) { + EquipmentProfileProvider.of(context).addProfile(value); + profileContainersKeys.add(GlobalKey()); + } + }); + } + + void _updateProfile(EquipmentProfileData data) { + // + } + + void _removeProfileAt(int index) { + EquipmentProfileProvider.of(context).deleteProfile(EquipmentProfiles.of(context)![index]); + profileContainersKeys.removeAt(index); + } + void _keepExpandedAt(int index) { profileContainersKeys.getRange(0, index).forEach((element) { element.currentState?.collapse();