2023-04-01 19:04:55 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:lightmeter/data/models/film.dart';
|
2023-03-30 19:24:18 +00:00
|
|
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
2022-10-29 18:02:45 +00:00
|
|
|
|
2023-04-01 19:04:55 +00:00
|
|
|
@immutable
|
2023-02-19 10:26:14 +00:00
|
|
|
abstract class MeteringState {
|
2023-06-20 06:43:49 +00:00
|
|
|
final double? ev100;
|
2023-04-01 19:04:55 +00:00
|
|
|
final Film film;
|
2022-12-01 20:49:06 +00:00
|
|
|
final IsoValue iso;
|
2022-12-04 19:12:52 +00:00
|
|
|
final NdValue nd;
|
2023-06-20 06:43:49 +00:00
|
|
|
final bool isMetering;
|
2022-10-29 18:02:45 +00:00
|
|
|
|
2023-05-16 09:47:53 +00:00
|
|
|
const MeteringState({
|
2023-06-20 06:43:49 +00:00
|
|
|
this.ev100,
|
2023-04-01 19:04:55 +00:00
|
|
|
required this.film,
|
2022-10-29 18:02:45 +00:00
|
|
|
required this.iso,
|
|
|
|
required this.nd,
|
2023-06-20 06:43:49 +00:00
|
|
|
required this.isMetering,
|
2022-10-29 18:02:45 +00:00
|
|
|
});
|
|
|
|
}
|
2023-02-19 10:26:14 +00:00
|
|
|
|
2023-05-16 09:47:53 +00:00
|
|
|
class LoadingState extends MeteringState {
|
|
|
|
const LoadingState({
|
2023-04-01 19:04:55 +00:00
|
|
|
required super.film,
|
2023-02-19 10:26:14 +00:00
|
|
|
required super.iso,
|
|
|
|
required super.nd,
|
2023-06-20 06:43:49 +00:00
|
|
|
}) : super(isMetering: true);
|
2023-02-19 10:26:14 +00:00
|
|
|
}
|
|
|
|
|
2023-05-16 09:47:53 +00:00
|
|
|
class MeteringDataState extends MeteringState {
|
|
|
|
const MeteringDataState({
|
2023-06-20 06:43:49 +00:00
|
|
|
required super.ev100,
|
2023-04-01 19:04:55 +00:00
|
|
|
required super.film,
|
2023-02-19 10:26:14 +00:00
|
|
|
required super.iso,
|
|
|
|
required super.nd,
|
2023-06-20 06:43:49 +00:00
|
|
|
required super.isMetering,
|
2023-02-19 10:26:14 +00:00
|
|
|
});
|
2023-05-16 09:47:53 +00:00
|
|
|
|
2023-06-20 06:43:49 +00:00
|
|
|
double? get ev => ev100 != null ? ev100! + log2(iso.value / 100) - nd.stopReduction : null;
|
2023-05-16 09:47:53 +00:00
|
|
|
bool get hasError => ev == null;
|
2023-02-19 10:26:14 +00:00
|
|
|
}
|