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 {
|
class Environment {
|
||||||
|
final BuildType buildType;
|
||||||
final String sourceCodeUrl;
|
final String sourceCodeUrl;
|
||||||
final String issuesReportUrl;
|
final String issuesReportUrl;
|
||||||
final String contactEmail;
|
final String contactEmail;
|
||||||
|
@ -6,6 +9,7 @@ class Environment {
|
||||||
final bool hasLightSensor;
|
final bool hasLightSensor;
|
||||||
|
|
||||||
const Environment({
|
const Environment({
|
||||||
|
required this.buildType,
|
||||||
required this.sourceCodeUrl,
|
required this.sourceCodeUrl,
|
||||||
required this.issuesReportUrl,
|
required this.issuesReportUrl,
|
||||||
required this.contactEmail,
|
required this.contactEmail,
|
||||||
|
@ -13,18 +17,21 @@ class Environment {
|
||||||
});
|
});
|
||||||
|
|
||||||
const Environment.dev()
|
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',
|
issuesReportUrl = 'https://github.com/vodemn/m3_lightmeter/issues',
|
||||||
contactEmail = 'contact.vodemn@gmail.com',
|
contactEmail = 'contact.vodemn@gmail.com',
|
||||||
hasLightSensor = false;
|
hasLightSensor = false;
|
||||||
|
|
||||||
const Environment.prod()
|
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',
|
issuesReportUrl = 'https://github.com/vodemn/m3_lightmeter/issues',
|
||||||
contactEmail = 'contact.vodemn@gmail.com',
|
contactEmail = 'contact.vodemn@gmail.com',
|
||||||
hasLightSensor = false;
|
hasLightSensor = false;
|
||||||
|
|
||||||
Environment copyWith({bool? hasLightSensor}) => Environment(
|
Environment copyWith({bool? hasLightSensor}) => Environment(
|
||||||
|
buildType: buildType,
|
||||||
sourceCodeUrl: sourceCodeUrl,
|
sourceCodeUrl: sourceCodeUrl,
|
||||||
issuesReportUrl: issuesReportUrl,
|
issuesReportUrl: issuesReportUrl,
|
||||||
contactEmail: contactEmail,
|
contactEmail: contactEmail,
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
"@@locale": "en",
|
"@@locale": "en",
|
||||||
"fastestExposurePair": "Fastest",
|
"fastestExposurePair": "Fastest",
|
||||||
"slowestExposurePair": "Slowest",
|
"slowestExposurePair": "Slowest",
|
||||||
"ev": "{value} EV",
|
"ev": "EV",
|
||||||
"@ev": {
|
"evValue": "{value} EV",
|
||||||
|
"@evValue": {
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "String"
|
"type": "String"
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
"@@locale": "fr",
|
"@@locale": "fr",
|
||||||
"fastestExposurePair": "Le plus rapide",
|
"fastestExposurePair": "Le plus rapide",
|
||||||
"slowestExposurePair": "Le plus lent",
|
"slowestExposurePair": "Le plus lent",
|
||||||
"ev": "{value} EV",
|
"ev": "EV",
|
||||||
"@ev": {
|
"evValue": "{value} EV",
|
||||||
|
"@evValue": {
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "String"
|
"type": "String"
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
"@@locale": "ru",
|
"@@locale": "ru",
|
||||||
"fastestExposurePair": "Короткая выдержка",
|
"fastestExposurePair": "Короткая выдержка",
|
||||||
"slowestExposurePair": "Длинная выдержка",
|
"slowestExposurePair": "Длинная выдержка",
|
||||||
"ev": "{value} EV",
|
"ev": "EV",
|
||||||
"@ev": {
|
"evValue": "{value} EV",
|
||||||
|
"@evValue": {
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"value": {
|
"value": {
|
||||||
"type": "String"
|
"type": "String"
|
||||||
|
|
|
@ -122,19 +122,9 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ExposurePair> _buildExposureValues(double ev) {
|
List<ExposurePair> _buildExposureValues(double ev) {
|
||||||
late final int evSteps;
|
/// Depending on the `stopType` the exposure pairs list length is multiplied by 1,2 or 3
|
||||||
switch (stopType) {
|
final int evSteps = (ev * (stopType.index + 1)).round();
|
||||||
case StopType.full:
|
final int evOffset =
|
||||||
evSteps = ev.floor();
|
|
||||||
break;
|
|
||||||
case StopType.half:
|
|
||||||
evSteps = (ev / 0.5).floor();
|
|
||||||
break;
|
|
||||||
case StopType.third:
|
|
||||||
evSteps = (ev / 0.3).floor();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
final evOffset =
|
|
||||||
_shutterSpeedValues.indexOf(const ShutterSpeedValue(1, false, StopType.full)) - evSteps;
|
_shutterSpeedValues.indexOf(const ShutterSpeedValue(1, false, StopType.full)) - evSteps;
|
||||||
|
|
||||||
late final int apertureOffset;
|
late final int apertureOffset;
|
||||||
|
@ -147,7 +137,7 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
|
||||||
shutterSpeedOffset = 0;
|
shutterSpeedOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int itemsCount = min(_apertureValues.length + shutterSpeedOffset,
|
final int itemsCount = min(_apertureValues.length + shutterSpeedOffset,
|
||||||
_shutterSpeedValues.length + apertureOffset) -
|
_shutterSpeedValues.length + apertureOffset) -
|
||||||
max(apertureOffset, shutterSpeedOffset);
|
max(apertureOffset, shutterSpeedOffset);
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:lightmeter/generated/l10n.dart';
|
||||||
import 'package:lightmeter/res/dimens.dart';
|
import 'package:lightmeter/res/dimens.dart';
|
||||||
import 'package:lightmeter/screens/shared/filled_circle/widget_circle_filled.dart';
|
import 'package:lightmeter/screens/shared/filled_circle/widget_circle_filled.dart';
|
||||||
|
|
||||||
class MeteringMeasureButton extends StatefulWidget {
|
class MeteringMeasureButton extends StatefulWidget {
|
||||||
|
final double? ev;
|
||||||
final double size;
|
final double size;
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
|
|
||||||
const MeteringMeasureButton({
|
const MeteringMeasureButton({
|
||||||
required this.onTap,
|
required this.onTap,
|
||||||
|
required this.ev,
|
||||||
this.size = 72,
|
this.size = 72,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
@ -55,6 +58,16 @@ class _MeteringMeasureButtonState extends State<MeteringMeasureButton> {
|
||||||
child: FilledCircle(
|
child: FilledCircle(
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
size: widget.size - Dimens.grid16,
|
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';
|
import 'widget_bottom_controls.dart';
|
||||||
|
|
||||||
class MeteringBottomControlsProvider extends StatelessWidget {
|
class MeteringBottomControlsProvider extends StatelessWidget {
|
||||||
|
final double? ev;
|
||||||
final VoidCallback? onSwitchEvSourceType;
|
final VoidCallback? onSwitchEvSourceType;
|
||||||
final VoidCallback onMeasure;
|
final VoidCallback onMeasure;
|
||||||
final VoidCallback onSettings;
|
final VoidCallback onSettings;
|
||||||
|
|
||||||
const MeteringBottomControlsProvider({
|
const MeteringBottomControlsProvider({
|
||||||
|
required this.ev,
|
||||||
required this.onSwitchEvSourceType,
|
required this.onSwitchEvSourceType,
|
||||||
required this.onMeasure,
|
required this.onMeasure,
|
||||||
required this.onSettings,
|
required this.onSettings,
|
||||||
|
@ -30,6 +32,7 @@ class MeteringBottomControlsProvider extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: MeteringBottomControls(
|
child: MeteringBottomControls(
|
||||||
|
ev: ev,
|
||||||
onSwitchEvSourceType: onSwitchEvSourceType,
|
onSwitchEvSourceType: onSwitchEvSourceType,
|
||||||
onMeasure: onMeasure,
|
onMeasure: onMeasure,
|
||||||
onSettings: onSettings,
|
onSettings: onSettings,
|
||||||
|
|
|
@ -6,11 +6,13 @@ import 'package:provider/provider.dart';
|
||||||
import 'components/measure_button/widget_button_measure.dart';
|
import 'components/measure_button/widget_button_measure.dart';
|
||||||
|
|
||||||
class MeteringBottomControls extends StatelessWidget {
|
class MeteringBottomControls extends StatelessWidget {
|
||||||
|
final double? ev;
|
||||||
final VoidCallback? onSwitchEvSourceType;
|
final VoidCallback? onSwitchEvSourceType;
|
||||||
final VoidCallback onMeasure;
|
final VoidCallback onMeasure;
|
||||||
final VoidCallback onSettings;
|
final VoidCallback onSettings;
|
||||||
|
|
||||||
const MeteringBottomControls({
|
const MeteringBottomControls({
|
||||||
|
required this.ev,
|
||||||
required this.onSwitchEvSourceType,
|
required this.onSwitchEvSourceType,
|
||||||
required this.onMeasure,
|
required this.onMeasure,
|
||||||
required this.onSettings,
|
required this.onSettings,
|
||||||
|
@ -46,7 +48,10 @@ class MeteringBottomControls extends StatelessWidget {
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
MeteringMeasureButton(onTap: onMeasure),
|
MeteringMeasureButton(
|
||||||
|
ev: ev,
|
||||||
|
onTap: onMeasure,
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
|
|
|
@ -83,9 +83,8 @@ class _PhotographyValuePickerDialogState<T extends PhotographyValue>
|
||||||
child: widget.itemTitleBuilder(context, widget.values[index]),
|
child: widget.itemTitleBuilder(context, widget.values[index]),
|
||||||
),
|
),
|
||||||
secondary: widget.values[index].value != _selectedValue.value
|
secondary: widget.values[index].value != _selectedValue.value
|
||||||
? Text(S
|
? Text(S.of(context).evValue(
|
||||||
.of(context)
|
widget.evDifferenceBuilder.call(_selectedValue, widget.values[index])))
|
||||||
.ev(widget.evDifferenceBuilder.call(_selectedValue, widget.values[index])))
|
|
||||||
: null,
|
: null,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
|
|
@ -57,12 +57,16 @@ class _MeteringScreenState extends State<MeteringScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
MeteringBottomControlsProvider(
|
BlocBuilder<MeteringBloc, MeteringState>(
|
||||||
onSwitchEvSourceType: context.read<Environment>().hasLightSensor
|
buildWhen: (previous, current) => previous.ev != current.ev,
|
||||||
? EvSourceTypeProvider.of(context).toggleType
|
builder: (context, state) => MeteringBottomControlsProvider(
|
||||||
: null,
|
ev: context.read<Environment>().buildType == BuildType.dev ? state.ev : null,
|
||||||
onMeasure: () => _bloc.add(const MeasureEvent()),
|
onSwitchEvSourceType: context.read<Environment>().hasLightSensor
|
||||||
onSettings: () => Navigator.pushNamed(context, 'settings'),
|
? EvSourceTypeProvider.of(context).toggleType
|
||||||
|
: null,
|
||||||
|
onMeasure: () => _bloc.add(const MeasureEvent()),
|
||||||
|
onSettings: () => Navigator.pushNamed(context, 'settings'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -101,7 +101,7 @@ class _CalibrationUnit extends StatelessWidget {
|
||||||
ListTile(
|
ListTile(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
trailing: Text(S.of(context).ev(value.toStringSignedAsFixed(1))),
|
trailing: Text(S.of(context).evValue(value.toStringSignedAsFixed(1))),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|
Loading…
Reference in a new issue