mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
refactor: comic specific settings
This commit is contained in:
@@ -152,7 +152,6 @@ class Settings with ChangeNotifier {
|
||||
'blockedWords': [],
|
||||
'defaultSearchTarget': null,
|
||||
'autoPageTurningInterval': 5, // in seconds
|
||||
'enableComicSpecificSettings': false,
|
||||
'readerMode': 'galleryLeftToRight', // values of [ReaderMode]
|
||||
'readerScreenPicNumberForLandscape': 1, // 1 - 5
|
||||
'readerScreenPicNumberForPortrait': 1, // 1 - 5
|
||||
@@ -204,18 +203,19 @@ class Settings with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
bool haveComicSpecificSettings(String comicId, String sourceKey, String key) {
|
||||
return _data['comicSpecificSettings']?["$comicId@$sourceKey"]?.containsKey(
|
||||
key,
|
||||
) ??
|
||||
false;
|
||||
void setEnabledComicSpecificSettings(String comicId, String sourceKey, bool enabled) {
|
||||
setReaderSetting(comicId, sourceKey, "enabled", enabled);
|
||||
}
|
||||
|
||||
bool isComicSpecificSettingsEnabled(String? comicId, String? sourceKey) {
|
||||
if (comicId == null || sourceKey == null) {
|
||||
return false;
|
||||
}
|
||||
return _data['comicSpecificSettings']["$comicId@$sourceKey"]?["enabled"] == true;
|
||||
}
|
||||
|
||||
dynamic getReaderSetting(String comicId, String sourceKey, String key) {
|
||||
if (key == 'enableComicSpecificSettings') {
|
||||
return _data['enableComicSpecificSettings'];
|
||||
}
|
||||
if (_data['enableComicSpecificSettings'] == false) {
|
||||
if (!isComicSpecificSettingsEnabled(comicId, sourceKey)) {
|
||||
return _data[key];
|
||||
}
|
||||
return _data['comicSpecificSettings']["$comicId@$sourceKey"]?[key] ??
|
||||
@@ -228,16 +228,6 @@ class Settings with ChangeNotifier {
|
||||
String key,
|
||||
dynamic value,
|
||||
) {
|
||||
if (key == 'enableComicSpecificSettings') {
|
||||
_data['enableComicSpecificSettings'] = value;
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
if (_data['enableComicSpecificSettings'] == false) {
|
||||
_data[key] = value;
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
(_data['comicSpecificSettings'] as Map<String, dynamic>).putIfAbsent(
|
||||
"$comicId@$sourceKey",
|
||||
() => <String, dynamic>{},
|
||||
@@ -245,16 +235,8 @@ class Settings with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void resetComicReaderSettings(String comicId, String sourceKey) {
|
||||
final allComicSettings = _data['comicSpecificSettings'] as Map;
|
||||
if (allComicSettings.containsKey("$comicId@$sourceKey")) {
|
||||
allComicSettings.remove("$comicId@$sourceKey");
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void resetAllComicReaderSettings() {
|
||||
_data['comicSpecificSettings'] = <String, Map<String, dynamic>>{};
|
||||
void resetComicReaderSettings(String key) {
|
||||
(_data['comicSpecificSettings'] as Map).remove(key);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user