From b6a7f68b5c5072c01a37aa81fbd9d8840776219c Mon Sep 17 00:00:00 2001 From: Vadim Date: Thu, 23 Mar 2023 08:05:28 +0300 Subject: [PATCH] added default equipment profile --- lib/providers/equipment_profile_provider.dart | 22 +++++++++---------- .../widget_container_readings.dart | 4 ++-- .../screen_equipment_profile.dart | 19 +++++++++------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/lib/providers/equipment_profile_provider.dart b/lib/providers/equipment_profile_provider.dart index fd09965..37b89df 100644 --- a/lib/providers/equipment_profile_provider.dart +++ b/lib/providers/equipment_profile_provider.dart @@ -16,18 +16,18 @@ class EquipmentProfileProvider extends StatefulWidget { } class EquipmentProfileProviderState extends State { - final List _profiles = []; + final List _profiles = [ + const EquipmentProfileData( + id: '', + name: '', + apertureValues: apertureValues, + ndValues: ndValues, + shutterSpeedValues: shutterSpeedValues, + isoValues: isoValues, + ) + ]; - late EquipmentProfileData _selectedProfile = _profiles.isNotEmpty - ? _profiles.first - : const EquipmentProfileData( - id: 'default', - name: '', - apertureValues: apertureValues, - ndValues: ndValues, - shutterSpeedValues: shutterSpeedValues, - isoValues: isoValues, - ); + late EquipmentProfileData _selectedProfile = _profiles.first; @override Widget build(BuildContext context) { diff --git a/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart b/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart index 4c9df9c..9a4edf4 100644 --- a/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart +++ b/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart @@ -105,12 +105,12 @@ class _EquipmentProfilePicker extends StatelessWidget { title: S.of(context).equipmentProfiles, selectedValue: selectedValue, values: values, - itemTitleBuilder: (_, value) => Text(value.name), + itemTitleBuilder: (_, value) => Text(value.id.isEmpty ? S.of(context).none : value.name), onChanged: onChanged, closedChild: ReadingValueContainer.singleValue( value: ReadingValue( label: S.of(context).equipmentProfiles, - value: selectedValue.name, + value: selectedValue.id.isEmpty ? S.of(context).none : selectedValue.name, ), ), ); 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 756d078..1a1763e 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 @@ -50,15 +50,18 @@ class _EquipmentProfilesScreenState extends State { Dimens.grid56 + kFloatingActionButtonMargin, ), - separatorBuilder: (context, index) => const SizedBox(height: Dimens.grid16), + separatorBuilder: (context, index) => + index > 0 ? const SizedBox(height: Dimens.grid16) : const SizedBox.shrink(), itemCount: profilesCount, - itemBuilder: (context, index) => EquipmentProfileContainer( - key: profileContainersKeys[index], - data: EquipmentProfiles.of(context)![index], - onExpand: () => _keepExpandedAt(index), - onUpdate: (profileData) => _updateProfileAt(profileData, index), - onDelete: () => _removeProfileAt(index), - ), + itemBuilder: (context, index) => index > 0 + ? EquipmentProfileContainer( + key: profileContainersKeys[index], + data: EquipmentProfiles.of(context)![index], + onExpand: () => _keepExpandedAt(index), + onUpdate: (profileData) => _updateProfileAt(profileData, index), + onDelete: () => _removeProfileAt(index), + ) + : const SizedBox.shrink(), ), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,