m3_lightmeter/lib/models/photography_value.dart

34 lines
889 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';
enum Stop { full, half, third }
abstract class PhotographyValue<T> {
final T rawValue;
final Stop stopType;
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> {
List<T> whereStopType(Stop stopType) {
switch (stopType) {
case Stop.full:
return where((e) => e.stopType == Stop.full).toList();
case Stop.half:
return where((e) => e.stopType == Stop.full || e.stopType == Stop.half).toList();
case Stop.third:
return where((e) => e.stopType == Stop.full || e.stopType == Stop.third).toList();
}
}
2022-10-25 19:53:39 +00:00
2022-10-26 19:49:21 +00:00
List<T> fullStops() => whereStopType(Stop.full);
2022-10-25 19:53:39 +00:00
2022-10-26 19:49:21 +00:00
List<T> halfStops() => whereStopType(Stop.half);
List<T> thirdStops() => whereStopType(Stop.third);
2022-10-25 19:53:39 +00:00
}