1- import 'package:flutter/foundation.dart' ;
21import 'package:flutter/material.dart' ;
32
43import '../../l10n/app_localizations.dart' ;
54import '../../models/app_notification.dart' ;
5+ import '../../models/settings_service.dart' ;
66import '../../services/app_notification_service.dart' ;
77
88class NotificationTestScreen extends StatelessWidget {
@@ -50,40 +50,49 @@ class NotificationTestScreen extends StatelessWidget {
5050 ),
5151 ];
5252
53- return Scaffold (
54- appBar: AppBar (title: Text (l10n.debugNotificationTester)),
55- body: ListView .separated (
56- padding: const EdgeInsets .symmetric (vertical: 8 ),
57- itemCount: samples.length,
58- separatorBuilder: (_, _) => const Divider (height: 1 ),
59- itemBuilder: (context, index) {
60- final sample = samples[index];
61- return ListTile (
62- contentPadding: const EdgeInsets .symmetric (
63- horizontal: 24 ,
64- vertical: 8 ,
65- ),
66- leading: CircleAvatar (child: Icon (sample.icon)),
67- title: Text (sample.title),
68- subtitle: Text (l10n.debugNotificationTestBody),
69- trailing: Row (
70- mainAxisSize: MainAxisSize .min,
71- children: [
72- IconButton .filledTonal (
73- icon: const Icon (Icons .web_asset_outlined),
74- tooltip: l10n.debugNotificationTestInApp,
75- onPressed: () => _showInApp (context, sample),
76- ),
77- const SizedBox (width: 8 ),
78- IconButton .filledTonal (
79- icon: const Icon (Icons .desktop_windows_outlined),
80- tooltip: l10n.debugNotificationTestSystem,
81- onPressed: kIsWeb ? null : () => _showSystem (context, sample),
82- ),
83- ],
84- ),
85- );
86- },
53+ return ListenableBuilder (
54+ listenable: SettingsService .instance,
55+ builder: (context, _) => Scaffold (
56+ appBar: AppBar (title: Text (l10n.debugNotificationTester)),
57+ body: ListView .separated (
58+ padding: const EdgeInsets .symmetric (vertical: 8 ),
59+ itemCount: samples.length,
60+ separatorBuilder: (_, _) => const Divider (height: 1 ),
61+ itemBuilder: (context, index) {
62+ final sample = samples[index];
63+ final notification = _notification (context, sample);
64+ final service = AppNotificationService .instance;
65+ return ListTile (
66+ contentPadding: const EdgeInsets .symmetric (
67+ horizontal: 24 ,
68+ vertical: 8 ,
69+ ),
70+ leading: CircleAvatar (child: Icon (sample.icon)),
71+ title: Text (sample.title),
72+ subtitle: Text (l10n.debugNotificationTestBody),
73+ trailing: Row (
74+ mainAxisSize: MainAxisSize .min,
75+ children: [
76+ IconButton .filledTonal (
77+ icon: const Icon (Icons .web_asset_outlined),
78+ tooltip: l10n.debugNotificationTestInApp,
79+ onPressed: service.canShowInApp (notification)
80+ ? () => service.showInAppTest (notification)
81+ : null ,
82+ ),
83+ const SizedBox (width: 8 ),
84+ IconButton .filledTonal (
85+ icon: const Icon (Icons .desktop_windows_outlined),
86+ tooltip: l10n.debugNotificationTestSystem,
87+ onPressed: service.canShowSystem (notification)
88+ ? () => _showSystem (context, notification)
89+ : null ,
90+ ),
91+ ],
92+ ),
93+ );
94+ },
95+ ),
8796 ),
8897 );
8998 }
@@ -102,18 +111,12 @@ class NotificationTestScreen extends StatelessWidget {
102111 );
103112 }
104113
105- void _showInApp (BuildContext context, _NotificationSample sample) {
106- AppNotificationService .instance.showInAppTest (
107- _notification (context, sample),
108- );
109- }
110-
111114 Future <void > _showSystem (
112115 BuildContext context,
113- _NotificationSample sample ,
116+ AppNotification notification ,
114117 ) async {
115118 final shown = await AppNotificationService .instance.showSystemTest (
116- _notification (context, sample) ,
119+ notification ,
117120 );
118121 if (! context.mounted || shown) return ;
119122 ScaffoldMessenger .of (context).showSnackBar (
0 commit comments