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

Loading…
Cancel
Save