m3_lightmeter/lib/screens/metering/state_metering.dart
Vadim 74d0a7101c
ML-62 Bloc's tests (#78)
* removed redundant `UserPreferencesService` from `MeteringBloc`

* wip

* post-merge fixes

* `MeasureEvent` tests

* `MeasureEvent` tests revision

* `MeasureEvent` tests added timeout

* added stubs for other `MeteringBloc` events

* rewritten `MeteringBloc` logic

* wip

* `IsoChangedEvent` tests

* refined `IsoChangedEvent` tests

* `NdChangedEvent` tests

* `FilmChangedEvent` tests

* `MeteringCommunicationBloc` tests

* added test run to ci

* overriden `==` for `MeasuredState`

* `LuxMeteringEvent` tests

* refined `LuxMeteringEvent` tests

* rename

* wip

* wip

* `InitializeEvent`/`DeinitializeEvent` tests

* clamp minZoomLevel

* fixed `MeteringCommunicationBloc` tests

* wip

* `ZoomChangedEvent` tests

* `ExposureOffsetChangedEvent`/`ExposureOffsetResetEvent` tests

* renamed test groups

* added test coverage script

* improved `CameraContainerBloc` test coverage

* `EquipmentProfileChangedEvent` tests

* verify response vibration

* fixed running all tests

* `MeteringCommunicationBloc` equality tests

* `CameraContainerBloc` equality tests

* removed generated code from coverage
2023-06-20 08:43:49 +02:00

41 lines
979 B
Dart

import 'package:flutter/material.dart';
import 'package:lightmeter/data/models/film.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
@immutable
abstract class MeteringState {
final double? ev100;
final Film film;
final IsoValue iso;
final NdValue nd;
final bool isMetering;
const MeteringState({
this.ev100,
required this.film,
required this.iso,
required this.nd,
required this.isMetering,
});
}
class LoadingState extends MeteringState {
const LoadingState({
required super.film,
required super.iso,
required super.nd,
}) : super(isMetering: true);
}
class MeteringDataState extends MeteringState {
const MeteringDataState({
required super.ev100,
required super.film,
required super.iso,
required super.nd,
required super.isMetering,
});
double? get ev => ev100 != null ? ev100! + log2(iso.value / 100) - nd.stopReduction : null;
bool get hasError => ev == null;
}