Erweiterungen
This commit is contained in:
1 parent
e9811da904
commit
b94e8f252a
6 files changed
+45
-5
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stadtbote/tools/util.dart';
|
||||
|
||||
enum AppLanguage {
|
||||
@@ -33,12 +34,16 @@ class AppLocalizations {
|
||||
|
||||
static const String _prefsLanguageKey = 'app_language';
|
||||
|
||||
// ValueNotifier für Sprachänderungen
|
||||
final ValueNotifier<AppLanguage> languageNotifier = ValueNotifier<AppLanguage>(AppLanguage.german);
|
||||
|
||||
AppLanguage _currentLanguage = AppLanguage.german;
|
||||
|
||||
AppLanguage get currentLanguage => _currentLanguage;
|
||||
|
||||
void setLanguage(AppLanguage language) {
|
||||
_currentLanguage = language;
|
||||
languageNotifier.value = language;
|
||||
Util.preferencesSaveString(_prefsLanguageKey, language.code);
|
||||
}
|
||||
|
||||
@@ -46,6 +51,7 @@ class AppLocalizations {
|
||||
final savedCode = Util.preferencesGetString(_prefsLanguageKey, null);
|
||||
if (savedCode != null) {
|
||||
_currentLanguage = AppLanguage.fromCode(savedCode);
|
||||
languageNotifier.value = _currentLanguage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ class Constants {
|
||||
static const String messageTopicRequestConnectionStatus = "request_connection_status";
|
||||
static const String messageTopicCurrentConnectionStatus = "current_connection_status";
|
||||
static const String messageTopicBWVEnabled = "bwv_enabled";
|
||||
static const String messageTopicLanguageChanged = "language_changed";
|
||||
|
||||
static const String messageShowPopup = "show_popup";
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'package:stadtbote/tools/app_localizations.dart';
|
||||
|
||||
class LanguageChangedMessage {
|
||||
final AppLanguage newLanguage;
|
||||
|
||||
LanguageChangedMessage(this.newLanguage);
|
||||
}
|
||||
Reference in new issue
Block a user