|
|
|
@ -17,7 +17,7 @@ class SettingsController with ChangeNotifier {
|
|
|
|
|
_themeMode = await _settingsService.themeMode();
|
|
|
|
|
_hostname = await _settingsService.keyStr("hostname");
|
|
|
|
|
_username = await _settingsService.keyStr("username");
|
|
|
|
|
_password = await _settingsService.keyStr("password");
|
|
|
|
|
_password = await _settingsService.keyStrSec("password");
|
|
|
|
|
// Important! Inform listeners a change has occurred.
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
@ -35,6 +35,10 @@ class SettingsController with ChangeNotifier {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
await _settingsService.setKeyStr(key, value);
|
|
|
|
|
}
|
|
|
|
|
Future<void> _setKeySec(String key, String value) async {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
await _settingsService.setKeyStrSec(key, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> setHostname(String newHostname) async {
|
|
|
|
|
_hostname = newHostname;
|
|
|
|
@ -48,24 +52,16 @@ class SettingsController with ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
Future<void> setPassword(String newPassword) async {
|
|
|
|
|
_password = newPassword;
|
|
|
|
|
await _setKey("password", password);
|
|
|
|
|
await _setKeySec("password", password);
|
|
|
|
|
Log().debug("password update");
|
|
|
|
|
}
|
|
|
|
|
/// Update and persist the ThemeMode based on the user's selection.
|
|
|
|
|
|
|
|
|
|
Future<void> updateThemeMode(ThemeMode? newThemeMode) async {
|
|
|
|
|
if (newThemeMode == null) return;
|
|
|
|
|
|
|
|
|
|
// Do not perform any work if new and old ThemeMode are identical
|
|
|
|
|
if (newThemeMode == _themeMode) return;
|
|
|
|
|
|
|
|
|
|
// Otherwise, store the new ThemeMode in memory
|
|
|
|
|
_themeMode = newThemeMode;
|
|
|
|
|
|
|
|
|
|
// Important! Inform listeners a change has occurred.
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|
|
|
|
|
// Persist the changes to a local database or the internet using the
|
|
|
|
|
// SettingService.
|
|
|
|
|
await _settingsService.updateThemeMode(newThemeMode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|