feat: 实现日历提醒 in-app fallback 机制及通知服务重构

This commit is contained in:
zl-q
2026-03-20 01:30:34 +08:00
parent 7fd536e976
commit d574128815
55 changed files with 4565 additions and 647 deletions
@@ -1,17 +1,23 @@
enum ReminderAction {
cancel('cancel'),
snooze10m('snooze_10m'),
timeout30s('timeout_30s'),
autoArchive('auto_archive');
archive('archive'),
snooze10m('snooze10m');
const ReminderAction(this.value);
final String value;
static ReminderAction fromValue(String raw) {
return ReminderAction.values.firstWhere(
(item) => item.value == raw,
orElse: () => ReminderAction.timeout30s,
);
switch (raw) {
case 'archive':
case 'cancel':
case 'auto_archive':
return ReminderAction.archive;
case 'snooze10m':
case 'snooze_10m':
case 'timeout_30s':
return ReminderAction.snooze10m;
default:
throw ArgumentError.value(raw, 'raw', 'Unsupported reminder action');
}
}
}
@@ -9,6 +9,7 @@ class ReminderPayload {
final String? color;
final ReminderPayloadMode mode;
final List<String> aggregateIds;
final int? fireTimeBucket;
final int version;
const ReminderPayload({
@@ -22,6 +23,7 @@ class ReminderPayload {
this.color,
this.mode = ReminderPayloadMode.single,
this.aggregateIds = const [],
this.fireTimeBucket,
this.version = 1,
});
@@ -36,6 +38,7 @@ class ReminderPayload {
String? color,
ReminderPayloadMode? mode,
List<String>? aggregateIds,
int? fireTimeBucket,
int? version,
}) {
return ReminderPayload(
@@ -49,6 +52,7 @@ class ReminderPayload {
color: color ?? this.color,
mode: mode ?? this.mode,
aggregateIds: aggregateIds ?? this.aggregateIds,
fireTimeBucket: fireTimeBucket ?? this.fireTimeBucket,
version: version ?? this.version,
);
}
@@ -65,6 +69,7 @@ class ReminderPayload {
'color': color,
'mode': mode.value,
'aggregateIds': aggregateIds,
'fireTimeBucket': fireTimeBucket,
'version': version,
};
}
@@ -104,6 +109,7 @@ class ReminderPayload {
color: json['color'] as String?,
mode: mode,
aggregateIds: aggregateIds,
fireTimeBucket: json['fireTimeBucket'] as int?,
version: (json['version'] as int?) ?? 1,
);
}
@@ -124,6 +130,7 @@ class ReminderPayload {
other.color == color &&
other.mode == mode &&
_listEquals(other.aggregateIds, aggregateIds) &&
other.fireTimeBucket == fireTimeBucket &&
other.version == version;
}
@@ -140,6 +147,7 @@ class ReminderPayload {
color,
mode,
Object.hashAll(aggregateIds),
fireTimeBucket,
version,
);
}