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>;
|
typedef CameraFeaturesConfig = Map<CameraFeature, bool>;
|
||||||
|
|
||||||
extension CameraFeaturesConfigJson on CameraFeaturesConfig {
|
extension CameraFeaturesConfigJson on CameraFeaturesConfig {
|
||||||
static CameraFeaturesConfig fromJson(Map<String, dynamic> data) =>
|
static CameraFeaturesConfig fromJson(Map<String, dynamic> data) {
|
||||||
<CameraFeature, bool>{for (final f in CameraFeature.values) f: data[f.name] as bool? ?? false};
|
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));
|
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);
|
set showEv100(bool value) => _sharedPreferences.setBool(showEv100Key, value);
|
||||||
|
|
||||||
MeteringScreenLayoutConfig get meteringScreenLayout {
|
MeteringScreenLayoutConfig get meteringScreenLayout {
|
||||||
final configJson = _sharedPreferences.getString(meteringScreenLayoutKey);
|
final configJson = _sharedPreferences.getString(meteringScreenLayoutKey) ?? '{}';
|
||||||
if (configJson != null) {
|
return MeteringScreenLayoutConfigJson.fromJson(json.decode(configJson) as Map<String, dynamic>);
|
||||||
return MeteringScreenLayoutConfigJson.fromJson(
|
|
||||||
json.decode(configJson) as Map<String, dynamic>,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
MeteringScreenLayoutFeature.equipmentProfiles: true,
|
|
||||||
MeteringScreenLayoutFeature.extremeExposurePairs: true,
|
|
||||||
MeteringScreenLayoutFeature.filmPicker: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set meteringScreenLayout(MeteringScreenLayoutConfig value) =>
|
set meteringScreenLayout(MeteringScreenLayoutConfig value) =>
|
||||||
_sharedPreferences.setString(meteringScreenLayoutKey, json.encode(value.toJson()));
|
_sharedPreferences.setString(meteringScreenLayoutKey, json.encode(value.toJson()));
|
||||||
|
|
||||||
CameraFeaturesConfig get cameraFeatures {
|
CameraFeaturesConfig get cameraFeatures {
|
||||||
final configJson = _sharedPreferences.getString(cameraFeaturesKey);
|
final configJson = _sharedPreferences.getString(cameraFeaturesKey) ?? '{}';
|
||||||
if (configJson != null) {
|
|
||||||
return CameraFeaturesConfigJson.fromJson(json.decode(configJson) as Map<String, dynamic>);
|
return CameraFeaturesConfigJson.fromJson(json.decode(configJson) as Map<String, dynamic>);
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
CameraFeature.spotMetering: false,
|
|
||||||
CameraFeature.histogram: false,
|
|
||||||
CameraFeature.showFocalLength: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set cameraFeatures(CameraFeaturesConfig value) =>
|
set cameraFeatures(CameraFeaturesConfig value) =>
|
||||||
|
|
|
@ -22,13 +22,13 @@ void main() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Legacy (no spotMetering & histogram)', () {
|
test('Legacy', () {
|
||||||
expect(
|
expect(
|
||||||
CameraFeaturesConfigJson.fromJson({}),
|
CameraFeaturesConfigJson.fromJson({}),
|
||||||
{
|
{
|
||||||
CameraFeature.spotMetering: false,
|
CameraFeature.spotMetering: true,
|
||||||
CameraFeature.histogram: false,
|
CameraFeature.histogram: false,
|
||||||
CameraFeature.showFocalLength: false,
|
CameraFeature.showFocalLength: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -40,10 +40,12 @@ void main() {
|
||||||
{
|
{
|
||||||
CameraFeature.spotMetering: true,
|
CameraFeature.spotMetering: true,
|
||||||
CameraFeature.histogram: true,
|
CameraFeature.histogram: true,
|
||||||
|
CameraFeature.showFocalLength: true,
|
||||||
}.toJson(),
|
}.toJson(),
|
||||||
{
|
{
|
||||||
'spotMetering': true,
|
'spotMetering': true,
|
||||||
'histogram': true,
|
'histogram': true,
|
||||||
|
'showFocalLength': true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -270,9 +270,9 @@ void main() {
|
||||||
expect(
|
expect(
|
||||||
service.cameraFeatures,
|
service.cameraFeatures,
|
||||||
{
|
{
|
||||||
CameraFeature.spotMetering: false,
|
CameraFeature.spotMetering: true,
|
||||||
CameraFeature.histogram: false,
|
CameraFeature.histogram: false,
|
||||||
CameraFeature.showFocalLength: false,
|
CameraFeature.showFocalLength: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -285,7 +285,7 @@ void main() {
|
||||||
{
|
{
|
||||||
CameraFeature.spotMetering: false,
|
CameraFeature.spotMetering: false,
|
||||||
CameraFeature.histogram: true,
|
CameraFeature.histogram: true,
|
||||||
CameraFeature.showFocalLength: false,
|
CameraFeature.showFocalLength: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue