Browse Source

neon: Hide hint to enable push notifications on first launch when push notifications are unavailable

pull/209/head
jld3103 2 years ago
parent
commit
d774870a2d
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 37
      packages/neon/lib/src/utils/global_popups.dart

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

@ -10,6 +10,7 @@ class GlobalPopups extends StatefulWidget {
} }
class _GlobalPopupsState extends State<GlobalPopups> { class _GlobalPopupsState extends State<GlobalPopups> {
late GlobalOptions _globalOptions;
late FirstLaunchBloc _firstLaunchBloc; late FirstLaunchBloc _firstLaunchBloc;
late NextPushBloc _nextPushBloc; late NextPushBloc _nextPushBloc;
@ -17,25 +18,31 @@ class _GlobalPopupsState extends State<GlobalPopups> {
void initState() { void initState() {
super.initState(); super.initState();
_globalOptions = Provider.of<GlobalOptions>(context, listen: false);
_firstLaunchBloc = Provider.of<FirstLaunchBloc>(context, listen: false); _firstLaunchBloc = Provider.of<FirstLaunchBloc>(context, listen: false);
_nextPushBloc = Provider.of<NextPushBloc>(context, listen: false); _nextPushBloc = Provider.of<NextPushBloc>(context, listen: false);
_firstLaunchBloc.onFirstLaunch.listen((final _) { _firstLaunchBloc.onFirstLaunch.listen((final _) async {
ScaffoldMessenger.of(context).showSnackBar( if (await _globalOptions.pushNotificationsEnabled.enabled.first) {
SnackBar( if (!mounted) {
content: Text(AppLocalizations.of(context).firstLaunchGoToSettingsToEnablePushNotifications), return;
action: SnackBarAction( }
label: AppLocalizations.of(context).settings, ScaffoldMessenger.of(context).showSnackBar(
onPressed: () async { SnackBar(
await Navigator.of(context).push( content: Text(AppLocalizations.of(context).firstLaunchGoToSettingsToEnablePushNotifications),
MaterialPageRoute( action: SnackBarAction(
builder: (final context) => const SettingsPage(), label: AppLocalizations.of(context).settings,
), onPressed: () async {
); await Navigator.of(context).push(
}, MaterialPageRoute(
builder: (final context) => const SettingsPage(),
),
);
},
),
), ),
), );
); }
}); });
_nextPushBloc.onNextPushSupported.listen((final _) async { _nextPushBloc.onNextPushSupported.listen((final _) async {

Loading…
Cancel
Save