From 0ff9249f8f7af8cd4620bd47d1cd5197c8f743ad Mon Sep 17 00:00:00 2001 From: Vadim Date: Sat, 1 Apr 2023 19:15:30 +0300 Subject: [PATCH] added `FeaturesConfig` --- lib/features.dart | 3 ++ lib/res/dimens.dart | 2 +- .../widget_container_camera.dart | 3 +- .../widget_container_readings.dart | 54 ++++++++++++------- .../widget_settings_section_metering.dart | 3 +- 5 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 lib/features.dart diff --git a/lib/features.dart b/lib/features.dart new file mode 100644 index 0000000..deede30 --- /dev/null +++ b/lib/features.dart @@ -0,0 +1,3 @@ +class FeaturesConfig { + static const bool equipmentProfilesEnabled = false; +} diff --git a/lib/res/dimens.dart b/lib/res/dimens.dart index ce931e2..61d79b5 100644 --- a/lib/res/dimens.dart +++ b/lib/res/dimens.dart @@ -32,7 +32,7 @@ class Dimens { // TopBar /// Probably this is a bad practice, but with text size locked, the height is always 212 static const double readingContainerSingleValueHeight = 76; - static const double readingContainerDefaultHeight = 212; + static const double readingContainerDefaultHeight = 288; // `CenteredSlider` static const double cameraSliderTrackHeight = grid4; diff --git a/lib/screens/metering/components/camera_container/widget_container_camera.dart b/lib/screens/metering/components/camera_container/widget_container_camera.dart index 8aacb4e..185262d 100644 --- a/lib/screens/metering/components/camera_container/widget_container_camera.dart +++ b/lib/screens/metering/components/camera_container/widget_container_camera.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; +import 'package:lightmeter/features.dart'; import 'package:lightmeter/platform_config.dart'; import 'package:lightmeter/providers/equipment_profile_provider.dart'; import 'package:lightmeter/res/dimens.dart'; @@ -49,7 +50,7 @@ class CameraContainer extends StatelessWidget { PlatformConfig.cameraPreviewAspectRatio; double topBarOverflow = Dimens.readingContainerDefaultHeight - cameraViewHeight; - if (EquipmentProfiles.of(context).isNotEmpty) { + if (FeaturesConfig.equipmentProfilesEnabled) { topBarOverflow += Dimens.readingContainerSingleValueHeight; topBarOverflow += Dimens.paddingS; } 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 88b86f9..12e2772 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 @@ -1,7 +1,10 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; +import 'package:lightmeter/data/models/film.dart'; +import 'package:lightmeter/features.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/providers/equipment_profile_provider.dart'; +import 'package:lightmeter/providers/film_profile.dart'; import 'package:lightmeter/res/dimens.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; @@ -36,12 +39,8 @@ class ReadingsContainer extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - if (EquipmentProfiles.of(context).isNotEmpty) ...[ - _EquipmentProfilePicker( - selectedValue: EquipmentProfile.of(context), - values: EquipmentProfiles.of(context), - onChanged: EquipmentProfileProvider.of(context).setProfile, - ), + if (FeaturesConfig.equipmentProfilesEnabled) ...[ + const _EquipmentProfilePicker(), const _InnerPadding(), ], ReadingValueContainer( @@ -57,6 +56,8 @@ class ReadingsContainer extends StatelessWidget { ], ), const _InnerPadding(), + const _FilmPicker(), + const _InnerPadding(), Row( children: [ Expanded( @@ -86,28 +87,43 @@ class _InnerPadding extends SizedBox { } class _EquipmentProfilePicker extends StatelessWidget { - final List values; - final EquipmentProfileData selectedValue; - final ValueChanged onChanged; - - const _EquipmentProfilePicker({ - required this.selectedValue, - required this.values, - required this.onChanged, - }); + const _EquipmentProfilePicker(); @override Widget build(BuildContext context) { return AnimatedDialogPicker( title: S.of(context).equipmentProfile, - selectedValue: selectedValue, - values: values, + selectedValue: EquipmentProfile.of(context), + values: EquipmentProfiles.of(context), itemTitleBuilder: (_, value) => Text(value.id.isEmpty ? S.of(context).none : value.name), - onChanged: onChanged, + onChanged: EquipmentProfileProvider.of(context).setProfile, closedChild: ReadingValueContainer.singleValue( value: ReadingValue( label: S.of(context).equipmentProfile, - value: selectedValue.id.isEmpty ? S.of(context).none : selectedValue.name, + value: EquipmentProfile.of(context).id.isEmpty + ? S.of(context).none + : EquipmentProfile.of(context).name, + ), + ), + ); + } +} + +class _FilmPicker extends StatelessWidget { + const _FilmPicker(); + + @override + Widget build(BuildContext context) { + return AnimatedDialogPicker( + title: S.of(context).film, + selectedValue: Film.of(context), + values: FilmData.values, + itemTitleBuilder: (_, value) => Text(value.name.isEmpty ? S.of(context).none : value.name), + onChanged: FilmProvider.of(context).setFilm, + closedChild: ReadingValueContainer.singleValue( + value: ReadingValue( + label: S.of(context).film, + value: Film.of(context).name.isEmpty ? S.of(context).none : Film.of(context).name, ), ), ); diff --git a/lib/screens/settings/components/metering/widget_settings_section_metering.dart b/lib/screens/settings/components/metering/widget_settings_section_metering.dart index db30e84..45e057a 100644 --- a/lib/screens/settings/components/metering/widget_settings_section_metering.dart +++ b/lib/screens/settings/components/metering/widget_settings_section_metering.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:lightmeter/features.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/screens/settings/components/shared/settings_section/widget_settings_section.dart'; @@ -16,7 +17,7 @@ class MeteringSettingsSection extends StatelessWidget { children: const [ StopTypeListTile(), CalibrationListTile(), - EquipmentProfilesListTile(), + if (FeaturesConfig.equipmentProfilesEnabled) EquipmentProfilesListTile(), ], ); }