mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 07:20:39 +00:00
show selected values count (wip)
This commit is contained in:
parent
24646987ee
commit
bf540e062a
5 changed files with 59 additions and 21 deletions
|
@ -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",
|
||||
|
|
|
@ -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<T extends PhotographyValue> extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String valuesCount;
|
||||
final String description;
|
||||
final List<T> selectedValues;
|
||||
final List<T> values;
|
||||
|
@ -83,6 +96,7 @@ class _EquipmentListTile<T extends PhotographyValue> 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<T extends PhotographyValue> extends StatelessWidget {
|
|||
return ListTile(
|
||||
leading: Icon(icon),
|
||||
title: Text(title),
|
||||
trailing: Text(valuesCount),
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
|
|
|
@ -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<EquipmentProfileData> 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<EquipmentProfileContainer> {
|
||||
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<EquipmentProfileContainer> {
|
|||
focusNode: _fieldFocusNode,
|
||||
controller: _nameController,
|
||||
onChanged: (value) {},
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Profile name',
|
||||
decoration: InputDecoration(
|
||||
hintText: S.of(context).equipmentProfileNameHint,
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
|
|
|
@ -34,7 +34,7 @@ class _EquipmentProfileNameDialogState extends State<EquipmentProfileNameDialog>
|
|||
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),
|
||||
),
|
||||
|
|
|
@ -17,7 +17,6 @@ class _EquipmentProfileScreenState extends State<EquipmentProfileScreen> {
|
|||
static const maxProfiles = 5; // replace with a constant from iap
|
||||
|
||||
late List<GlobalKey<EquipmentProfileContainerState>> profileContainersKeys = [];
|
||||
|
||||
int get profilesCount => EquipmentProfiles.of(context)?.length ?? 0;
|
||||
|
||||
@override
|
||||
|
@ -56,30 +55,40 @@ class _EquipmentProfileScreenState extends State<EquipmentProfileScreen> {
|
|||
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) {
|
||||
onPressed: _addProfile,
|
||||
child: const Icon(Icons.add),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
void _addProfile() {
|
||||
showDialog<String>(
|
||||
context: context,
|
||||
builder: (_) => const EquipmentProfileNameDialog(),
|
||||
).then((value) {
|
||||
if (value != null) {
|
||||
EquipmentProfileProvider.of(context).addProfile(value);
|
||||
profileContainersKeys.add(GlobalKey<EquipmentProfileContainerState>());
|
||||
}
|
||||
});
|
||||
},
|
||||
child: const Icon(Icons.add),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
void _updateProfile(EquipmentProfileData data) {
|
||||
//
|
||||
}
|
||||
|
||||
void _removeProfileAt(int index) {
|
||||
EquipmentProfileProvider.of(context).deleteProfile(EquipmentProfiles.of(context)![index]);
|
||||
profileContainersKeys.removeAt(index);
|
||||
}
|
||||
|
||||
void _keepExpandedAt(int index) {
|
||||
|
|
Loading…
Reference in a new issue