1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-09-18 21:38:48 +00:00

Add dark theme

This commit is contained in:
2019-11-01 13:48:40 +01:00
parent 9e151639c2
commit 6a34df6814
3 changed files with 104 additions and 8 deletions

View File

@@ -9,9 +9,12 @@ import 'package:shared_preferences/shared_preferences.dart';
///
/// @author Pierre HUBERT
enum PreferencesKeyList { LOGIN_TOKENS }
enum PreferencesKeyList { LOGIN_TOKENS, ENABLE_DARK_THEME }
const _PreferenceKeysName = {PreferencesKeyList.LOGIN_TOKENS: "login_tokens"};
const _PreferenceKeysName = {
PreferencesKeyList.LOGIN_TOKENS: "login_tokens",
PreferencesKeyList.ENABLE_DARK_THEME: "dark_theme",
};
class PreferencesHelper {
static PreferencesHelper _instance;
@@ -51,11 +54,20 @@ class PreferencesHelper {
}
}
Future<void> setString(PreferencesKeyList key, String value) async {
await _sharedPreferences.setString(_PreferenceKeysName[key], value);
Future<bool> setString(PreferencesKeyList key, String value) async {
return await _sharedPreferences.setString(_PreferenceKeysName[key], value);
}
String getString(PreferencesKeyList key) {
return _sharedPreferences.getString(_PreferenceKeysName[key]);
}
Future<bool> setBool(PreferencesKeyList key, bool value) async {
return await _sharedPreferences.setBool(_PreferenceKeysName[key], value);
}
bool getBool(PreferencesKeyList key, {bool alternative = false}) {
final v = _sharedPreferences.getBool(_PreferenceKeysName[key]);
return v == null ? alternative : v;
}
}