mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 15:30:59 +00:00
add profile with name
This commit is contained in:
parent
da02748806
commit
24646987ee
4 changed files with 58 additions and 5 deletions
|
@ -35,6 +35,8 @@
|
||||||
"camera": "Camera",
|
"camera": "Camera",
|
||||||
"lightSensor": "Light sensor",
|
"lightSensor": "Light sensor",
|
||||||
"equipment": "Equipment",
|
"equipment": "Equipment",
|
||||||
|
"equipmentProfileName": "Equipment profile name",
|
||||||
|
"equipmentProfileNameHint": "Praktica MTL5B",
|
||||||
"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",
|
||||||
|
|
|
@ -46,10 +46,10 @@ class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a default equipment profile
|
/// Creates a default equipment profile
|
||||||
void addProfile() {
|
void addProfile(String name) {
|
||||||
_profiles.add(const EquipmentProfileData(
|
_profiles.add(EquipmentProfileData(
|
||||||
id: 'default',
|
id: 'default',
|
||||||
name: '',
|
name: name,
|
||||||
apertureValues: apertureValues,
|
apertureValues: apertureValues,
|
||||||
ndValues: ndValues,
|
ndValues: ndValues,
|
||||||
shutterSpeedValues: shutterSpeedValues,
|
shutterSpeedValues: shutterSpeedValues,
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:lightmeter/generated/l10n.dart';
|
||||||
|
|
||||||
|
class EquipmentProfileNameDialog extends StatefulWidget {
|
||||||
|
const EquipmentProfileNameDialog({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<EquipmentProfileNameDialog> createState() => _EquipmentProfileNameDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _EquipmentProfileNameDialogState extends State<EquipmentProfileNameDialog> {
|
||||||
|
final TextEditingController _nameController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_nameController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(S.of(context).equipmentProfileName),
|
||||||
|
content: TextField(
|
||||||
|
controller: _nameController,
|
||||||
|
decoration: InputDecoration(hintText: S.of(context).equipmentProfileNameHint),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: Navigator.of(context).pop,
|
||||||
|
child: Text(S.of(context).cancel),
|
||||||
|
),
|
||||||
|
ValueListenableBuilder(
|
||||||
|
valueListenable: _nameController,
|
||||||
|
builder: (_, value, __) => TextButton(
|
||||||
|
onPressed: value.text.isNotEmpty
|
||||||
|
? () => Navigator.of(context).pop(value.text.isNotEmpty)
|
||||||
|
: null,
|
||||||
|
child: Text(S.of(context).save),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import 'package:lightmeter/providers/equipment_profile_provider.dart';
|
||||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
import 'components/equipment_profile_container/widget_container_equipment_profile.dart';
|
import 'components/equipment_profile_container/widget_container_equipment_profile.dart';
|
||||||
|
import 'components/equipment_profile_name_dialog/widget_dialog_equipment_profile_name.dart';
|
||||||
|
|
||||||
class EquipmentProfileScreen extends StatefulWidget {
|
class EquipmentProfileScreen extends StatefulWidget {
|
||||||
const EquipmentProfileScreen({super.key});
|
const EquipmentProfileScreen({super.key});
|
||||||
|
@ -67,8 +68,13 @@ class _EquipmentProfileScreenState extends State<EquipmentProfileScreen> {
|
||||||
floatingActionButton: profilesCount < maxProfiles
|
floatingActionButton: profilesCount < maxProfiles
|
||||||
? FloatingActionButton(
|
? FloatingActionButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
EquipmentProfileProvider.of(context).addProfile();
|
showDialog(context: context, builder: (_) => const EquipmentProfileNameDialog())
|
||||||
|
.then((value) {
|
||||||
|
if (value != null) {
|
||||||
|
EquipmentProfileProvider.of(context).addProfile(value);
|
||||||
profileContainersKeys.add(GlobalKey<EquipmentProfileContainerState>());
|
profileContainersKeys.add(GlobalKey<EquipmentProfileContainerState>());
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue