Files
jamshalat-diary/lib/data/local/models/app_settings.dart
Dwindi Ramadhana 4badfb6521 Notification system audit: fix 6 defects, close 5 gaps, add rich notifications (v1.1.0)
Defects fixed:
- D1: Fix notification ID range collision (report reminders 700k→2M+)
- D2: Streak risk now checks both dzikir pagi & petang
- D3: _cancelPrayerPending no longer kills non-prayer notifications
- D4: Push notifications carry deeplink in payload for proper routing
- D5: Add reconfigureTimeZoneIfNeeded() for TZ change detection
- D6: Defer launch notification routing until widget tree is ready

Gaps closed:
- G1: Add streak risk + weekly summary toggles to settings UI
- G2: Verified boot reschedule already in place (flutter_local_notifications v21)
- G3: Remove unused mirrorAdzanToInbox field and legacy cleanup calls
- G4: Add notif_push_opened analytics tracking
- G5: Add notif_settings_changed analytics tracking

Enhancements:
- O1: Rich notification with Sudah Sholat action button on report reminders
- O2: Permission check on app resume via WidgetsBindingObserver (30s throttle)
- O2b: Fix stretched notification icon (white crescent moon vector drawable)
- O3: Expired inbox cleanup in background sync
- O4: Haptic feedback on notification bell quick actions

Bump version 1.0.8+9 → 1.1.0+10
2026-06-06 22:38:02 +07:00

174 lines
3.7 KiB
Dart

import 'package:hive_flutter/hive_flutter.dart';
part 'app_settings.g.dart';
/// User settings stored in Hive.
@HiveType(typeId: 0)
class AppSettings extends HiveObject {
@HiveField(0)
String userName;
@HiveField(1)
String userEmail;
@HiveField(2)
int themeModeIndex; // 0=system, 1=light, 2=dark
@HiveField(3)
double arabicFontSize;
@HiveField(4)
String uiLanguage; // 'id' or 'en'
@HiveField(5)
Map<String, bool> adhanEnabled;
@HiveField(6)
Map<String, int> iqamahOffset; // minutes
@HiveField(7)
String? checklistReminderTime; // HH:mm format
@HiveField(8)
double? lastLat;
@HiveField(9)
double? lastLng;
@HiveField(10)
String? lastCityName;
@HiveField(11)
int rawatibLevel; // 0 = Off, 1 = Muakkad Only, 2 = Full
@HiveField(12)
int tilawahTargetValue;
@HiveField(13)
String tilawahTargetUnit; // 'Juz', 'Halaman', 'Ayat'
@HiveField(14)
bool tilawahAutoSync;
@HiveField(15)
bool trackDzikir;
@HiveField(16)
bool trackPuasa;
@HiveField(17)
bool showLatin;
@HiveField(18)
bool showTerjemahan;
@HiveField(19)
bool simpleMode; // false = Mode Lengkap, true = Mode Simpel
@HiveField(20)
String dzikirDisplayMode; // 'list' | 'focus'
@HiveField(21)
String dzikirCounterButtonPosition; // 'bottomPill' | 'fabCircle'
@HiveField(22)
bool dzikirAutoAdvance;
@HiveField(23)
bool dzikirHapticOnCount;
@HiveField(24)
bool alertsEnabled;
@HiveField(25)
bool inboxEnabled;
@HiveField(26)
bool streakRiskEnabled;
@HiveField(27)
bool dailyChecklistReminderEnabled;
@HiveField(28)
bool weeklySummaryEnabled;
@HiveField(29)
String quietHoursStart; // HH:mm
@HiveField(30)
String quietHoursEnd; // HH:mm
@HiveField(31)
int maxNonPrayerPushPerDay;
@HiveField(33)
bool tilawahAutoContinueNextSurah;
@HiveField(34)
bool shalatReportReminderEnabled;
@HiveField(35)
int shalatReportReminderDelayMinutes;
@HiveField(36)
int shalatReportReminderRepeatCount;
@HiveField(37)
int shalatReportReminderRepeatIntervalMinutes;
AppSettings({
this.userName = 'User',
this.userEmail = '',
this.themeModeIndex = 0,
this.arabicFontSize = 24.0,
this.uiLanguage = 'id',
Map<String, bool>? adhanEnabled,
Map<String, int>? iqamahOffset,
this.checklistReminderTime = '09:00',
this.lastLat,
this.lastLng,
this.lastCityName,
this.rawatibLevel = 1, // Default to Muakkad
this.tilawahTargetValue = 1,
this.tilawahTargetUnit = 'Juz',
this.tilawahAutoSync = false,
this.trackDzikir = true,
this.trackPuasa = false,
this.showLatin = true,
this.showTerjemahan = true,
this.simpleMode = false,
this.dzikirDisplayMode = 'list',
this.dzikirCounterButtonPosition = 'bottomPill',
this.dzikirAutoAdvance = true,
this.dzikirHapticOnCount = true,
this.alertsEnabled = true,
this.inboxEnabled = true,
this.streakRiskEnabled = true,
this.dailyChecklistReminderEnabled = false,
this.weeklySummaryEnabled = true,
this.quietHoursStart = '22:00',
this.quietHoursEnd = '05:00',
this.maxNonPrayerPushPerDay = 2,
this.tilawahAutoContinueNextSurah = true,
this.shalatReportReminderEnabled = true,
this.shalatReportReminderDelayMinutes = 30,
this.shalatReportReminderRepeatCount = 1,
this.shalatReportReminderRepeatIntervalMinutes = 15,
}) : adhanEnabled = adhanEnabled ??
{
'fajr': true,
'dhuhr': true,
'asr': true,
'maghrib': true,
'isha': true,
},
iqamahOffset = iqamahOffset ??
{
'fajr': 15,
'dhuhr': 10,
'asr': 10,
'maghrib': 5,
'isha': 10,
};
}