d17f5d78aa
- Remove permission fallback logic from LocalNotificationService - Remove unused methods: _scheduleInApp*, _trackFallback, bindInAppReminderHandler - Remove unused fields: _permissionFallbackTracker, _inAppReminderHandler, _inAppFallbackTimersByEventId, _canDeliverSystemNotification - Remove unused _showSnoozeOptions from ReminderOverlay - Remove unused reminderActionExecutor from AuthSessionBootstrapper - Remove obsolete test files: reminder_permission_fallback_test, reminder_notification_bridge_test, auth_session_bootstrapper_test - Add native notification grouping (threadIdentifier/groupKey)
185 lines
5.0 KiB
Dart
185 lines
5.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import '../../../../core/theme/design_tokens.dart';
|
|
import '../../../../shared/widgets/app_button.dart';
|
|
import '../../reminders/reminder_queue_manager.dart';
|
|
import '../../reminders/models/reminder_payload.dart';
|
|
|
|
class ReminderOverlay extends StatefulWidget {
|
|
const ReminderOverlay({
|
|
super.key,
|
|
required this.queueManager,
|
|
required this.onComplete,
|
|
required this.onSnooze,
|
|
required this.onArchive,
|
|
});
|
|
|
|
final ReminderQueueManager queueManager;
|
|
final VoidCallback onComplete;
|
|
final void Function(int minutes) onSnooze;
|
|
final VoidCallback onArchive;
|
|
|
|
@override
|
|
State<ReminderOverlay> createState() => _ReminderOverlayState();
|
|
}
|
|
|
|
class _ReminderOverlayState extends State<ReminderOverlay> {
|
|
OverlayEntry? _overlayEntry;
|
|
|
|
ReminderPayload? get _currentPayload => widget.queueManager.currentPayload;
|
|
|
|
@override
|
|
void dispose() {
|
|
_hideSnoozeOptions();
|
|
super.dispose();
|
|
}
|
|
|
|
void _hideSnoozeOptions() {
|
|
_overlayEntry?.remove();
|
|
_overlayEntry = null;
|
|
}
|
|
|
|
void _showSnoozeDropdown() {
|
|
_hideSnoozeOptions();
|
|
|
|
final box = context.findRenderObject() as RenderBox?;
|
|
if (box == null) return;
|
|
|
|
final button = box.localToGlobal(Offset.zero);
|
|
|
|
_overlayEntry = OverlayEntry(
|
|
builder: (context) => Positioned(
|
|
left: button.dx,
|
|
top: button.dy + box.size.height + 4,
|
|
width: 120,
|
|
child: Material(
|
|
elevation: 4,
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: AppColors.white,
|
|
borderRadius: BorderRadius.circular(8),
|
|
border: Border.all(color: AppColors.borderSecondary),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
_SnoozeOption(
|
|
label: '5 分钟',
|
|
onTap: () {
|
|
_hideSnoozeOptions();
|
|
_handleSnooze(5);
|
|
},
|
|
),
|
|
const Divider(height: 1, color: AppColors.borderSecondary),
|
|
_SnoozeOption(
|
|
label: '15 分钟',
|
|
onTap: () {
|
|
_hideSnoozeOptions();
|
|
_handleSnooze(15);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
Overlay.of(context).insert(_overlayEntry!);
|
|
}
|
|
|
|
void _handleComplete() {
|
|
widget.onArchive();
|
|
widget.queueManager.dequeueCurrent();
|
|
widget.onComplete();
|
|
}
|
|
|
|
void _handleSnooze(int minutes) {
|
|
widget.onSnooze(minutes);
|
|
widget.queueManager.dequeueCurrent();
|
|
widget.onComplete();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final payload = _currentPayload;
|
|
if (payload == null) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
|
|
return Container(
|
|
color: AppColors.white,
|
|
child: SafeArea(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(AppSpacing.lg),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Text(
|
|
payload.title,
|
|
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
|
color: AppColors.slate900,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: AppSpacing.sm),
|
|
Text(
|
|
DateFormat('HH:mm').format(DateTime.now()),
|
|
style: Theme.of(
|
|
context,
|
|
).textTheme.titleLarge?.copyWith(color: AppColors.slate500),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: AppSpacing.xl),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: AppButton(
|
|
text: '稍后提醒',
|
|
isOutlined: true,
|
|
onPressed: _showSnoozeDropdown,
|
|
),
|
|
),
|
|
const SizedBox(width: AppSpacing.md),
|
|
Expanded(
|
|
child: AppButton(text: '完成', onPressed: _handleComplete),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _SnoozeOption extends StatelessWidget {
|
|
const _SnoozeOption({required this.label, required this.onTap});
|
|
|
|
final String label;
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
onTap: onTap,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.md,
|
|
vertical: AppSpacing.sm,
|
|
),
|
|
child: Text(
|
|
label,
|
|
style: Theme.of(
|
|
context,
|
|
).textTheme.bodyMedium?.copyWith(color: AppColors.slate900),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|