m3_lightmeter/lib/models/photography_value.dart

34 lines
945 B
Dart
Raw Normal View History

2022-10-25 19:53:39 +00:00
part 'aperture_value.dart';
part 'iso_value.dart';
part 'shutter_speed_value.dart';
2022-10-30 18:06:51 +00:00
enum StopType { full, half, third }
2022-10-25 19:53:39 +00:00
abstract class PhotographyValue<T> {
final T rawValue;
2022-10-30 18:06:51 +00:00
final StopType stopType;
2022-10-25 19:53:39 +00:00
const PhotographyValue(this.rawValue, this.stopType);
T get value;
}
2022-10-26 19:49:21 +00:00
extension PhotographyValues<T extends PhotographyValue> on List<T> {
2022-10-30 18:06:51 +00:00
List<T> whereStopType(StopType stopType) {
2022-10-26 19:49:21 +00:00
switch (stopType) {
2022-10-30 18:06:51 +00:00
case StopType.full:
return where((e) => e.stopType == StopType.full).toList();
case StopType.half:
return where((e) => e.stopType == StopType.full || e.stopType == StopType.half).toList();
case StopType.third:
return where((e) => e.stopType == StopType.full || e.stopType == StopType.third).toList();
2022-10-26 19:49:21 +00:00
}
}
2022-10-25 19:53:39 +00:00
2022-10-30 18:06:51 +00:00
List<T> fullStops() => whereStopType(StopType.full);
2022-10-25 19:53:39 +00:00
2022-10-30 18:06:51 +00:00
List<T> halfStops() => whereStopType(StopType.half);
2022-10-26 19:49:21 +00:00
2022-10-30 18:06:51 +00:00
List<T> thirdStops() => whereStopType(StopType.third);
2022-10-25 19:53:39 +00:00
}