diff --git a/lib/data/ev_source/camera/bloc_camera.dart b/lib/data/ev_source/camera/bloc_camera.dart index 382e855..113d874 100644 --- a/lib/data/ev_source/camera/bloc_camera.dart +++ b/lib/data/ev_source/camera/bloc_camera.dart @@ -67,6 +67,11 @@ class CameraBloc extends Bloc { await _cameraController!.initialize(); await _cameraController!.setFlashMode(FlashMode.off); emit(CameraReadyState(_cameraController!)); + _takePhoto().then((ev100) { + if (ev100 != null) { + _communicationBloc.add(communication_event.MeasuredEvent(ev100)); + } + }); } catch (e) { emit(const CameraErrorState()); } diff --git a/lib/screens/metering/components/topbar/components/reading_container.dart b/lib/screens/metering/components/topbar/components/reading_container.dart index a4abc3d..13c1734 100644 --- a/lib/screens/metering/components/topbar/components/reading_container.dart +++ b/lib/screens/metering/components/topbar/components/reading_container.dart @@ -3,12 +3,20 @@ import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/metering/components/topbar/models/reading_value.dart'; class ReadingContainer extends StatelessWidget { - final List<_ReadingValueBuilder> _items; + late final List _items; ReadingContainer({ required List values, super.key, - }) : _items = values.map((e) => _ReadingValueBuilder(e)).toList(); + }) { + _items = []; + for (int i = 0; i < values.length; i++) { + if (i > 0) { + _items.add(const SizedBox(height: Dimens.grid8)); + } + _items.add(_ReadingValueBuilder(values[i])); + } + } ReadingContainer.singleValue({ required ReadingValue value, @@ -25,7 +33,7 @@ class ReadingContainer extends StatelessWidget { padding: const EdgeInsets.all(Dimens.paddingM), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: _items, ), diff --git a/lib/screens/metering/components/topbar/topbar.dart b/lib/screens/metering/components/topbar/topbar.dart index 903414d..26a6496 100644 --- a/lib/screens/metering/components/topbar/topbar.dart +++ b/lib/screens/metering/components/topbar/topbar.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:lightmeter/data/ev_source/camera/bloc_camera.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/models/exposure_pair.dart'; import 'package:lightmeter/models/iso_value.dart'; @@ -47,85 +49,88 @@ class MeteringTopBar extends StatelessWidget { bottom: false, child: MediaQuery( data: MediaQuery.of(context), - child: IntrinsicHeight( - child: Row( - crossAxisAlignment: CrossAxisAlignment.stretch, - mainAxisSize: MainAxisSize.min, - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - child: ReadingContainer( - values: [ - ReadingValue( - label: S.of(context).fastestExposurePair, - value: fastest != null - ? '${fastest!.aperture.toString()} - ${fastest!.shutterSpeed.toString()}' - : 'N/A', - ), - ReadingValue( - label: S.of(context).slowestExposurePair, - value: fastest != null - ? '${slowest!.aperture.toString()} - ${slowest!.shutterSpeed.toString()}' - : 'N/A', - ), - ], + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + ReadingContainer( + values: [ + ReadingValue( + label: S.of(context).fastestExposurePair, + value: fastest != null + ? '${fastest!.aperture.toString()} - ${fastest!.shutterSpeed.toString()}' + : 'N/A', ), - ), - const _InnerPadding(), - ReadingContainer.singleValue( - value: ReadingValue( - label: 'EV', - value: ev.toString(), + ReadingValue( + label: S.of(context).slowestExposurePair, + value: fastest != null + ? '${slowest!.aperture.toString()} - ${slowest!.shutterSpeed.toString()}' + : 'N/A', ), + ], + ), + /* + const _InnerPadding(), + ReadingContainer.singleValue( + value: ReadingValue( + label: 'EV', + value: ev.toStringAsFixed(1), ), - const _InnerPadding(), - Row( - children: [ - Expanded( - child: _AnimatedDialogPicker( - title: S.of(context).iso, - subtitle: S.of(context).filmSpeed, - selectedValue: iso, - values: isoValues, - itemTitleBuilder: (_, value) => Text(value.value.toString()), - // using ascending order, because increase in film speed rises EV - evDifferenceBuilder: (selected, other) => selected.toStringDifference(other), - onChanged: onIsoChanged, - ), + ), + */ + const _InnerPadding(), + Row( + children: [ + Expanded( + child: _AnimatedDialogPicker( + title: S.of(context).iso, + subtitle: S.of(context).filmSpeed, + selectedValue: iso, + values: isoValues, + itemTitleBuilder: (_, value) => Text(value.value.toString()), + // using ascending order, because increase in film speed rises EV + evDifferenceBuilder: (selected, other) => selected.toStringDifference(other), + onChanged: onIsoChanged, ), - const _InnerPadding(), - Expanded( - child: _AnimatedDialogPicker( - title: S.of(context).nd, - subtitle: S.of(context).ndFilterFactor, - selectedValue: nd, - values: ndValues, - itemTitleBuilder: (_, value) => Text( - value.value == 0 ? S.of(context).none : value.value.toString(), - ), - // using descending order, because ND filter darkens image & lowers EV - evDifferenceBuilder: (selected, other) => other.toStringDifference(selected), - onChanged: onNdChanged, + ), + const _InnerPadding(), + Expanded( + child: _AnimatedDialogPicker( + title: S.of(context).nd, + subtitle: S.of(context).ndFilterFactor, + selectedValue: nd, + values: ndValues, + itemTitleBuilder: (_, value) => Text( + value.value == 0 ? S.of(context).none : value.value.toString(), ), + // using descending order, because ND filter darkens image & lowers EV + evDifferenceBuilder: (selected, other) => other.toStringDifference(selected), + onChanged: onNdChanged, ), - ], - ) - ], + ), + ], + ) + ], + ), + ), + const _InnerPadding(), + Expanded( + child: AnimatedDialog( + openedSize: Size( + MediaQuery.of(context).size.width - Dimens.paddingM * 2, + (MediaQuery.of(context).size.width - Dimens.paddingM * 2) / 3 * 4, + ), + child: BlocProvider.value( + value: context.read(), + child: const CameraView(), ), ), - const _InnerPadding(), - Expanded( - child: Column( - children: [ - const CameraView(), - ], - ), - ), - ], - ), + ), + ], ), ), ),