feat: Implement snooze functionality for notifications

- Added snooze duration setting in SettingsScreen.
- Created DebugNotificationsScreen to view pending notifications and logs.
- Integrated notification logging with NotificationDebugStore.
- Enhanced SimpleNotificationService to handle snooze actions and log notifications.
- Removed ProfileSetupScreen as it is no longer needed.
- Updated NotificationRouter to manage snooze actions without UI.
- Refactored settings provider to include snooze duration management.
This commit is contained in:
2025-08-30 01:51:38 +02:00
parent 811c1f3d6a
commit f7966ce587
8 changed files with 940 additions and 183 deletions

View File

@@ -24,7 +24,8 @@ class SettingsProvider extends ChangeNotifier {
int _nightStart = 23;
int _nightEnd = 4;
// Notifications
int _snoozeMinutes = 10;
// Auto-sync settings
bool _autoSyncEnabled = false;
@@ -32,19 +33,6 @@ class SettingsProvider extends ChangeNotifier {
ThemeOption get themeOption => _themeOption;
// Profile getters
DateTime? get dateOfBirth => _dateOfBirth;
String? get gender => _gender;
int? get age {
if (_dateOfBirth == null) return null;
final now = DateTime.now();
int years = now.year - _dateOfBirth!.year;
final hasHadBirthday = (now.month > _dateOfBirth!.month) ||
(now.month == _dateOfBirth!.month && now.day >= _dateOfBirth!.day);
if (!hasHadBirthday) years--;
return years;
}
// Time range getters
int get morningStart => _morningStart;
int get morningEnd => _morningEnd;
@@ -55,7 +43,8 @@ class SettingsProvider extends ChangeNotifier {
int get nightStart => _nightStart;
int get nightEnd => _nightEnd;
// Notifications
int get snoozeMinutes => _snoozeMinutes;
// Auto-sync getters
bool get autoSyncEnabled => _autoSyncEnabled;
@@ -104,7 +93,8 @@ class SettingsProvider extends ChangeNotifier {
_nightStart = prefs.getInt('night_start') ?? 23;
_nightEnd = prefs.getInt('night_end') ?? 4;
// Load snooze setting
_snoozeMinutes = prefs.getInt('snooze_minutes') ?? 10;
// Load auto-sync settings
_autoSyncEnabled = prefs.getBool('auto_sync_enabled') ?? false;
@@ -269,7 +259,18 @@ class SettingsProvider extends ChangeNotifier {
}
}
// Notifications setters
Future<void> setSnoozeMinutes(int minutes) async {
const allowed = [5, 10, 15, 20];
if (!allowed.contains(minutes)) {
throw ArgumentError('Snooze minutes must be one of ${allowed.join(", ")}');
}
_snoozeMinutes = minutes;
notifyListeners();
final prefs = await SharedPreferences.getInstance();
await prefs.setInt('snooze_minutes', minutes);
}
// Auto-sync setters
Future<void> setAutoSyncEnabled(bool enabled) async {