mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 23:10:40 +00:00
integrated EV value to measure button
This commit is contained in:
parent
f8391454b6
commit
a00d608adc
10 changed files with 53 additions and 19 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"
|
||||
|
|
|
@ -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