A bit of notification turn on reminder

This commit is contained in:
2026-03-01 05:45:23 +08:00
parent ec46c33c35
commit e91e7b43d2
9 changed files with 190 additions and 14 deletions
@@ -1,6 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:permission_handler/permission_handler.dart';
import '../../services/notification_service.dart';
import '../../providers/notifications_provider.dart';
import '../../providers/profile_provider.dart';
@@ -10,11 +13,34 @@ import '../../widgets/mono_text.dart';
import '../../widgets/responsive_body.dart';
import '../../theme/app_surfaces.dart';
class NotificationsScreen extends ConsumerWidget {
class NotificationsScreen extends ConsumerStatefulWidget {
const NotificationsScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
ConsumerState<NotificationsScreen> createState() =>
_NotificationsScreenState();
}
class _NotificationsScreenState extends ConsumerState<NotificationsScreen> {
bool _showBanner = false;
bool _dismissed = false;
@override
void initState() {
super.initState();
_checkChannel();
}
Future<void> _checkChannel() async {
final muted = await NotificationService.isHighPriorityChannelMuted();
if (!mounted) return;
if (muted) {
setState(() => _showBanner = true);
}
}
@override
Widget build(BuildContext context) {
final notificationsAsync = ref.watch(notificationsProvider);
final profilesAsync = ref.watch(profilesProvider);
final ticketsAsync = ref.watch(ticketsProvider);
@@ -49,6 +75,29 @@ class NotificationsScreen extends ConsumerWidget {
).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.w700),
),
),
if (_showBanner && !_dismissed)
Padding(
padding: const EdgeInsets.only(bottom: 12),
child: MaterialBanner(
content: const Text(
'Push notifications are currently silenced. Tap here to fix.',
),
actions: [
TextButton(
onPressed: () {
openAppSettings();
},
child: const Text('Open settings'),
),
TextButton(
onPressed: () {
setState(() => _dismissed = true);
},
child: const Text('Dismiss'),
),
],
),
),
Expanded(
child: ListView.separated(
padding: const EdgeInsets.only(bottom: 24),