From 916e9f762d81a8fd6ca8a30b6a43a260424a0b69 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Mon, 26 Jun 2023 18:29:02 +0200 Subject: [PATCH] neon_notifications: add app route --- packages/neon/neon_notifications/build.yaml | 0 .../lib/neon_notifications.dart | 9 ++++- .../neon/neon_notifications/lib/routes.dart | 18 ++++++++++ .../neon/neon_notifications/lib/routes.g.dart | 33 +++++++++++++++++++ packages/neon/neon_notifications/pubspec.yaml | 3 ++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 packages/neon/neon_notifications/build.yaml create mode 100644 packages/neon/neon_notifications/lib/routes.dart create mode 100644 packages/neon/neon_notifications/lib/routes.g.dart diff --git a/packages/neon/neon_notifications/build.yaml b/packages/neon/neon_notifications/build.yaml new file mode 100644 index 00000000..e69de29b diff --git a/packages/neon/neon_notifications/lib/neon_notifications.dart b/packages/neon/neon_notifications/lib/neon_notifications.dart index e0d4d696..eee8591f 100644 --- a/packages/neon/neon_notifications/lib/neon_notifications.dart +++ b/packages/neon/neon_notifications/lib/neon_notifications.dart @@ -3,6 +3,7 @@ library notifications; import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:neon/blocs.dart'; import 'package:neon/models.dart'; @@ -10,6 +11,7 @@ import 'package:neon/settings.dart'; import 'package:neon/utils.dart'; import 'package:neon/widgets.dart'; import 'package:neon_notifications/l10n/localizations.dart'; +import 'package:neon_notifications/routes.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:provider/provider.dart'; import 'package:rxdart/rxdart.dart'; @@ -23,7 +25,9 @@ class NotificationsApp extends AppImplementation const NotificationsMainPage(); + @override + RouteBase get route => $notificationsAppRoute; + @override BehaviorSubject getUnreadCounter(final NotificationsBloc bloc) => bloc.unreadCounter; } diff --git a/packages/neon/neon_notifications/lib/routes.dart b/packages/neon/neon_notifications/lib/routes.dart new file mode 100644 index 00000000..39f79ba7 --- /dev/null +++ b/packages/neon/neon_notifications/lib/routes.dart @@ -0,0 +1,18 @@ +import 'package:flutter/widgets.dart'; +import 'package:go_router/go_router.dart'; +import 'package:neon/utils.dart'; +import 'package:neon_notifications/neon_notifications.dart'; + +part 'routes.g.dart'; + +@TypedGoRoute( + path: '$appsRoutePrefix${NotificationsApp.appId}', + name: NotificationsApp.appId, +) +@immutable +class NotificationsAppRoute extends NeonAppRoute { + const NotificationsAppRoute(); + + @override + Widget build(final BuildContext context, final GoRouterState state) => const NotificationsMainPage(); +} diff --git a/packages/neon/neon_notifications/lib/routes.g.dart b/packages/neon/neon_notifications/lib/routes.g.dart new file mode 100644 index 00000000..46db16cb --- /dev/null +++ b/packages/neon/neon_notifications/lib/routes.g.dart @@ -0,0 +1,33 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'routes.dart'; + +// ************************************************************************** +// GoRouterGenerator +// ************************************************************************** + +List get $appRoutes => [ + $notificationsAppRoute, + ]; + +RouteBase get $notificationsAppRoute => GoRouteData.$route( + path: '/apps/notifications', + name: 'notifications', + factory: $NotificationsAppRouteExtension._fromState, + ); + +extension $NotificationsAppRouteExtension on NotificationsAppRoute { + static NotificationsAppRoute _fromState(GoRouterState state) => const NotificationsAppRoute(); + + String get location => GoRouteData.$location( + '/apps/notifications', + ); + + void go(BuildContext context) => context.go(location); + + Future push(BuildContext context) => context.push(location); + + void pushReplacement(BuildContext context) => context.pushReplacement(location); + + void replace(BuildContext context) => context.replace(location); +} diff --git a/packages/neon/neon_notifications/pubspec.yaml b/packages/neon/neon_notifications/pubspec.yaml index 4c764866..944ebdef 100644 --- a/packages/neon/neon_notifications/pubspec.yaml +++ b/packages/neon/neon_notifications/pubspec.yaml @@ -9,6 +9,7 @@ environment: dependencies: flutter: sdk: flutter + go_router: ^8.0.3 material_design_icons_flutter: ^7.0.7296 neon: git: @@ -22,6 +23,8 @@ dependencies: rxdart: ^0.27.7 dev_dependencies: + build_runner: ^2.4.4 + go_router_builder: ^2.0.2 nit_picking: git: url: https://github.com/stack11/dart_nit_picking