Logic & UI improvements

added inner insets to `ReadingContainer`

provide bloc for `CameraView` in dialog

measure on camera loaded
This commit is contained in:
Vadim 2022-12-15 12:25:52 +03:00
parent 9b0b387514
commit a054a55f15
3 changed files with 92 additions and 74 deletions

View file

@ -67,6 +67,11 @@ class CameraBloc extends Bloc<CameraEvent, CameraState> {
await _cameraController!.initialize(); await _cameraController!.initialize();
await _cameraController!.setFlashMode(FlashMode.off); await _cameraController!.setFlashMode(FlashMode.off);
emit(CameraReadyState(_cameraController!)); emit(CameraReadyState(_cameraController!));
_takePhoto().then((ev100) {
if (ev100 != null) {
_communicationBloc.add(communication_event.MeasuredEvent(ev100));
}
});
} catch (e) { } catch (e) {
emit(const CameraErrorState()); emit(const CameraErrorState());
} }

View file

@ -3,12 +3,20 @@ import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/screens/metering/components/topbar/models/reading_value.dart'; import 'package:lightmeter/screens/metering/components/topbar/models/reading_value.dart';
class ReadingContainer extends StatelessWidget { class ReadingContainer extends StatelessWidget {
final List<_ReadingValueBuilder> _items; late final List<Widget> _items;
ReadingContainer({ ReadingContainer({
required List<ReadingValue> values, required List<ReadingValue> values,
super.key, 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({ ReadingContainer.singleValue({
required ReadingValue value, required ReadingValue value,
@ -25,7 +33,7 @@ class ReadingContainer extends StatelessWidget {
padding: const EdgeInsets.all(Dimens.paddingM), padding: const EdgeInsets.all(Dimens.paddingM),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: _items, children: _items,
), ),

View file

@ -1,4 +1,6 @@
import 'package:flutter/material.dart'; 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/generated/l10n.dart';
import 'package:lightmeter/models/exposure_pair.dart'; import 'package:lightmeter/models/exposure_pair.dart';
import 'package:lightmeter/models/iso_value.dart'; import 'package:lightmeter/models/iso_value.dart';
@ -47,85 +49,88 @@ class MeteringTopBar extends StatelessWidget {
bottom: false, bottom: false,
child: MediaQuery( child: MediaQuery(
data: MediaQuery.of(context), data: MediaQuery.of(context),
child: IntrinsicHeight( child: Row(
child: Row( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min, children: [
children: [ Expanded(
Expanded( child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.stretch,
crossAxisAlignment: CrossAxisAlignment.stretch, children: [
children: [ ReadingContainer(
Expanded( values: [
child: ReadingContainer( ReadingValue(
values: [ label: S.of(context).fastestExposurePair,
ReadingValue( value: fastest != null
label: S.of(context).fastestExposurePair, ? '${fastest!.aperture.toString()} - ${fastest!.shutterSpeed.toString()}'
value: fastest != null : 'N/A',
? '${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',
),
],
), ),
), ReadingValue(
const _InnerPadding(), label: S.of(context).slowestExposurePair,
ReadingContainer.singleValue( value: fastest != null
value: ReadingValue( ? '${slowest!.aperture.toString()} - ${slowest!.shutterSpeed.toString()}'
label: 'EV', : 'N/A',
value: ev.toString(),
), ),
],
),
/*
const _InnerPadding(),
ReadingContainer.singleValue(
value: ReadingValue(
label: 'EV',
value: ev.toStringAsFixed(1),
), ),
const _InnerPadding(), ),
Row( */
children: [ const _InnerPadding(),
Expanded( Row(
child: _AnimatedDialogPicker( children: [
title: S.of(context).iso, Expanded(
subtitle: S.of(context).filmSpeed, child: _AnimatedDialogPicker(
selectedValue: iso, title: S.of(context).iso,
values: isoValues, subtitle: S.of(context).filmSpeed,
itemTitleBuilder: (_, value) => Text(value.value.toString()), selectedValue: iso,
// using ascending order, because increase in film speed rises EV values: isoValues,
evDifferenceBuilder: (selected, other) => selected.toStringDifference(other), itemTitleBuilder: (_, value) => Text(value.value.toString()),
onChanged: onIsoChanged, // using ascending order, because increase in film speed rises EV
), evDifferenceBuilder: (selected, other) => selected.toStringDifference(other),
onChanged: onIsoChanged,
), ),
const _InnerPadding(), ),
Expanded( const _InnerPadding(),
child: _AnimatedDialogPicker( Expanded(
title: S.of(context).nd, child: _AnimatedDialogPicker(
subtitle: S.of(context).ndFilterFactor, title: S.of(context).nd,
selectedValue: nd, subtitle: S.of(context).ndFilterFactor,
values: ndValues, selectedValue: nd,
itemTitleBuilder: (_, value) => Text( values: ndValues,
value.value == 0 ? S.of(context).none : value.value.toString(), 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,
), ),
// 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<CameraBloc>(),
child: const CameraView(),
), ),
), ),
const _InnerPadding(), ),
Expanded( ],
child: Column(
children: [
const CameraView(),
],
),
),
],
),
), ),
), ),
), ),