progress in new theme sharing
This commit is contained in:
@@ -35,6 +35,8 @@ const settingsDB = DatabaseStruct("settings", {
|
||||
"renamed_teachers_italics": int,
|
||||
"live_activity_color": String,
|
||||
"welcome_message": String, "app_icon": String,
|
||||
// paints
|
||||
"current_theme_id": String, "current_theme_display_name": String, "current_theme_creator": String,
|
||||
});
|
||||
// DON'T FORGET TO UPDATE DEFAULT VALUES IN `initDB` MIGRATION OR ELSE PARENTS WILL COMPLAIN ABOUT THEIR CHILDREN MISSING
|
||||
// YOU'VE BEEN WARNED!!!
|
||||
|
||||
@@ -79,6 +79,10 @@ class SettingsProvider extends ChangeNotifier {
|
||||
Color _liveActivityColor;
|
||||
String _welcomeMessage;
|
||||
String _appIcon;
|
||||
// current theme
|
||||
String _currentThemeId;
|
||||
String _currentThemeDisplayName;
|
||||
String _currentThemeCreator;
|
||||
|
||||
SettingsProvider({
|
||||
DatabaseProvider? database,
|
||||
@@ -127,6 +131,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
required Color liveActivityColor,
|
||||
required String welcomeMessage,
|
||||
required String appIcon,
|
||||
required String currentThemeId,
|
||||
required String currentThemeDisplayName,
|
||||
required String currentThemeCreator,
|
||||
}) : _database = database,
|
||||
_language = language,
|
||||
_startPage = startPage,
|
||||
@@ -172,7 +179,10 @@ class SettingsProvider extends ChangeNotifier {
|
||||
_renamedTeachersItalics = renameTeachersItalics,
|
||||
_liveActivityColor = liveActivityColor,
|
||||
_welcomeMessage = welcomeMessage,
|
||||
_appIcon = appIcon;
|
||||
_appIcon = appIcon,
|
||||
_currentThemeId = currentThemeId,
|
||||
_currentThemeDisplayName = currentThemeDisplayName,
|
||||
_currentThemeCreator = currentThemeCreator;
|
||||
|
||||
factory SettingsProvider.fromMap(Map map,
|
||||
{required DatabaseProvider database}) {
|
||||
@@ -238,6 +248,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
liveActivityColor: Color(map["live_activity_color"]),
|
||||
welcomeMessage: map["welcome_message"],
|
||||
appIcon: map["app_icon"],
|
||||
currentThemeId: map['current_theme_id'],
|
||||
currentThemeDisplayName: map['current_theme_display_name'],
|
||||
currentThemeCreator: map['current_theme_creator'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -291,6 +304,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
"live_activity_color": _liveActivityColor.value,
|
||||
"welcome_message": _welcomeMessage,
|
||||
"app_icon": _appIcon,
|
||||
"current_theme_id": _currentThemeId,
|
||||
"current_theme_display_name": _currentThemeDisplayName,
|
||||
"current_theme_creator": _currentThemeCreator,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -348,6 +364,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
liveActivityColor: const Color(0xFF676767),
|
||||
welcomeMessage: '',
|
||||
appIcon: 'refilc_default',
|
||||
currentThemeId: '',
|
||||
currentThemeDisplayName: '',
|
||||
currentThemeCreator: 'reFilc',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -400,6 +419,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
Color get liveActivityColor => _liveActivityColor;
|
||||
String get welcomeMessage => _welcomeMessage;
|
||||
String get appIcon => _appIcon;
|
||||
String get currentThemeId => _currentThemeId;
|
||||
String get currentThemeDisplayName => _currentThemeDisplayName;
|
||||
String get currentThemeCreator => _currentThemeCreator;
|
||||
|
||||
Future<void> update({
|
||||
bool store = true,
|
||||
@@ -448,6 +470,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
Color? liveActivityColor,
|
||||
String? welcomeMessage,
|
||||
String? appIcon,
|
||||
String? currentThemeId,
|
||||
String? currentThemeDisplayName,
|
||||
String? currentThemeCreator,
|
||||
}) async {
|
||||
if (language != null && language != _language) _language = language;
|
||||
if (startPage != null && startPage != _startPage) _startPage = startPage;
|
||||
@@ -578,6 +603,17 @@ class SettingsProvider extends ChangeNotifier {
|
||||
if (appIcon != null && appIcon != _appIcon) {
|
||||
_appIcon = appIcon;
|
||||
}
|
||||
if (currentThemeId != null && currentThemeId != _currentThemeId) {
|
||||
_currentThemeId = currentThemeId;
|
||||
}
|
||||
if (currentThemeDisplayName != null &&
|
||||
currentThemeDisplayName != _currentThemeDisplayName) {
|
||||
_currentThemeDisplayName = currentThemeDisplayName;
|
||||
}
|
||||
if (currentThemeCreator != null &&
|
||||
currentThemeCreator != _currentThemeCreator) {
|
||||
_currentThemeCreator = currentThemeCreator;
|
||||
}
|
||||
// store or not
|
||||
if (store) await _database?.store.storeSettings(this);
|
||||
notifyListeners();
|
||||
|
||||
Reference in New Issue
Block a user