added FeaturesConfig

This commit is contained in:
Vadim 2023-04-01 19:15:30 +03:00
parent f12fe6953e
commit 0ff9249f8f
5 changed files with 43 additions and 22 deletions

3
lib/features.dart Normal file
View file

@ -0,0 +1,3 @@
class FeaturesConfig {
static const bool equipmentProfilesEnabled = false;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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<EquipmentProfileData> values;
final EquipmentProfileData selectedValue;
final ValueChanged<EquipmentProfileData> onChanged;
const _EquipmentProfilePicker({
required this.selectedValue,
required this.values,
required this.onChanged,
});
const _EquipmentProfilePicker();
@override
Widget build(BuildContext context) {
return AnimatedDialogPicker<EquipmentProfileData>(
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<FilmData>(
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,
),
),
);

View file

@ -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(),
],
);
}