add notification for messages

This commit is contained in:
hihihaha
2023-08-29 14:32:40 +02:00
parent bc4e4e9b5a
commit e280227ee1
9 changed files with 141 additions and 17 deletions

View File

@@ -33,6 +33,7 @@ class SettingsProvider extends ChangeNotifier {
bool _notificationsEnabled;
bool _notificationsGradesEnabled;
bool _notificationsAbsencesEnabled;
bool _notificationsMessagesEnabled;
/*
notificationsBitfield values:
@@ -88,6 +89,7 @@ class SettingsProvider extends ChangeNotifier {
required bool notificationsEnabled,
required bool notificationsGradesEnabled,
required bool notificationsAbsencesEnabled,
required bool notificationsMessagesEnabled,
required int notificationsBitfield,
required bool developerMode,
required int notificationPollInterval,
@@ -128,6 +130,7 @@ class SettingsProvider extends ChangeNotifier {
_notificationsEnabled = notificationsEnabled,
_notificationsGradesEnabled = notificationsGradesEnabled,
_notificationsAbsencesEnabled = notificationsAbsencesEnabled,
_notificationsMessagesEnabled = notificationsMessagesEnabled,
_notificationsBitfield = notificationsBitfield,
_developerMode = developerMode,
_notificationPollInterval = notificationPollInterval,
@@ -186,6 +189,7 @@ class SettingsProvider extends ChangeNotifier {
notificationsEnabled: map["notifications"] == 1,
notificationsGradesEnabled: map["notifications_grades"] == 1,
notificationsAbsencesEnabled: map["notifications_absences"] == 1,
notificationsMessagesEnabled: map["notifications_messages"] == 1,
notificationsBitfield: map["notifications_bitfield"],
notificationPollInterval: map["notification_poll_interval"],
developerMode: map["developer_mode"] == 1,
@@ -230,6 +234,7 @@ class SettingsProvider extends ChangeNotifier {
"notifications": _notificationsEnabled ? 1 : 0,
"notifications_grades": _notificationsGradesEnabled ? 1 : 0,
"notifications_absences": _notificationsAbsencesEnabled ? 1 : 0,
"notifications_messages": _notificationsMessagesEnabled ? 1 : 0,
"notifications_bitfield": _notificationsBitfield,
"developer_mode": _developerMode ? 1 : 0,
"grade_color1": _gradeColors[0].value,
@@ -285,6 +290,7 @@ class SettingsProvider extends ChangeNotifier {
notificationsEnabled: true,
notificationsGradesEnabled: true,
notificationsAbsencesEnabled: true,
notificationsMessagesEnabled: true,
notificationsBitfield: 255,
developerMode: false,
notificationPollInterval: 1,
@@ -328,6 +334,7 @@ class SettingsProvider extends ChangeNotifier {
bool get notificationsEnabled => _notificationsEnabled;
bool get notificationsGradesEnabled => _notificationsGradesEnabled;
bool get notificationsAbsencesEnabled => _notificationsAbsencesEnabled;
bool get notificationsMessagesEnabled => _notificationsMessagesEnabled;
int get notificationsBitfield => _notificationsBitfield;
bool get developerMode => _developerMode;
int get notificationPollInterval => _notificationPollInterval;
@@ -373,6 +380,7 @@ class SettingsProvider extends ChangeNotifier {
bool? notificationsEnabled,
bool? notificationsGradesEnabled,
bool? notificationsAbsencesEnabled,
bool? notificationsMessagesEnabled,
int? notificationsBitfield,
bool? developerMode,
int? notificationPollInterval,
@@ -432,6 +440,10 @@ class SettingsProvider extends ChangeNotifier {
notificationsAbsencesEnabled != _notificationsAbsencesEnabled) {
_notificationsAbsencesEnabled = notificationsAbsencesEnabled;
}
if (notificationsMessagesEnabled != null &&
notificationsMessagesEnabled != _notificationsMessagesEnabled) {
_notificationsMessagesEnabled = notificationsMessagesEnabled;
}
if (notificationsBitfield != null &&
notificationsBitfield != _notificationsBitfield) {
_notificationsBitfield = notificationsBitfield;