Browse Source

fix(neon): Hide useless push notifications popups

pull/509/head
jld3103 1 year ago
parent
commit
efc8f59c10
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 35
      packages/neon/neon/lib/src/utils/global_popups.dart

35
packages/neon/neon/lib/src/utils/global_popups.dart

@ -4,6 +4,7 @@ import 'package:neon/l10n/localizations.dart';
import 'package:neon/src/blocs/first_launch.dart'; import 'package:neon/src/blocs/first_launch.dart';
import 'package:neon/src/blocs/next_push.dart'; import 'package:neon/src/blocs/next_push.dart';
import 'package:neon/src/pages/settings.dart'; import 'package:neon/src/pages/settings.dart';
import 'package:neon/src/platform/platform.dart';
import 'package:neon/src/router.dart'; import 'package:neon/src/router.dart';
import 'package:neon/src/utils/global_options.dart'; import 'package:neon/src/utils/global_options.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -31,27 +32,31 @@ class GlobalPopups {
final globalOptions = Provider.of<GlobalOptions>(context, listen: false); final globalOptions = Provider.of<GlobalOptions>(context, listen: false);
final firstLaunchBloc = Provider.of<FirstLaunchBloc>(context, listen: false); final firstLaunchBloc = Provider.of<FirstLaunchBloc>(context, listen: false);
final nextPushBloc = Provider.of<NextPushBloc>(context, listen: false); final nextPushBloc = Provider.of<NextPushBloc>(context, listen: false);
final platform = Provider.of<NeonPlatform>(context, listen: false);
firstLaunchBloc.onFirstLaunch.listen((final _) { firstLaunchBloc.onFirstLaunch.listen((final _) {
if (globalOptions.pushNotificationsEnabled.enabled) { if (!platform.canUsePushNotifications || !globalOptions.pushNotificationsEnabled.enabled) {
if (!context.mounted) { return;
return;
}
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(AppLocalizations.of(context).firstLaunchGoToSettingsToEnablePushNotifications),
action: SnackBarAction(
label: AppLocalizations.of(context).settings,
onPressed: () {
const SettingsRoute(initialCategory: SettingsCageories.pushNotifications).go(context);
},
),
),
);
} }
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(AppLocalizations.of(context).firstLaunchGoToSettingsToEnablePushNotifications),
action: SnackBarAction(
label: AppLocalizations.of(context).settings,
onPressed: () {
const SettingsRoute(initialCategory: SettingsCageories.pushNotifications).go(context);
},
),
),
);
}); });
nextPushBloc.onNextPushSupported.listen((final _) async { nextPushBloc.onNextPushSupported.listen((final _) async {
if (!platform.canUsePushNotifications || !globalOptions.pushNotificationsEnabled.enabled) {
return;
}
await showDialog( await showDialog(
context: context, context: context,
builder: (final context) => AlertDialog( builder: (final context) => AlertDialog(

Loading…
Cancel
Save