diff --git a/packages/neon/neon_notes/build.yaml b/packages/neon/neon_notes/build.yaml new file mode 100644 index 00000000..e69de29b diff --git a/packages/neon/neon_notes/lib/neon_notes.dart b/packages/neon/neon_notes/lib/neon_notes.dart index 41e73862..a5c29136 100644 --- a/packages/neon/neon_notes/lib/neon_notes.dart +++ b/packages/neon/neon_notes/lib/neon_notes.dart @@ -7,6 +7,7 @@ import 'package:built_collection/built_collection.dart'; import 'package:crypto/crypto.dart'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.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'; @@ -16,6 +17,7 @@ import 'package:neon/sort_box.dart'; import 'package:neon/utils.dart'; import 'package:neon/widgets.dart'; import 'package:neon_notes/l10n/localizations.dart'; +import 'package:neon_notes/routes.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:provider/provider.dart'; import 'package:queue/queue.dart'; @@ -44,7 +46,9 @@ class NotesApp extends AppImplementation { NotesApp(super.sharedPreferences, super.requestManager, super.platform); @override - String id = 'notes'; + String id = appId; + + static const String appId = 'notes'; @override List supportedLocales = AppLocalizations.supportedLocales; @@ -64,4 +68,7 @@ class NotesApp extends AppImplementation { @override Widget get page => const NotesMainPage(); + + @override + RouteBase get route => $notesAppRoute; } diff --git a/packages/neon/neon_notes/lib/routes.dart b/packages/neon/neon_notes/lib/routes.dart new file mode 100644 index 00000000..8cbb7f3f --- /dev/null +++ b/packages/neon/neon_notes/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_notes/neon_notes.dart'; + +part 'routes.g.dart'; + +@TypedGoRoute( + path: '$appsRoutePrefix${NotesApp.appId}', + name: NotesApp.appId, +) +@immutable +class NotesAppRoute extends NeonAppRoute { + const NotesAppRoute(); + + @override + Widget build(final BuildContext context, final GoRouterState state) => const NotesMainPage(); +} diff --git a/packages/neon/neon_notes/lib/routes.g.dart b/packages/neon/neon_notes/lib/routes.g.dart new file mode 100644 index 00000000..cb68c111 --- /dev/null +++ b/packages/neon/neon_notes/lib/routes.g.dart @@ -0,0 +1,33 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'routes.dart'; + +// ************************************************************************** +// GoRouterGenerator +// ************************************************************************** + +List get $appRoutes => [ + $notesAppRoute, + ]; + +RouteBase get $notesAppRoute => GoRouteData.$route( + path: '/apps/notes', + name: 'notes', + factory: $NotesAppRouteExtension._fromState, + ); + +extension $NotesAppRouteExtension on NotesAppRoute { + static NotesAppRoute _fromState(GoRouterState state) => const NotesAppRoute(); + + String get location => GoRouteData.$location( + '/apps/notes', + ); + + 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_notes/pubspec.yaml b/packages/neon/neon_notes/pubspec.yaml index 5952d3f1..6319ea2b 100644 --- a/packages/neon/neon_notes/pubspec.yaml +++ b/packages/neon/neon_notes/pubspec.yaml @@ -12,6 +12,7 @@ dependencies: flutter: sdk: flutter flutter_markdown: ^0.6.14 + go_router: ^8.0.3 material_design_icons_flutter: ^7.0.7296 neon: git: @@ -28,6 +29,8 @@ dependencies: wakelock: ^0.6.2 dev_dependencies: + build_runner: ^2.4.4 + go_router_builder: ^2.0.2 nit_picking: git: url: https://github.com/stack11/dart_nit_picking