mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-05-13 11:40:42 +00:00
enable focal length feature by default
This commit is contained in:
parent
eb90123a26
commit
10794258b8
4 changed files with 26 additions and 30 deletions
|
@ -7,8 +7,20 @@ enum CameraFeature {
|
|||
typedef CameraFeaturesConfig = Map<CameraFeature, bool>;
|
||||
|
||||
extension CameraFeaturesConfigJson on CameraFeaturesConfig {
|
||||
static CameraFeaturesConfig fromJson(Map<String, dynamic> data) =>
|
||||
<CameraFeature, bool>{for (final f in CameraFeature.values) f: data[f.name] as bool? ?? false};
|
||||
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),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => map((key, value) => MapEntry(key.name, value));
|
||||
}
|
||||
|
|
|
@ -94,34 +94,16 @@ class UserPreferencesService {
|
|||
set showEv100(bool value) => _sharedPreferences.setBool(showEv100Key, value);
|
||||
|
||||
MeteringScreenLayoutConfig get meteringScreenLayout {
|
||||
final configJson = _sharedPreferences.getString(meteringScreenLayoutKey);
|
||||
if (configJson != null) {
|
||||
return MeteringScreenLayoutConfigJson.fromJson(
|
||||
json.decode(configJson) as Map<String, dynamic>,
|
||||
);
|
||||
} else {
|
||||
return {
|
||||
MeteringScreenLayoutFeature.equipmentProfiles: true,
|
||||
MeteringScreenLayoutFeature.extremeExposurePairs: true,
|
||||
MeteringScreenLayoutFeature.filmPicker: true,
|
||||
};
|
||||
}
|
||||
final configJson = _sharedPreferences.getString(meteringScreenLayoutKey) ?? '{}';
|
||||
return MeteringScreenLayoutConfigJson.fromJson(json.decode(configJson) as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
set meteringScreenLayout(MeteringScreenLayoutConfig value) =>
|
||||
_sharedPreferences.setString(meteringScreenLayoutKey, json.encode(value.toJson()));
|
||||
|
||||
CameraFeaturesConfig get cameraFeatures {
|
||||
final configJson = _sharedPreferences.getString(cameraFeaturesKey);
|
||||
if (configJson != null) {
|
||||
return CameraFeaturesConfigJson.fromJson(json.decode(configJson) as Map<String, dynamic>);
|
||||
} else {
|
||||
return {
|
||||
CameraFeature.spotMetering: false,
|
||||
CameraFeature.histogram: false,
|
||||
CameraFeature.showFocalLength: false,
|
||||
};
|
||||
}
|
||||
final configJson = _sharedPreferences.getString(cameraFeaturesKey) ?? '{}';
|
||||
return CameraFeaturesConfigJson.fromJson(json.decode(configJson) as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
set cameraFeatures(CameraFeaturesConfig value) =>
|
||||
|
|
|
@ -22,13 +22,13 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
test('Legacy (no spotMetering & histogram)', () {
|
||||
test('Legacy', () {
|
||||
expect(
|
||||
CameraFeaturesConfigJson.fromJson({}),
|
||||
{
|
||||
CameraFeature.spotMetering: false,
|
||||
CameraFeature.spotMetering: true,
|
||||
CameraFeature.histogram: false,
|
||||
CameraFeature.showFocalLength: false,
|
||||
CameraFeature.showFocalLength: true,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
@ -40,10 +40,12 @@ void main() {
|
|||
{
|
||||
CameraFeature.spotMetering: true,
|
||||
CameraFeature.histogram: true,
|
||||
CameraFeature.showFocalLength: true,
|
||||
}.toJson(),
|
||||
{
|
||||
'spotMetering': true,
|
||||
'histogram': true,
|
||||
'showFocalLength': true,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -270,9 +270,9 @@ void main() {
|
|||
expect(
|
||||
service.cameraFeatures,
|
||||
{
|
||||
CameraFeature.spotMetering: false,
|
||||
CameraFeature.spotMetering: true,
|
||||
CameraFeature.histogram: false,
|
||||
CameraFeature.showFocalLength: false,
|
||||
CameraFeature.showFocalLength: true,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
@ -285,7 +285,7 @@ void main() {
|
|||
{
|
||||
CameraFeature.spotMetering: false,
|
||||
CameraFeature.histogram: true,
|
||||
CameraFeature.showFocalLength: false,
|
||||
CameraFeature.showFocalLength: true,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue