Fix release notification resource and add multiple advance reminders

This commit is contained in:
Codex
2026-10-14 11:30:37 +08:00
parent caf7abe0c0
commit 4d86db3dd5
16 changed files with 350 additions and 58 deletions
+16 -5
View File
@@ -3,23 +3,31 @@ import 'semester.dart';
enum ColorMode { single, multicolor }
class AppSettings {
const AppSettings({
AppSettings({
this.semester,
this.remindersEnabled = true,
this.reminderMinutes = 15,
int reminderMinutes = 15,
List<int>? reminderOffsets,
this.colorMode = ColorMode.multicolor,
this.singleColorArgb = 0xFF348F91,
this.calendarEnabled = false,
this.calendarId,
this.courseHeightScale = defaultCourseHeightScale,
});
}) : reminderOffsets = List.unmodifiable(
(reminderOffsets ?? [reminderMinutes]).toSet().toList()..sort(),
);
static const allowedReminderMinutes = [5, 10, 15, 30, 60];
static const defaultCourseHeightScale = 1.25;
static const minCourseHeightScale = 0.8;
static const maxCourseHeightScale = 2.0;
final double courseHeightScale;
final Semester? semester;
final bool remindersEnabled, calendarEnabled;
final int reminderMinutes, singleColorArgb;
final int singleColorArgb;
final List<int> reminderOffsets;
// Retain the single-value API and JSON field for existing saved data.
int get reminderMinutes =>
reminderOffsets.isEmpty ? 15 : reminderOffsets.first;
final ColorMode colorMode;
final String? calendarId;
AppSettings copyWith({
@@ -27,6 +35,7 @@ class AppSettings {
bool clearSemester = false,
bool? remindersEnabled,
int? reminderMinutes,
List<int>? reminderOffsets,
ColorMode? colorMode,
int? singleColorArgb,
bool? calendarEnabled,
@@ -35,7 +44,9 @@ class AppSettings {
}) => AppSettings(
semester: clearSemester ? null : semester ?? this.semester,
remindersEnabled: remindersEnabled ?? this.remindersEnabled,
reminderMinutes: reminderMinutes ?? this.reminderMinutes,
reminderOffsets:
reminderOffsets ??
(reminderMinutes == null ? this.reminderOffsets : [reminderMinutes]),
colorMode: colorMode ?? this.colorMode,
singleColorArgb: singleColorArgb ?? this.singleColorArgb,
calendarEnabled: calendarEnabled ?? this.calendarEnabled,