2023-11-11 20:05:11 +00:00
|
|
|
enum CameraFeature {
|
|
|
|
spotMetering,
|
|
|
|
histogram,
|
2025-02-17 20:03:09 +00:00
|
|
|
showFocalLength,
|
2023-11-11 20:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef CameraFeaturesConfig = Map<CameraFeature, bool>;
|
|
|
|
|
|
|
|
extension CameraFeaturesConfigJson on CameraFeaturesConfig {
|
2025-05-12 14:04:24 +00:00
|
|
|
static CameraFeaturesConfig fromJson(Map<String, dynamic> data) {
|
|
|
|
MapEntry<CameraFeature, bool> valueOrBool(CameraFeature feature, {bool defaultValue = true}) => MapEntry(
|
|
|
|
feature,
|
|
|
|
data[feature.name] as bool? ?? defaultValue,
|
|
|
|
);
|
|
|
|
|
|
|
|
return Map.fromEntries(
|
|
|
|
[
|
|
|
|
valueOrBool(CameraFeature.spotMetering),
|
|
|
|
valueOrBool(CameraFeature.histogram, defaultValue: false),
|
|
|
|
valueOrBool(CameraFeature.showFocalLength),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2023-11-11 20:05:11 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => map((key, value) => MapEntry(key.name, value));
|
|
|
|
}
|