2022-01-19 13:47:54 +01:00
|
|
|
import 'package:get_it/get_it.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
|
|
final SharedPreferences _prefs = GetIt.instance.get<SharedPreferences>();
|
|
|
|
|
|
|
|
const Map<String, dynamic> _defaults = {
|
|
|
|
'romajiEnabled': false,
|
2022-01-23 03:15:33 +01:00
|
|
|
'extensiveSearch': true,
|
2022-01-19 13:47:54 +01:00
|
|
|
'darkThemeEnabled': false,
|
|
|
|
'autoThemeEnabled': false,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool _getSettingOrDefault(String settingName) =>
|
|
|
|
_prefs.getBool(settingName) ?? _defaults[settingName];
|
|
|
|
|
|
|
|
bool get romajiEnabled => _getSettingOrDefault('romajiEnabled');
|
2022-01-23 03:15:33 +01:00
|
|
|
bool get extensiveSearchEnabled => _getSettingOrDefault('extensiveSearch');
|
2022-01-19 13:47:54 +01:00
|
|
|
bool get darkThemeEnabled => _getSettingOrDefault('darkThemeEnabled');
|
|
|
|
bool get autoThemeEnabled => _getSettingOrDefault('autoThemeEnabled');
|
|
|
|
|
|
|
|
set romajiEnabled(b) => _prefs.setBool('romajiEnabled', b);
|
2022-01-23 03:15:33 +01:00
|
|
|
set extensiveSearchEnabled(b) => _prefs.setBool('extensiveSearch', b);
|
2022-01-19 13:47:54 +01:00
|
|
|
set darkThemeEnabled(b) => _prefs.setBool('darkThemeEnabled', b);
|
|
|
|
set autoThemeEnabled(b) => _prefs.setBool('autoThemeEnabled', b);
|