diff --git a/lib/environment.dart b/lib/environment.dart index 7f93bb2..c2e43c7 100644 --- a/lib/environment.dart +++ b/lib/environment.dart @@ -1,4 +1,7 @@ +enum BuildType { dev, prod } + class Environment { + final BuildType buildType; final String sourceCodeUrl; final String issuesReportUrl; final String contactEmail; @@ -6,6 +9,7 @@ class Environment { final bool hasLightSensor; const Environment({ + required this.buildType, required this.sourceCodeUrl, required this.issuesReportUrl, required this.contactEmail, @@ -13,18 +17,21 @@ class Environment { }); const Environment.dev() - : sourceCodeUrl = 'https://github.com/vodemn/m3_lightmeter', + : buildType = BuildType.dev, + sourceCodeUrl = 'https://github.com/vodemn/m3_lightmeter', issuesReportUrl = 'https://github.com/vodemn/m3_lightmeter/issues', contactEmail = 'contact.vodemn@gmail.com', hasLightSensor = false; const Environment.prod() - : sourceCodeUrl = 'https://github.com/vodemn/m3_lightmeter', + : buildType = BuildType.prod, + sourceCodeUrl = 'https://github.com/vodemn/m3_lightmeter', issuesReportUrl = 'https://github.com/vodemn/m3_lightmeter/issues', contactEmail = 'contact.vodemn@gmail.com', hasLightSensor = false; Environment copyWith({bool? hasLightSensor}) => Environment( + buildType: buildType, sourceCodeUrl: sourceCodeUrl, issuesReportUrl: issuesReportUrl, contactEmail: contactEmail, diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index e78c0eb..aded824 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -2,8 +2,9 @@ "@@locale": "en", "fastestExposurePair": "Fastest", "slowestExposurePair": "Slowest", - "ev": "{value} EV", - "@ev": { + "ev": "EV", + "evValue": "{value} EV", + "@evValue": { "placeholders": { "value": { "type": "String" diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index ff80b36..2dd9b2e 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -2,8 +2,9 @@ "@@locale": "fr", "fastestExposurePair": "Le plus rapide", "slowestExposurePair": "Le plus lent", - "ev": "{value} EV", - "@ev": { + "ev": "EV", + "evValue": "{value} EV", + "@evValue": { "placeholders": { "value": { "type": "String" diff --git a/lib/l10n/intl_ru.arb b/lib/l10n/intl_ru.arb index 34e44f6..4d792d3 100644 --- a/lib/l10n/intl_ru.arb +++ b/lib/l10n/intl_ru.arb @@ -2,8 +2,9 @@ "@@locale": "ru", "fastestExposurePair": "Короткая выдержка", "slowestExposurePair": "Длинная выдержка", - "ev": "{value} EV", - "@ev": { + "ev": "EV", + "evValue": "{value} EV", + "@evValue": { "placeholders": { "value": { "type": "String" diff --git a/lib/screens/metering/bloc_metering.dart b/lib/screens/metering/bloc_metering.dart index f9d49bb..6078e3e 100644 --- a/lib/screens/metering/bloc_metering.dart +++ b/lib/screens/metering/bloc_metering.dart @@ -122,19 +122,9 @@ class MeteringBloc extends Bloc { } List _buildExposureValues(double ev) { - late final int evSteps; - switch (stopType) { - case StopType.full: - evSteps = ev.floor(); - break; - case StopType.half: - evSteps = (ev / 0.5).floor(); - break; - case StopType.third: - evSteps = (ev / 0.3).floor(); - break; - } - final evOffset = + /// Depending on the `stopType` the exposure pairs list length is multiplied by 1,2 or 3 + final int evSteps = (ev * (stopType.index + 1)).round(); + final int evOffset = _shutterSpeedValues.indexOf(const ShutterSpeedValue(1, false, StopType.full)) - evSteps; late final int apertureOffset; @@ -147,7 +137,7 @@ class MeteringBloc extends Bloc { shutterSpeedOffset = 0; } - int itemsCount = min(_apertureValues.length + shutterSpeedOffset, + final int itemsCount = min(_apertureValues.length + shutterSpeedOffset, _shutterSpeedValues.length + apertureOffset) - max(apertureOffset, shutterSpeedOffset); diff --git a/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart b/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart index 083c8d3..dc416ed 100644 --- a/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart +++ b/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart @@ -1,13 +1,16 @@ import 'package:flutter/material.dart'; +import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/shared/filled_circle/widget_circle_filled.dart'; class MeteringMeasureButton extends StatefulWidget { + final double? ev; final double size; final VoidCallback onTap; const MeteringMeasureButton({ required this.onTap, + required this.ev, this.size = 72, super.key, }); @@ -55,6 +58,16 @@ class _MeteringMeasureButtonState extends State { child: FilledCircle( color: Theme.of(context).colorScheme.onSurface, size: widget.size - Dimens.grid16, + child: Center( + child: widget.ev != null + ? Text( + '${widget.ev!.toStringAsFixed(1)}\n${S.of(context).ev}', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.surface, + ), + ) + : null, + ), ), ), ), diff --git a/lib/screens/metering/components/bottom_controls/provider_bottom_controls.dart b/lib/screens/metering/components/bottom_controls/provider_bottom_controls.dart index fe88167..e41f936 100644 --- a/lib/screens/metering/components/bottom_controls/provider_bottom_controls.dart +++ b/lib/screens/metering/components/bottom_controls/provider_bottom_controls.dart @@ -4,11 +4,13 @@ import 'package:lightmeter/res/dimens.dart'; import 'widget_bottom_controls.dart'; class MeteringBottomControlsProvider extends StatelessWidget { + final double? ev; final VoidCallback? onSwitchEvSourceType; final VoidCallback onMeasure; final VoidCallback onSettings; const MeteringBottomControlsProvider({ + required this.ev, required this.onSwitchEvSourceType, required this.onMeasure, required this.onSettings, @@ -30,6 +32,7 @@ class MeteringBottomControlsProvider extends StatelessWidget { ), ), child: MeteringBottomControls( + ev: ev, onSwitchEvSourceType: onSwitchEvSourceType, onMeasure: onMeasure, onSettings: onSettings, diff --git a/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart b/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart index a8001d8..a1837c3 100644 --- a/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart +++ b/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart @@ -6,11 +6,13 @@ import 'package:provider/provider.dart'; import 'components/measure_button/widget_button_measure.dart'; class MeteringBottomControls extends StatelessWidget { + final double? ev; final VoidCallback? onSwitchEvSourceType; final VoidCallback onMeasure; final VoidCallback onSettings; const MeteringBottomControls({ + required this.ev, required this.onSwitchEvSourceType, required this.onMeasure, required this.onSettings, @@ -46,7 +48,10 @@ class MeteringBottomControls extends StatelessWidget { ) else const Spacer(), - MeteringMeasureButton(onTap: onMeasure), + MeteringMeasureButton( + ev: ev, + onTap: onMeasure, + ), Expanded( child: Center( child: IconButton( diff --git a/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/photography_value_picker_dialog/widget_dialog_picker_photography_value.dart b/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/photography_value_picker_dialog/widget_dialog_picker_photography_value.dart index 10f8b7f..acf9663 100644 --- a/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/photography_value_picker_dialog/widget_dialog_picker_photography_value.dart +++ b/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/photography_value_picker_dialog/widget_dialog_picker_photography_value.dart @@ -83,9 +83,8 @@ class _PhotographyValuePickerDialogState child: widget.itemTitleBuilder(context, widget.values[index]), ), secondary: widget.values[index].value != _selectedValue.value - ? Text(S - .of(context) - .ev(widget.evDifferenceBuilder.call(_selectedValue, widget.values[index]))) + ? Text(S.of(context).evValue( + widget.evDifferenceBuilder.call(_selectedValue, widget.values[index]))) : null, onChanged: (value) { if (value != null) { diff --git a/lib/screens/metering/screen_metering.dart b/lib/screens/metering/screen_metering.dart index 465b5bb..0c7a297 100644 --- a/lib/screens/metering/screen_metering.dart +++ b/lib/screens/metering/screen_metering.dart @@ -57,12 +57,16 @@ class _MeteringScreenState extends State { ), ), ), - MeteringBottomControlsProvider( - onSwitchEvSourceType: context.read().hasLightSensor - ? EvSourceTypeProvider.of(context).toggleType - : null, - onMeasure: () => _bloc.add(const MeasureEvent()), - onSettings: () => Navigator.pushNamed(context, 'settings'), + BlocBuilder( + buildWhen: (previous, current) => previous.ev != current.ev, + builder: (context, state) => MeteringBottomControlsProvider( + ev: context.read().buildType == BuildType.dev ? state.ev : null, + onSwitchEvSourceType: context.read().hasLightSensor + ? EvSourceTypeProvider.of(context).toggleType + : null, + onMeasure: () => _bloc.add(const MeasureEvent()), + onSettings: () => Navigator.pushNamed(context, 'settings'), + ), ), ], ), diff --git a/lib/screens/settings/components/calibration/components/calibration_dialog/widget_dialog_calibration.dart b/lib/screens/settings/components/calibration/components/calibration_dialog/widget_dialog_calibration.dart index 3af2bc0..62025ac 100644 --- a/lib/screens/settings/components/calibration/components/calibration_dialog/widget_dialog_calibration.dart +++ b/lib/screens/settings/components/calibration/components/calibration_dialog/widget_dialog_calibration.dart @@ -101,7 +101,7 @@ class _CalibrationUnit extends StatelessWidget { ListTile( contentPadding: EdgeInsets.zero, title: Text(title), - trailing: Text(S.of(context).ev(value.toStringSignedAsFixed(1))), + trailing: Text(S.of(context).evValue(value.toStringSignedAsFixed(1))), ), Row( mainAxisSize: MainAxisSize.min,