mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-24 16:30:40 +00:00
ML-37 Fix exposure pairs list creation (#39)
* integrated EV value to measure button * fixed
This commit is contained in:
parent
f8391454b6
commit
cbee0f350a
11 changed files with 57 additions and 33 deletions
|
@ -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,
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
"@@locale": "en",
|
||||
"fastestExposurePair": "Fastest",
|
||||
"slowestExposurePair": "Slowest",
|
||||
"ev": "{value} EV",
|
||||
"@ev": {
|
||||
"ev": "EV",
|
||||
"evValue": "{value} EV",
|
||||
"@evValue": {
|
||||
"placeholders": {
|
||||
"value": {
|
||||
"type": "String"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
"@@locale": "ru",
|
||||
"fastestExposurePair": "Короткая выдержка",
|
||||
"slowestExposurePair": "Длинная выдержка",
|
||||
"ev": "{value} EV",
|
||||
"@ev": {
|
||||
"ev": "EV",
|
||||
"evValue": "{value} EV",
|
||||
"@evValue": {
|
||||
"placeholders": {
|
||||
"value": {
|
||||
"type": "String"
|
||||
|
|
|
@ -122,19 +122,9 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
|||
}
|
||||
|
||||
List<ExposurePair> _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<MeteringEvent, MeteringState> {
|
|||
shutterSpeedOffset = 0;
|
||||
}
|
||||
|
||||
int itemsCount = min(_apertureValues.length + shutterSpeedOffset,
|
||||
final int itemsCount = min(_apertureValues.length + shutterSpeedOffset,
|
||||
_shutterSpeedValues.length + apertureOffset) -
|
||||
max(apertureOffset, shutterSpeedOffset);
|
||||
|
||||
|
|
|
@ -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<MeteringMeasureButton> {
|
|||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -83,9 +83,8 @@ class _PhotographyValuePickerDialogState<T extends PhotographyValue>
|
|||
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) {
|
||||
|
|
|
@ -57,12 +57,16 @@ class _MeteringScreenState extends State<MeteringScreen> {
|
|||
),
|
||||
),
|
||||
),
|
||||
MeteringBottomControlsProvider(
|
||||
onSwitchEvSourceType: context.read<Environment>().hasLightSensor
|
||||
? EvSourceTypeProvider.of(context).toggleType
|
||||
: null,
|
||||
onMeasure: () => _bloc.add(const MeasureEvent()),
|
||||
onSettings: () => Navigator.pushNamed(context, 'settings'),
|
||||
BlocBuilder<MeteringBloc, MeteringState>(
|
||||
buildWhen: (previous, current) => previous.ev != current.ev,
|
||||
builder: (context, state) => MeteringBottomControlsProvider(
|
||||
ev: context.read<Environment>().buildType == BuildType.dev ? state.ev : null,
|
||||
onSwitchEvSourceType: context.read<Environment>().hasLightSensor
|
||||
? EvSourceTypeProvider.of(context).toggleType
|
||||
: null,
|
||||
onMeasure: () => _bloc.add(const MeasureEvent()),
|
||||
onSettings: () => Navigator.pushNamed(context, 'settings'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue