refactor(calendar): remove deprecated reminder components

This commit is contained in:
qzl
2026-03-20 18:42:58 +08:00
parent 9ece726de0
commit 6e35fff9a4
20 changed files with 47 additions and 1143 deletions
-5
View File
@@ -20,7 +20,6 @@ import '../../features/calendar/data/calendar_api.dart';
import '../../features/calendar/data/services/calendar_repository.dart';
import '../../features/calendar/data/services/calendar_service.dart';
import '../../features/calendar/reminders/reminder_action_executor.dart';
import '../../features/calendar/reminders/reminder_outbox_store.dart';
import '../../features/calendar/ui/calendar_state_manager.dart';
import '../../features/friends/data/friends_api.dart';
import '../../features/messages/data/inbox_api.dart';
@@ -98,15 +97,11 @@ Future<void> configureDependencies() async {
);
sl.registerSingleton<CalendarRepository>(calendarRepository);
final reminderOutboxStore = ReminderOutboxStore(sharedPreferences);
sl.registerSingleton<ReminderOutboxStore>(reminderOutboxStore);
sl.registerSingleton<LocalNotificationService>(LocalNotificationService());
final reminderActionExecutor = ReminderActionExecutor(
calendarService: calendarService,
notificationService: sl<LocalNotificationService>(),
outboxStore: reminderOutboxStore,
);
sl.registerSingleton<ReminderActionExecutor>(reminderActionExecutor);
@@ -4,7 +4,6 @@ import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:timezone/data/latest.dart' as tz_data;
import 'package:timezone/timezone.dart' as tz;
@@ -12,8 +11,6 @@ import 'reminder_notification_callbacks.dart';
import '../../features/calendar/data/models/schedule_item_model.dart';
import '../../features/calendar/reminders/models/reminder_action.dart';
import '../../features/calendar/reminders/models/reminder_payload.dart';
import '../../features/calendar/reminders/reminder_action_dedupe_store.dart';
import '../../features/calendar/reminders/reminder_overlap_policy.dart';
typedef ReminderNotificationActionHandler =
Future<void> Function({
@@ -38,9 +35,7 @@ class LocalNotificationService {
static const String _actionSnooze = 'snooze10m';
final FlutterLocalNotificationsPlugin _plugin;
final ReminderOverlapPolicy _overlapPolicy;
final ReminderPermissionFallbackTracker? _permissionFallbackTracker;
ReminderActionDedupeStore? _dedupeStore;
bool _initialized = false;
bool _canDeliverSystemNotification = true;
ReminderNotificationActionHandler? _actionHandler;
@@ -50,12 +45,8 @@ class LocalNotificationService {
LocalNotificationService({
FlutterLocalNotificationsPlugin? plugin,
ReminderOverlapPolicy? overlapPolicy,
ReminderActionDedupeStore? dedupeStore,
ReminderPermissionFallbackTracker? permissionFallbackTracker,
}) : _plugin = plugin ?? FlutterLocalNotificationsPlugin(),
_overlapPolicy = overlapPolicy ?? const ReminderOverlapPolicy(),
_dedupeStore = dedupeStore,
_permissionFallbackTracker = permissionFallbackTracker;
void bindActionHandler(ReminderNotificationActionHandler handler) {
@@ -128,19 +119,9 @@ class LocalNotificationService {
>();
await iosImpl?.requestPermissions(alert: true, badge: true, sound: true);
await _ensureDedupeStore();
_initialized = true;
}
Future<void> _ensureDedupeStore() async {
if (_dedupeStore != null) {
return;
}
final prefs = await SharedPreferences.getInstance();
_dedupeStore = ReminderActionDedupeStore(prefs);
}
Future<void> _refreshAndroidNotificationAvailability() async {
if (defaultTargetPlatform != TargetPlatform.android) {
return;
@@ -166,8 +147,9 @@ class LocalNotificationService {
}
final now = DateTime.now();
final fireAt = _overlapPolicy.resolveFirstFireAt(event, now: now);
if (fireAt == null) {
final reminderMinutes = event.metadata?.reminderMinutes ?? 0;
final fireAt = event.startAt.subtract(Duration(minutes: reminderMinutes));
if (fireAt.isBefore(now)) {
await cancelEventReminder(event.id);
return;
}
@@ -225,31 +207,21 @@ class LocalNotificationService {
) async {
await initialize();
await _refreshAndroidNotificationAvailability();
if (!_canDeliverSystemNotification) {
_clearAllInAppFallbackTimers();
final now = DateTime.now();
final groups = _overlapPolicy.groupByMinute(events, now: now);
for (final group in groups) {
if (group.isAggregate) {
await _scheduleInAppAggregateFallback(group.events, group.fireAt);
continue;
}
await _scheduleInAppFallbackRemindersFrom(
event: group.events.first,
firstFireAt: group.fireAt,
for (final event in events) {
if (!_canDeliverSystemNotification) {
final reminderMinutes = event.metadata?.reminderMinutes ?? 0;
final fireAt = event.startAt.subtract(
Duration(minutes: reminderMinutes),
);
}
return;
}
final now = DateTime.now();
final groups = _overlapPolicy.groupByMinute(events, now: now);
for (final group in groups) {
if (group.isAggregate) {
await _scheduleAggregateReminder(group.events, group.fireAt);
if (fireAt.isAfter(DateTime.now())) {
await _scheduleInAppFallbackRemindersFrom(
event: event,
firstFireAt: fireAt,
);
}
continue;
}
await upsertEventReminder(group.events.first);
await upsertEventReminder(event);
}
}
@@ -693,21 +665,6 @@ class LocalNotificationService {
return;
}
final dedupeStore = _dedupeStore;
if (dedupeStore != null) {
final notificationId = response.id?.toString() ?? payload.eventId;
final fireTimeBucket =
payload.fireTimeBucket ??
(payload.startAt.millisecondsSinceEpoch ~/
const Duration(minutes: 1).inMilliseconds);
final actionExecutionId =
'$notificationId|${action.value}|$fireTimeBucket';
final isNew = await dedupeStore.markIfNew(actionExecutionId);
if (!isNew) {
return;
}
}
await handler(action: action, payload: payload);
}
}
@@ -5,8 +5,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../features/calendar/reminders/reminder_cold_start_queue.dart';
typedef ReminderNotificationResponseHandler =
Future<void> Function(NotificationResponse response);
@@ -15,8 +13,6 @@ class ReminderNotificationCallbacks {
'calendar_reminder_pending_notification_responses_v1';
static ReminderNotificationResponseHandler? _responseHandler;
static Future<void> _pendingStorageLock = Future<void>.value();
static final ReminderColdStartQueue _coldStartQueue =
ReminderColdStartQueue();
@visibleForTesting
static Future<void> resetForTest() async {
@@ -106,38 +102,35 @@ class ReminderNotificationCallbacks {
final remaining = <String>[];
for (final raw in pending) {
_coldStartQueue.enqueue(() async {
Map<String, dynamic> parsed;
try {
parsed = Map<String, dynamic>.from(jsonDecode(raw) as Map);
} catch (_) {
return;
}
Map<String, dynamic> parsed;
try {
parsed = Map<String, dynamic>.from(jsonDecode(raw) as Map);
} catch (_) {
continue;
}
final id = parsed['id'] as int?;
final actionId = parsed['actionId'] as String?;
final payload = parsed['payload'] as String?;
final typeIndex = (parsed['type'] as int?) ?? 0;
final input = parsed['input'] as String?;
final type = NotificationResponseType.values[typeIndex.clamp(0, 1)];
final id = parsed['id'] as int?;
final actionId = parsed['actionId'] as String?;
final payload = parsed['payload'] as String?;
final typeIndex = (parsed['type'] as int?) ?? 0;
final input = parsed['input'] as String?;
final type = NotificationResponseType.values[typeIndex.clamp(0, 1)];
try {
await handler(
NotificationResponse(
id: id,
actionId: actionId,
payload: payload,
input: input,
notificationResponseType: type,
),
);
} catch (_) {
remaining.add(raw);
}
});
try {
await handler(
NotificationResponse(
id: id,
actionId: actionId,
payload: payload,
input: input,
notificationResponseType: type,
),
);
} catch (_) {
remaining.add(raw);
}
}
await _coldStartQueue.replay();
if (remaining.isEmpty) {
await prefs.remove(_pendingKey);
return;
@@ -29,8 +29,6 @@ class AuthSessionBootstrapper {
}
try {
await _reminderActionExecutor.replayPendingActions();
final now = DateTime.now();
final start = now.subtract(const Duration(days: 90));
final end = now.add(const Duration(days: 90));
@@ -1,52 +0,0 @@
import 'dart:async';
import 'package:shared_preferences/shared_preferences.dart';
typedef SetStringListFn = Future<bool> Function(String key, List<String> value);
class ReminderActionDedupeStore {
static const String _key = 'calendar_reminder_action_dedupe_v1';
static const int _maxEntries = 512;
final SharedPreferences _prefs;
final SetStringListFn _setStringList;
Future<void> _queue = Future<void>.value();
ReminderActionDedupeStore(
SharedPreferences prefs, {
SetStringListFn? setStringList,
}) : _prefs = prefs,
_setStringList = setStringList ?? prefs.setStringList;
Future<bool> markIfNew(String actionExecutionId) async {
final completer = Completer<bool>();
_queue = _queue
.then((_) async {
completer.complete(await _markIfNewInternal(actionExecutionId));
})
.catchError((_) {
if (!completer.isCompleted) {
completer.complete(false);
}
});
return completer.future;
}
Future<bool> _markIfNewInternal(String actionExecutionId) async {
final current = List<String>.from(
_prefs.getStringList(_key) ?? const <String>[],
);
if (current.contains(actionExecutionId)) {
return false;
}
current.add(actionExecutionId);
if (current.length > _maxEntries) {
current.removeRange(0, current.length - _maxEntries);
}
final saved = await _setStringList(_key, current);
return saved;
}
}
@@ -1,26 +1,17 @@
import 'dart:math';
import '../data/services/calendar_service.dart';
import '../../../core/notifications/local_notification_service.dart';
import 'models/reminder_action.dart';
import 'models/reminder_payload.dart';
import 'reminder_outbox_store.dart';
class ReminderActionExecutor {
final CalendarService _calendarService;
final LocalNotificationService _notificationService;
final ReminderOutboxStore _outboxStore;
final Random _random;
ReminderActionExecutor({
required CalendarService calendarService,
required LocalNotificationService notificationService,
required ReminderOutboxStore outboxStore,
Random? random,
}) : _calendarService = calendarService,
_notificationService = notificationService,
_outboxStore = outboxStore,
_random = random ?? Random();
_notificationService = notificationService;
Future<void> handleAction({
required ReminderAction action,
@@ -35,7 +26,7 @@ class ReminderActionExecutor {
if (action == ReminderAction.archive) {
for (final id in ids) {
await _notificationService.cancelEventReminder(id);
await _archiveEvent(id, ReminderAction.archive);
await _archiveEvent(id);
}
return;
}
@@ -47,21 +38,6 @@ class ReminderActionExecutor {
}
}
Future<void> replayPendingActions() async {
final pending = await _outboxStore.listPending();
for (final item in pending) {
if (item.targetStatus != 'archived') {
continue;
}
try {
await _calendarService.archiveEvent(item.eventId);
await _outboxStore.markDone(item.opId);
} catch (error) {
await _outboxStore.markRetry(item.opId, error.toString());
}
}
}
Future<void> _snoozeEvent(String eventId) async {
final event = await _calendarService.getEventById(eventId);
if (event == null) {
@@ -71,37 +47,21 @@ class ReminderActionExecutor {
final endAt = event.endAt;
if (endAt != null && !now.isBefore(endAt)) {
await _notificationService.cancelEventReminder(eventId);
await _archiveEvent(eventId, ReminderAction.archive);
await _archiveEvent(eventId);
return;
}
final nextAt = now.add(const Duration(minutes: 10));
if (endAt != null && !nextAt.isBefore(endAt)) {
await _notificationService.cancelEventReminder(eventId);
await _archiveEvent(eventId, ReminderAction.archive);
await _archiveEvent(eventId);
return;
}
await _notificationService.scheduleReminderAt(event, nextAt);
}
Future<void> _archiveEvent(String eventId, ReminderAction action) async {
try {
await _calendarService.archiveEvent(eventId);
return;
} catch (_) {
// fall through to enqueue local outbox for retry
}
final opId =
'${DateTime.now().millisecondsSinceEpoch}-${_random.nextInt(1 << 32)}';
final outboxItem = ReminderOutboxItem(
opId: opId,
eventId: eventId,
action: action,
targetStatus: 'archived',
occurredAt: DateTime.now(),
);
await _outboxStore.enqueue(outboxItem);
Future<void> _archiveEvent(String eventId) async {
await _calendarService.archiveEvent(eventId);
}
}
@@ -1,57 +0,0 @@
import 'dart:async';
import 'dart:collection';
typedef ReminderColdStartReplayTask = Future<void> Function();
typedef ReminderColdStartTaskErrorHandler =
void Function(Object error, StackTrace stackTrace);
class ReminderColdStartQueue {
final Queue<ReminderColdStartReplayTask> _tasks =
Queue<ReminderColdStartReplayTask>();
final ReminderColdStartTaskErrorHandler? _onTaskError;
Future<void>? _inFlightReplay;
ReminderColdStartQueue({ReminderColdStartTaskErrorHandler? onTaskError})
: _onTaskError = onTaskError;
void enqueue(ReminderColdStartReplayTask task) {
_tasks.add(task);
}
Future<void> replay() {
final inFlightReplay = _inFlightReplay;
if (inFlightReplay != null) {
return inFlightReplay;
}
final replayCompleter = Completer<void>();
final replayFuture = replayCompleter.future;
_inFlightReplay = replayFuture;
scheduleMicrotask(() async {
try {
await _replayInternal();
replayCompleter.complete();
} catch (error, stackTrace) {
replayCompleter.completeError(error, stackTrace);
} finally {
if (identical(_inFlightReplay, replayFuture)) {
_inFlightReplay = null;
}
}
});
return replayFuture;
}
Future<void> _replayInternal() async {
while (_tasks.isNotEmpty) {
final task = _tasks.removeFirst();
try {
await task();
} catch (error, stackTrace) {
_onTaskError?.call(error, stackTrace);
}
}
}
}
@@ -1,202 +0,0 @@
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import 'models/reminder_action.dart';
class ReminderOutboxItem {
final String opId;
final String eventId;
final ReminderAction action;
final String? targetStatus;
final DateTime occurredAt;
final int retryCount;
final DateTime? nextRetryAt;
final ReminderOutboxState state;
final String? lastError;
const ReminderOutboxItem({
required this.opId,
required this.eventId,
required this.action,
required this.occurredAt,
this.targetStatus,
this.retryCount = 0,
this.nextRetryAt,
this.state = ReminderOutboxState.pending,
this.lastError,
});
String get idempotencyBucket {
final bucket =
occurredAt.millisecondsSinceEpoch ~/
const Duration(minutes: 1).inMilliseconds;
return '$eventId|${action.value}|$bucket';
}
ReminderOutboxItem copyWith({
int? retryCount,
DateTime? nextRetryAt,
ReminderOutboxState? state,
String? lastError,
}) {
return ReminderOutboxItem(
opId: opId,
eventId: eventId,
action: action,
targetStatus: targetStatus,
occurredAt: occurredAt,
retryCount: retryCount ?? this.retryCount,
nextRetryAt: nextRetryAt ?? this.nextRetryAt,
state: state ?? this.state,
lastError: lastError ?? this.lastError,
);
}
Map<String, dynamic> toJson() {
return {
'opId': opId,
'eventId': eventId,
'action': action.value,
'targetStatus': targetStatus,
'occurredAt': occurredAt.toIso8601String(),
'retryCount': retryCount,
'nextRetryAt': nextRetryAt?.toIso8601String(),
'state': state.value,
'lastError': lastError,
};
}
factory ReminderOutboxItem.fromJson(Map<String, dynamic> json) {
return ReminderOutboxItem(
opId: (json['opId'] as String?) ?? '',
eventId: (json['eventId'] as String?) ?? '',
action: ReminderAction.fromValue(
(json['action'] as String?) ?? 'timeout_30s',
),
targetStatus: json['targetStatus'] as String?,
occurredAt: DateTime.parse(json['occurredAt'] as String),
retryCount: (json['retryCount'] as int?) ?? 0,
nextRetryAt: json['nextRetryAt'] != null
? DateTime.parse(json['nextRetryAt'] as String)
: null,
state: ReminderOutboxState.fromValue(
(json['state'] as String?) ?? 'pending',
),
lastError: json['lastError'] as String?,
);
}
}
enum ReminderOutboxState {
pending('pending'),
done('done'),
dead('dead');
const ReminderOutboxState(this.value);
final String value;
static ReminderOutboxState fromValue(String raw) {
return ReminderOutboxState.values.firstWhere(
(item) => item.value == raw,
orElse: () => ReminderOutboxState.pending,
);
}
}
class ReminderOutboxStore {
static const String _key = 'calendar_reminder_outbox_v1';
final SharedPreferences _prefs;
ReminderOutboxStore(this._prefs);
Future<void> enqueue(ReminderOutboxItem item) async {
final current = await _readAll();
final duplicated = current.any(
(existing) =>
existing.state == ReminderOutboxState.pending &&
existing.idempotencyBucket == item.idempotencyBucket,
);
if (duplicated) {
return;
}
current.add(item);
await _writeAll(current);
}
Future<List<ReminderOutboxItem>> listPending() async {
final all = await _readAll();
final now = DateTime.now();
return all
.where((item) => item.state == ReminderOutboxState.pending)
.where(
(item) => item.nextRetryAt == null || !item.nextRetryAt!.isAfter(now),
)
.toList();
}
Future<void> markDone(String opId) async {
final all = await _readAll();
final updated = all
.map(
(item) => item.opId == opId
? item.copyWith(
state: ReminderOutboxState.done,
nextRetryAt: null,
)
: item,
)
.toList();
await _writeAll(updated);
}
Future<void> markRetry(String opId, String error) async {
final all = await _readAll();
final updated = all.map((item) {
if (item.opId != opId) {
return item;
}
final nextRetryCount = item.retryCount + 1;
if (nextRetryCount >= 8) {
return item.copyWith(
retryCount: nextRetryCount,
state: ReminderOutboxState.dead,
lastError: error,
nextRetryAt: null,
);
}
final delayMinutes = nextRetryCount == 1 ? 0 : 1 << (nextRetryCount - 1);
return item.copyWith(
retryCount: nextRetryCount,
lastError: error,
nextRetryAt: DateTime.now().add(Duration(minutes: delayMinutes)),
);
}).toList();
await _writeAll(updated);
}
Future<List<ReminderOutboxItem>> _readAll() async {
try {
final raw = _prefs.getString(_key);
if (raw == null || raw.isEmpty) {
return [];
}
final list = jsonDecode(raw) as List<dynamic>;
return list
.whereType<Map>()
.map(
(item) =>
ReminderOutboxItem.fromJson(Map<String, dynamic>.from(item)),
)
.toList();
} catch (_) {
await _prefs.remove(_key);
return [];
}
}
Future<void> _writeAll(List<ReminderOutboxItem> items) async {
final raw = jsonEncode(items.map((item) => item.toJson()).toList());
await _prefs.setString(_key, raw);
}
}
@@ -1,80 +0,0 @@
import '../data/models/schedule_item_model.dart';
class ReminderOverlapGroup {
final DateTime fireAt;
final List<ScheduleItemModel> events;
const ReminderOverlapGroup({required this.fireAt, required this.events});
bool get isAggregate => events.length > 1;
}
class ReminderOverlapPolicy {
const ReminderOverlapPolicy();
List<ReminderOverlapGroup> groupByMinute(
Iterable<ScheduleItemModel> events, {
required DateTime now,
}) {
final buckets = <String, List<ScheduleItemModel>>{};
final minuteToFireAt = <String, DateTime>{};
for (final event in events) {
final fireAt = resolveFirstFireAt(event, now: now);
if (fireAt == null) {
continue;
}
final minute = DateTime(
fireAt.year,
fireAt.month,
fireAt.day,
fireAt.hour,
fireAt.minute,
);
final key = minute.toIso8601String();
buckets.putIfAbsent(key, () => <ScheduleItemModel>[]).add(event);
minuteToFireAt[key] = minuteToFireAt[key] ?? fireAt;
}
final groups = buckets.entries
.map(
(entry) => ReminderOverlapGroup(
fireAt: minuteToFireAt[entry.key]!,
events: entry.value,
),
)
.toList();
groups.sort((left, right) => left.fireAt.compareTo(right.fireAt));
return groups;
}
DateTime? resolveFirstFireAt(
ScheduleItemModel event, {
required DateTime now,
}) {
if (event.status != ScheduleStatus.active) {
return null;
}
final reminderMinutes = event.metadata?.reminderMinutes;
if (reminderMinutes == null) {
return null;
}
final remindAt = event.startAt.subtract(Duration(minutes: reminderMinutes));
final endAt = event.endAt;
if (endAt != null && !now.isBefore(endAt)) {
return null;
}
if (now.isBefore(remindAt)) {
return remindAt;
}
if (endAt != null && now.isBefore(endAt)) {
return now.add(const Duration(seconds: 5));
}
return null;
}
}
@@ -1,73 +0,0 @@
import 'package:flutter/material.dart';
import '../../../../core/theme/design_tokens.dart';
import '../models/reminder_action.dart';
import '../models/reminder_payload.dart';
import '../reminder_action_executor.dart';
import 'reminder_presentation_coordinator.dart';
import 'widgets/reminder_action_sheet.dart';
class ReminderForegroundPresenter {
final GlobalKey<NavigatorState> _navigatorKey;
final ReminderActionExecutor _executor;
final ReminderPresentationCoordinator _coordinator;
bool _isPresenting = false;
ReminderForegroundPresenter({
required GlobalKey<NavigatorState> navigatorKey,
required ReminderActionExecutor executor,
ReminderPresentationCoordinator? coordinator,
}) : _navigatorKey = navigatorKey,
_executor = executor,
_coordinator = coordinator ?? ReminderPresentationCoordinator();
Future<void> present(ReminderPayload payload) async {
final context = _navigatorKey.currentContext;
if (context == null) {
return;
}
final lifecycleState = WidgetsBinding.instance.lifecycleState;
final isAppActive = lifecycleState == AppLifecycleState.resumed;
final shouldPresent = _coordinator.shouldPresent(
eventId: payload.eventId,
isAppActive: isAppActive,
);
if (!shouldPresent || _isPresenting) {
return;
}
_isPresenting = true;
try {
final action = await showModalBottomSheet<ReminderAction>(
context: context,
useRootNavigator: true,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (sheetContext) {
return SafeArea(
child: Padding(
padding: const EdgeInsets.all(AppSpacing.md),
child: ReminderActionSheet(
onSnooze: () {
Navigator.of(sheetContext).pop(ReminderAction.snooze10m);
},
onArchive: () {
Navigator.of(sheetContext).pop(ReminderAction.archive);
},
),
),
);
},
);
if (action == null) {
return;
}
await _executor.handleAction(action: action, payload: payload);
} finally {
_isPresenting = false;
}
}
}
@@ -1,29 +0,0 @@
typedef ReminderPresentationNow = DateTime Function();
class ReminderPresentationCoordinator {
final Duration _dedupeWindow;
final ReminderPresentationNow _now;
final Map<String, DateTime> _lastPresentedAtByEventId = <String, DateTime>{};
ReminderPresentationCoordinator({
Duration dedupeWindow = const Duration(seconds: 30),
ReminderPresentationNow? now,
}) : _dedupeWindow = dedupeWindow,
_now = now ?? DateTime.now;
bool shouldPresent({required String eventId, required bool isAppActive}) {
if (!isAppActive) {
return false;
}
final currentTime = _now();
final lastPresentedAt = _lastPresentedAtByEventId[eventId];
if (lastPresentedAt != null &&
currentTime.difference(lastPresentedAt) < _dedupeWindow) {
return false;
}
_lastPresentedAtByEventId[eventId] = currentTime;
return true;
}
}
@@ -1,58 +0,0 @@
import 'package:flutter/material.dart';
import '../../../../../core/theme/design_tokens.dart';
import '../../../../../shared/widgets/app_button.dart';
class ReminderActionSheet extends StatelessWidget {
const ReminderActionSheet({
super.key,
required this.onSnooze,
required this.onArchive,
});
final VoidCallback onSnooze;
final VoidCallback onArchive;
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
padding: const EdgeInsets.all(AppSpacing.lg),
decoration: BoxDecoration(
color: AppColors.white,
borderRadius: BorderRadius.circular(AppRadius.xl),
border: Border.all(color: AppColors.borderSecondary),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
'提醒操作',
textAlign: TextAlign.center,
style: Theme.of(
context,
).textTheme.titleMedium?.copyWith(color: AppColors.slate900),
),
const SizedBox(height: AppSpacing.lg),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: AppButton(
text: '稍后提醒',
isOutlined: true,
onPressed: onSnooze,
),
),
const SizedBox(width: AppSpacing.md),
Expanded(
child: AppButton(text: '归档', onPressed: onArchive),
),
],
),
],
),
);
}
}
-8
View File
@@ -17,7 +17,6 @@ import 'features/auth/presentation/bloc/auth_state.dart';
import 'features/calendar/data/services/calendar_service.dart';
import 'features/calendar/data/services/calendar_repository.dart';
import 'features/calendar/reminders/reminder_action_executor.dart';
import 'features/calendar/reminders/ui/reminder_foreground_presenter.dart';
import 'features/calendar/ui/calendar_state_manager.dart';
import 'features/chat/presentation/bloc/chat_bloc.dart';
import 'features/settings/data/services/settings_user_cache.dart';
@@ -28,10 +27,6 @@ void main() async {
await configureDependencies();
await AppConstants.init();
final rootNavigatorKey = GlobalKey<NavigatorState>();
final reminderForegroundPresenter = ReminderForegroundPresenter(
navigatorKey: rootNavigatorKey,
executor: sl<ReminderActionExecutor>(),
);
sl<LocalNotificationService>().bindActionHandler(({
required action,
required payload,
@@ -41,9 +36,6 @@ void main() async {
payload: payload,
);
});
sl<LocalNotificationService>().bindInAppReminderHandler(
reminderForegroundPresenter.present,
);
await sl<LocalNotificationService>().initialize();
final authBloc = sl<AuthBloc>();