Browse Source

neon_news: add app route

pull/466/head
Nikolas Rimikis 1 year ago
parent
commit
382c34e864
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 0
      packages/neon/neon_news/build.yaml
  2. 9
      packages/neon/neon_news/lib/neon_news.dart
  3. 18
      packages/neon/neon_news/lib/routes.dart
  4. 33
      packages/neon/neon_news/lib/routes.g.dart
  5. 3
      packages/neon/neon_news/pubspec.yaml

0
packages/neon/neon_news/build.yaml

9
packages/neon/neon_news/lib/neon_news.dart

@ -5,6 +5,7 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_html/flutter_html.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/dom.dart' as html_dom;
import 'package:html/parser.dart' as html_parser; import 'package:html/parser.dart' as html_parser;
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; 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/utils.dart';
import 'package:neon/widgets.dart'; import 'package:neon/widgets.dart';
import 'package:neon_news/l10n/localizations.dart'; import 'package:neon_news/l10n/localizations.dart';
import 'package:neon_news/routes.dart';
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
@ -53,7 +55,9 @@ class NewsApp extends AppImplementation<NewsBloc, NewsAppSpecificOptions> {
NewsApp(super.sharedPreferences, super.requestManager, super.platform); NewsApp(super.sharedPreferences, super.requestManager, super.platform);
@override @override
String id = 'news'; String id = appId;
static const String appId = 'news';
@override @override
LocalizationsDelegate localizationsDelegate = AppLocalizations.delegate; LocalizationsDelegate localizationsDelegate = AppLocalizations.delegate;
@ -74,6 +78,9 @@ class NewsApp extends AppImplementation<NewsBloc, NewsAppSpecificOptions> {
@override @override
Widget get page => const NewsMainPage(); Widget get page => const NewsMainPage();
@override
RouteBase get route => $newsAppRoute;
@override @override
BehaviorSubject<int> getUnreadCounter(final NewsBloc bloc) => bloc.unreadCounter; BehaviorSubject<int> getUnreadCounter(final NewsBloc bloc) => bloc.unreadCounter;
} }

18
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<NewsAppRoute>(
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();
}

33
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<RouteBase> 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<T?> push<T>(BuildContext context) => context.push<T>(location);
void pushReplacement(BuildContext context) => context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}

3
packages/neon/neon_news/pubspec.yaml

@ -10,6 +10,7 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
flutter_html: ^3.0.0-alpha.6 flutter_html: ^3.0.0-alpha.6
go_router: ^8.0.3
html: ^0.15.3 html: ^0.15.3
material_design_icons_flutter: ^7.0.7296 material_design_icons_flutter: ^7.0.7296
neon: neon:
@ -28,6 +29,8 @@ dependencies:
webview_flutter: ^4.2.0 webview_flutter: ^4.2.0
dev_dependencies: dev_dependencies:
build_runner: ^2.4.4
go_router_builder: ^2.0.2
nit_picking: nit_picking:
git: git:
url: https://github.com/stack11/dart_nit_picking url: https://github.com/stack11/dart_nit_picking

Loading…
Cancel
Save