Browse Source

neon: Show info about enabling push notifications

pull/162/head
jld3103 2 years ago
parent
commit
74721807d4
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 7
      packages/neon/integration_test/screenshot_test.dart
  2. 1
      packages/neon/lib/l10n/en.arb
  3. 6
      packages/neon/lib/l10n/localizations.dart
  4. 3
      packages/neon/lib/l10n/localizations_en.dart
  5. 4
      packages/neon/lib/main.dart
  6. 4
      packages/neon/lib/src/app.dart
  7. 30
      packages/neon/lib/src/blocs/first_launch.dart
  8. 1
      packages/neon/lib/src/neon.dart
  9. 20
      packages/neon/lib/src/pages/home.dart

7
packages/neon/integration_test/screenshot_test.dart

@ -128,6 +128,10 @@ Future pumpAppPage(
globalOptions,
platform,
);
final firstLaunchBloc = FirstLaunchBloc(
sharedPreferences,
disabled: true,
);
// ignore: close_sinks
final userThemeStream = BehaviorSubject<NextcloudTheme?>();
@ -156,6 +160,9 @@ Future pumpAppPage(
Provider<PushNotificationsBloc>(
create: (final _) => pushNotificationsBloc,
),
Provider<FirstLaunchBloc>(
create: (final _) => firstLaunchBloc,
),
Provider<List<AppImplementation>>(
create: (final _) => allAppImplementations,
),

1
packages/neon/lib/l10n/en.arb

@ -65,6 +65,7 @@
}
}
},
"settingsGoToSettingsToEnablePushNotifications": "Go to the settings to enable push notifications",
"optionsCategoryGeneral": "General",
"optionsCategoryTheme": "Theme",
"optionsCategoryPushNotifications": "Push notifications",

6
packages/neon/lib/l10n/localizations.dart

@ -311,6 +311,12 @@ abstract class AppLocalizations {
/// **'Do you want to reset all settings for {name}?'**
String settingsResetForConfirmation(String name);
/// No description provided for @settingsGoToSettingsToEnablePushNotifications.
///
/// In en, this message translates to:
/// **'Go to the settings to enable push notifications'**
String get settingsGoToSettingsToEnablePushNotifications;
/// No description provided for @optionsCategoryGeneral.
///
/// In en, this message translates to:

3
packages/neon/lib/l10n/localizations_en.dart

@ -126,6 +126,9 @@ class AppLocalizationsEn extends AppLocalizations {
return 'Do you want to reset all settings for $name?';
}
@override
String get settingsGoToSettingsToEnablePushNotifications => 'Go to the settings to enable push notifications';
@override
String get optionsCategoryGeneral => 'General';

4
packages/neon/lib/main.dart

@ -54,6 +54,7 @@ Future main() async {
globalOptions,
platform,
);
final firstLaunchBloc = FirstLaunchBloc(sharedPreferences);
runApp(
MultiProvider(
@ -79,6 +80,9 @@ Future main() async {
Provider<PushNotificationsBloc>(
create: (final _) => pushNotificationsBloc,
),
Provider<FirstLaunchBloc>(
create: (final _) => firstLaunchBloc,
),
Provider<List<AppImplementation>>(
create: (final _) => allAppImplementations,
),

4
packages/neon/lib/src/app.dart

@ -70,13 +70,15 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
const settings = RouteSettings(
name: 'home',
);
Widget builder(final context) => HomePage(
Widget builder(final context) => Scaffold(
body: HomePage(
account: activeAccount,
onThemeChanged: (final nextcloudTheme) {
setState(() {
_nextcloudTheme = nextcloudTheme;
});
},
),
);
await _navigatorKey.currentState!.pushAndRemoveUntil(
widget.globalOptions.navigationMode.value == NavigationMode.drawer

30
packages/neon/lib/src/blocs/first_launch.dart

@ -0,0 +1,30 @@
part of '../neon.dart';
abstract class FirstLaunchBlocEvents {}
abstract class FirstLaunchBlocStates {
BehaviorSubject get onFirstLaunch;
}
class FirstLaunchBloc extends Bloc implements FirstLaunchBlocEvents, FirstLaunchBlocStates {
FirstLaunchBloc(
this._sharedPreferences, {
final bool disabled = false,
}) {
if (!disabled && !_sharedPreferences.containsKey(_keyFirstLaunch)) {
onFirstLaunch.add(null);
unawaited(_sharedPreferences.setBool(_keyFirstLaunch, false));
}
}
final SharedPreferences _sharedPreferences;
final _keyFirstLaunch = 'first-launch';
@override
void dispose() {
unawaited(onFirstLaunch.close());
}
@override
BehaviorSubject onFirstLaunch = BehaviorSubject();
}

1
packages/neon/lib/src/neon.dart

@ -50,6 +50,7 @@ part 'app.dart';
part 'blocs/accounts.dart';
part 'blocs/apps.dart';
part 'blocs/capabilities.dart';
part 'blocs/first_launch.dart';
part 'blocs/login.dart';
part 'blocs/push_notifications.dart';
part 'blocs/user_details.dart';

20
packages/neon/lib/src/pages/home.dart

@ -23,6 +23,7 @@ class _HomePageState extends State<HomePage> {
late GlobalOptions _globalOptions;
late CapabilitiesBloc _capabilitiesBloc;
late AppsBloc _appsBloc;
late FirstLaunchBloc _firstLaunchBloc;
@override
void initState() {
@ -31,6 +32,7 @@ class _HomePageState extends State<HomePage> {
_globalOptions = Provider.of<GlobalOptions>(context, listen: false);
_appsBloc = Provider.of<AccountsBloc>(context, listen: false).getAppsBloc(widget.account);
_capabilitiesBloc = Provider.of<AccountsBloc>(context, listen: false).getCapabilitiesBloc(widget.account);
_firstLaunchBloc = Provider.of<FirstLaunchBloc>(context, listen: false);
_capabilitiesBloc.capabilities.listen((final result) async {
if (result.data != null) {
@ -83,6 +85,24 @@ class _HomePageState extends State<HomePage> {
}
});
_firstLaunchBloc.onFirstLaunch.listen((final _) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(AppLocalizations.of(context).settingsGoToSettingsToEnablePushNotifications),
action: SnackBarAction(
label: AppLocalizations.of(context).settings,
onPressed: () async {
await Navigator.of(context).push(
MaterialPageRoute(
builder: (final context) => const SettingsPage(),
),
);
},
),
),
);
});
unawaited(_checkMaintenanceMode());
}

Loading…
Cancel
Save