@@ -33,81 +33,134 @@ import '../../../settings_view_widgets/update_firebase_token_dialog.dart';
3333
3434class SettingsGroupPushTokenDialog extends ConsumerWidget {
3535 final List <PushToken > unsupportedPushTokens;
36- const SettingsGroupPushTokenDialog ({super .key, required this .unsupportedPushTokens});
36+ const SettingsGroupPushTokenDialog ({
37+ super .key,
38+ required this .unsupportedPushTokens,
39+ });
3740
3841 @override
3942 Widget build (BuildContext context, WidgetRef ref) {
40- final settingsState = ref.watch (settingsProvider).whenOrNull (data: (data) => data);
41- final needsFirebaseMessaging = ref.watch (tokenProvider).value? .pushTokensNotPollOnly.isNotEmpty ?? false ;
43+ final settingsState = ref
44+ .watch (settingsProvider)
45+ .whenOrNull (data: (data) => data);
46+ final needsFirebaseMessaging =
47+ ref.watch (tokenProvider).value? .pushTokensNotPollOnly.isNotEmpty ??
48+ false ;
4249 return DefaultDialog (
4350 title: Text (AppLocalizations .of (context)! .pushToken),
4451 content: Column (
4552 mainAxisSize: MainAxisSize .min,
4653 children: [
4754 if (deviceHasFirebaseMessaging && needsFirebaseMessaging)
4855 ListTile (
49- title: Text (AppLocalizations .of (context)! .synchronizePushTokens, style: Theme .of (context).textTheme.bodyMedium),
50- subtitle: Text (AppLocalizations .of (context)! .synchronizesTokensWithServer, overflow: TextOverflow .fade),
56+ title: Text (
57+ AppLocalizations .of (context)! .synchronizePushTokens,
58+ style: Theme .of (context).textTheme.bodyMedium,
59+ ),
60+ subtitle: Text (
61+ AppLocalizations .of (context)! .synchronizesTokensWithServer,
62+ overflow: TextOverflow .fade,
63+ ),
5164 trailing: ElevatedButton (
5265 onPressed: () => showDialog (
5366 useRootNavigator: false ,
5467 context: context,
5568 barrierDismissible: false ,
56- builder: (context) => UpdateFirebaseTokenDialog (AppLocalizations .of (context)! ),
69+ builder: (context) =>
70+ UpdateFirebaseTokenDialog (AppLocalizations .of (context)! ),
71+ ),
72+ child: Text (
73+ AppLocalizations .of (context)! .sync ,
74+ overflow: TextOverflow .fade,
75+ softWrap: false ,
5776 ),
58- child: Text (AppLocalizations .of (context)! .sync , overflow: TextOverflow .fade, softWrap: false ),
5977 ),
6078 ),
6179 ListTile (
6280 title: RichText (
6381 text: TextSpan (
6482 children: [
65- TextSpan (text: AppLocalizations .of (context)! .enablePolling, style: Theme .of (context).textTheme.bodyMedium),
83+ TextSpan (
84+ text: AppLocalizations .of (context)! .enablePolling,
85+ style: Theme .of (context).textTheme.bodyMedium,
86+ ),
6687 // Add clickable icon to inform user of unsupported push tokens (for polling)
6788 WidgetSpan (
6889 child: Padding (
6990 padding: const EdgeInsets .only (left: 10 ),
7091 child: unsupportedPushTokens.isNotEmpty
7192 ? GestureDetector (
72- onTap: () => _showPollingInfo (context, unsupportedPushTokens),
73- child: const Icon (Icons .info_outline, color: Colors .red),
93+ onTap: () => _showPollingInfo (
94+ context,
95+ unsupportedPushTokens,
96+ ),
97+ child: const Icon (
98+ Icons .info_outline,
99+ color: Colors .red,
100+ ),
74101 )
75102 : null ,
76103 ),
77104 ),
78105 ],
79106 ),
80107 ),
81- subtitle: Text (AppLocalizations .of (context)! .requestPushChallengesPeriodically, overflow: TextOverflow .fade),
108+ subtitle: Text (
109+ AppLocalizations .of (context)! .requestPushChallengesPeriodically,
110+ overflow: TextOverflow .fade,
111+ ),
82112 trailing: Switch (
83- value: settingsState? .enablePolling ?? SettingsState .enablePollingDefault,
84- onChanged: (value) => ref.read (settingsProvider.notifier).setPolling (value),
113+ value:
114+ settingsState? .enablePolling ??
115+ SettingsState .enablePollingDefault,
116+ onChanged: (value) =>
117+ ref.read (settingsProvider.notifier).setPolling (value),
85118 ),
86119 ),
87120 ListTile (
88121 title: RichText (
89122 text: TextSpan (
90- children: [TextSpan (text: AppLocalizations .of (context)! .hidePushTokens, style: Theme .of (context).textTheme.bodyMedium)],
123+ children: [
124+ TextSpan (
125+ text: AppLocalizations .of (context)! .hidePushTokens,
126+ style: Theme .of (context).textTheme.bodyMedium,
127+ ),
128+ ],
91129 ),
92130 ),
93- subtitle: Text (AppLocalizations .of (context)! .hidePushTokensDescription, overflow: TextOverflow .fade),
131+ subtitle: Text (
132+ AppLocalizations .of (context)! .hidePushTokensDescription,
133+ overflow: TextOverflow .fade,
134+ ),
94135 trailing: Switch (
95- value: settingsState? .hidePushTokens ?? SettingsState .hidePushTokensDefault,
96- onChanged: (value) => ref.read (settingsProvider.notifier).setHidePushTokens (value),
136+ value:
137+ settingsState? .hidePushTokens ??
138+ SettingsState .hidePushTokensDefault,
139+ onChanged: (value) =>
140+ ref.read (settingsProvider.notifier).setHidePushTokens (value),
97141 ),
98142 ),
99143 if (Platform .isAndroid)
100144 ListTile (
101- title: Text (AppLocalizations .of (context)! .autoCloseAppAfterAcceptingPushRequestTitle, style: Theme .of (context).textTheme.bodyMedium),
102- subtitle: Text (AppLocalizations .of (context)! .autoCloseAppAfterAcceptingPushRequestDescription, overflow: TextOverflow .fade),
145+ title: Text (
146+ AppLocalizations .of (
147+ context,
148+ )! .autoCloseAppAfterAcceptingPushRequestTitle,
149+ style: Theme .of (context).textTheme.bodyMedium,
150+ ),
151+ subtitle: Text (
152+ AppLocalizations .of (
153+ context,
154+ )! .autoCloseAppAfterAcceptingPushRequestDescription,
155+ overflow: TextOverflow .fade,
156+ ),
103157 trailing: Switch (
104- value: ref.watch (settingsProvider).value? .autoCloseAppAfterAcceptingPushRequest ?? false ,
105- onChanged: (value) async {
106- final currentSettings = ref.read (settingsProvider).value;
107- if (currentSettings != null ) {
108- (await ref.read (settingsProvider.notifier).setAutoCloseAppAfterAcceptingPushRequest (value));
109- }
110- },
158+ value:
159+ settingsState? .autoCloseAppAfterAcceptingPushRequest ??
160+ false ,
161+ onChanged: (value) => ref
162+ .read (settingsProvider.notifier)
163+ .setAutoCloseAppAfterAcceptingPushRequest (value),
111164 ),
112165 ),
113166 ],
@@ -117,27 +170,34 @@ class SettingsGroupPushTokenDialog extends ConsumerWidget {
117170
118171 /// Shows a dialog to the user that displays all push tokens that do not
119172 /// support polling.
120- void _showPollingInfo (BuildContext context, List <PushToken > unsupported) => showDialog (
121- useRootNavigator: false ,
122- context: context,
123- builder: (BuildContext context) {
124- return AlertDialog (
125- title: Text ('${AppLocalizations .of (context )!.someTokensDoNotSupportPolling }:' ),
126- content: Scrollbar (
127- child: ListView .separated (
128- shrinkWrap: true ,
129- itemCount: unsupported.length,
130- itemBuilder: (context, index) => Text (unsupported[index].label.toString ()),
131- separatorBuilder: (context, index) => const Divider (),
132- ),
133- ),
134- actions: < Widget > [
135- TextButton (
136- child: Text (AppLocalizations .of (context)! .dismiss, style: Theme .of (context).textTheme.titleMedium),
137- onPressed: () => Navigator .of (context).pop (),
138- ),
139- ],
173+ void _showPollingInfo (BuildContext context, List <PushToken > unsupported) =>
174+ showDialog (
175+ useRootNavigator: false ,
176+ context: context,
177+ builder: (BuildContext context) {
178+ return AlertDialog (
179+ title: Text (
180+ '${AppLocalizations .of (context )!.someTokensDoNotSupportPolling }:' ,
181+ ),
182+ content: Scrollbar (
183+ child: ListView .separated (
184+ shrinkWrap: true ,
185+ itemCount: unsupported.length,
186+ itemBuilder: (context, index) =>
187+ Text (unsupported[index].label.toString ()),
188+ separatorBuilder: (context, index) => const Divider (),
189+ ),
190+ ),
191+ actions: < Widget > [
192+ TextButton (
193+ child: Text (
194+ AppLocalizations .of (context)! .dismiss,
195+ style: Theme .of (context).textTheme.titleMedium,
196+ ),
197+ onPressed: () => Navigator .of (context).pop (),
198+ ),
199+ ],
200+ );
201+ },
140202 );
141- },
142- );
143203}
0 commit comments