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