Improve notifications, tilawah flow, and dzikir structure

This commit is contained in:
Dwindi Ramadhana
2026-05-20 19:52:15 +07:00
parent c32b56c00e
commit 5195ba19ad
19 changed files with 1056 additions and 318 deletions

View File

@@ -219,15 +219,36 @@ Future<void> _syncAdhanNotifications(
);
}
final schedulesByDate = <String, Map<String, String>>{
schedule.date: schedule.times,
final schedulesByDate = <String, Map<String, String>>{};
final today = DateTime.now();
final startDate = DateTime(today.year, today.month, today.day);
final endDate = startDate.add(const Duration(days: 35));
final monthKeys = <String>{
DateFormat('yyyy-MM').format(startDate),
DateFormat('yyyy-MM').format(endDate),
};
final baseDate = DateTime.tryParse(schedule.date);
if (baseDate != null) {
final nextDate = DateFormat('yyyy-MM-dd')
.format(baseDate.add(const Duration(days: 1)));
if (!schedulesByDate.containsKey(nextDate)) {
for (final monthKey in monthKeys) {
final monthly = await MyQuranSholatService.instance
.getMonthlySchedule(cityId, monthKey);
for (final entry in monthly.entries) {
final date = DateTime.tryParse(entry.key);
if (date == null) continue;
final normalized = DateTime(date.year, date.month, date.day);
if (normalized.isBefore(startDate) || normalized.isAfter(endDate)) {
continue;
}
schedulesByDate[entry.key] = entry.value;
}
}
if (schedulesByDate.isEmpty) {
schedulesByDate[schedule.date] = schedule.times;
final baseDate = DateTime.tryParse(schedule.date);
if (baseDate != null) {
final nextDate = DateFormat('yyyy-MM-dd')
.format(baseDate.add(const Duration(days: 1)));
final nextSchedule = await MyQuranSholatService.instance
.getDailySchedule(cityId, nextDate);
if (nextSchedule != null) {
@@ -241,6 +262,11 @@ Future<void> _syncAdhanNotifications(
adhanEnabled: settings.adhanEnabled,
iqamahOffset: settings.iqamahOffset,
schedulesByDate: schedulesByDate,
reportReminderEnabled: settings.shalatReportReminderEnabled,
reportReminderDelayMinutes: settings.shalatReportReminderDelayMinutes,
reportReminderRepeatCount: settings.shalatReportReminderRepeatCount,
reportReminderRepeatIntervalMinutes:
settings.shalatReportReminderRepeatIntervalMinutes,
);
await NotificationService.instance.syncHabitNotifications(
settings: settings,