diff --git a/packages/neon/neon_news/build.yaml b/packages/neon/neon_news/build.yaml new file mode 100644 index 00000000..e69de29b diff --git a/packages/neon/neon_news/lib/neon_news.dart b/packages/neon/neon_news/lib/neon_news.dart index 6a7c4f62..3a534290 100644 --- a/packages/neon/neon_news/lib/neon_news.dart +++ b/packages/neon/neon_news/lib/neon_news.dart @@ -5,6 +5,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_html/flutter_html.dart'; +import 'package:go_router/go_router.dart'; import 'package:html/dom.dart' as html_dom; import 'package:html/parser.dart' as html_parser; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; @@ -16,6 +17,7 @@ import 'package:neon/sort_box.dart'; import 'package:neon/utils.dart'; import 'package:neon/widgets.dart'; import 'package:neon_news/l10n/localizations.dart'; +import 'package:neon_news/routes.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:provider/provider.dart'; import 'package:rxdart/rxdart.dart'; @@ -53,7 +55,9 @@ class NewsApp extends AppImplementation { NewsApp(super.sharedPreferences, super.requestManager, super.platform); @override - String id = 'news'; + String id = appId; + + static const String appId = 'news'; @override LocalizationsDelegate localizationsDelegate = AppLocalizations.delegate; @@ -74,6 +78,9 @@ class NewsApp extends AppImplementation { @override Widget get page => const NewsMainPage(); + @override + RouteBase get route => $newsAppRoute; + @override BehaviorSubject getUnreadCounter(final NewsBloc bloc) => bloc.unreadCounter; } diff --git a/packages/neon/neon_news/lib/routes.dart b/packages/neon/neon_news/lib/routes.dart new file mode 100644 index 00000000..cba521f9 --- /dev/null +++ b/packages/neon/neon_news/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_news/neon_news.dart'; + +part 'routes.g.dart'; + +@TypedGoRoute( + path: '$appsRoutePrefix${NewsApp.appId}', + name: NewsApp.appId, +) +@immutable +class NewsAppRoute extends NeonAppRoute { + const NewsAppRoute(); + + @override + Widget build(final BuildContext context, final GoRouterState state) => const NewsMainPage(); +} diff --git a/packages/neon/neon_news/lib/routes.g.dart b/packages/neon/neon_news/lib/routes.g.dart new file mode 100644 index 00000000..db34106d --- /dev/null +++ b/packages/neon/neon_news/lib/routes.g.dart @@ -0,0 +1,33 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'routes.dart'; + +// ************************************************************************** +// GoRouterGenerator +// ************************************************************************** + +List get $appRoutes => [ + $newsAppRoute, + ]; + +RouteBase get $newsAppRoute => GoRouteData.$route( + path: '/apps/news', + name: 'news', + factory: $NewsAppRouteExtension._fromState, + ); + +extension $NewsAppRouteExtension on NewsAppRoute { + static NewsAppRoute _fromState(GoRouterState state) => const NewsAppRoute(); + + String get location => GoRouteData.$location( + '/apps/news', + ); + + 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_news/pubspec.yaml b/packages/neon/neon_news/pubspec.yaml index 7e0b3289..c4c3a2c0 100644 --- a/packages/neon/neon_news/pubspec.yaml +++ b/packages/neon/neon_news/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: flutter: sdk: flutter flutter_html: ^3.0.0-alpha.6 + go_router: ^8.0.3 html: ^0.15.3 material_design_icons_flutter: ^7.0.7296 neon: @@ -28,6 +29,8 @@ dependencies: webview_flutter: ^4.2.0 dev_dependencies: + build_runner: ^2.4.4 + go_router_builder: ^2.0.2 nit_picking: git: url: https://github.com/stack11/dart_nit_picking