83 lines
2.9 KiB
Dart
83 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:shadcn_ui/shadcn_ui.dart';
|
|
|
|
/// A short in-app explanation displayed immediately before the system prompt.
|
|
class NotificationPermissionTip extends StatelessWidget {
|
|
const NotificationPermissionTip({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colors = ShadTheme.of(context).colorScheme;
|
|
return IgnorePointer(
|
|
child: Align(
|
|
alignment: Alignment.topCenter,
|
|
child: Material(
|
|
type: MaterialType.transparency,
|
|
child: SafeArea(
|
|
bottom: false,
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
|
child: Container(
|
|
padding: const EdgeInsets.fromLTRB(16, 14, 12, 14),
|
|
decoration: BoxDecoration(
|
|
color: colors.foreground,
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: const [
|
|
BoxShadow(
|
|
color: Color(0x33000000),
|
|
blurRadius: 16,
|
|
offset: Offset(0, 6),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
Icons.notifications_outlined,
|
|
size: 20,
|
|
color: colors.background,
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'通知权限使用说明',
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: colors.background,
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
'用于向你传递重要服务提醒。',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: colors.background,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
Future<void> showNotificationPermissionTip(BuildContext context) async {
|
|
final overlay = Overlay.of(context, rootOverlay: true);
|
|
final entry = OverlayEntry(builder: (_) => const NotificationPermissionTip());
|
|
overlay.insert(entry);
|
|
await Future<void>.delayed(const Duration(milliseconds: 500));
|
|
entry.remove();
|
|
}
|