From e1637c11e335c3aca65def1ca68b633390cea733 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Mon, 26 Jun 2023 18:29:03 +0200 Subject: [PATCH] neon_files: add app route --- packages/neon/neon_files/build.yaml | 0 packages/neon/neon_files/lib/neon_files.dart | 9 +++++- packages/neon/neon_files/lib/routes.dart | 18 +++++++++++ packages/neon/neon_files/lib/routes.g.dart | 33 ++++++++++++++++++++ packages/neon/neon_files/pubspec.yaml | 3 ++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 packages/neon/neon_files/build.yaml create mode 100644 packages/neon/neon_files/lib/routes.dart create mode 100644 packages/neon/neon_files/lib/routes.g.dart diff --git a/packages/neon/neon_files/build.yaml b/packages/neon/neon_files/build.yaml new file mode 100644 index 00000000..e69de29b diff --git a/packages/neon/neon_files/lib/neon_files.dart b/packages/neon/neon_files/lib/neon_files.dart index 246b507a..9a3dbb54 100644 --- a/packages/neon/neon_files/lib/neon_files.dart +++ b/packages/neon/neon_files/lib/neon_files.dart @@ -9,6 +9,7 @@ import 'package:file_icons/file_icons.dart'; import 'package:file_picker/file_picker.dart'; import 'package:filesize/filesize.dart'; import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import 'package:image_picker/image_picker.dart'; import 'package:intersperse/intersperse.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; @@ -21,6 +22,7 @@ import 'package:neon/theme.dart'; import 'package:neon/utils.dart'; import 'package:neon/widgets.dart'; import 'package:neon_files/l10n/localizations.dart'; +import 'package:neon_files/routes.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:open_file/open_file.dart'; import 'package:path/path.dart' as p; @@ -47,7 +49,9 @@ class FilesApp extends AppImplementation { FilesApp(super.sharedPreferences, super.requestManager, super.platform); @override - String id = 'files'; + String id = appId; + + static const String appId = 'files'; @override LocalizationsDelegate localizationsDelegate = AppLocalizations.delegate; @@ -68,4 +72,7 @@ class FilesApp extends AppImplementation { @override Widget get page => const FilesMainPage(); + + @override + RouteBase get route => $filesAppRoute; } diff --git a/packages/neon/neon_files/lib/routes.dart b/packages/neon/neon_files/lib/routes.dart new file mode 100644 index 00000000..395b10a4 --- /dev/null +++ b/packages/neon/neon_files/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_files/neon_files.dart'; + +part 'routes.g.dart'; + +@TypedGoRoute( + path: '$appsRoutePrefix${FilesApp.appId}', + name: FilesApp.appId, +) +@immutable +class FilesAppRoute extends NeonAppRoute { + const FilesAppRoute(); + + @override + Widget build(final BuildContext context, final GoRouterState state) => const FilesMainPage(); +} diff --git a/packages/neon/neon_files/lib/routes.g.dart b/packages/neon/neon_files/lib/routes.g.dart new file mode 100644 index 00000000..d8943daa --- /dev/null +++ b/packages/neon/neon_files/lib/routes.g.dart @@ -0,0 +1,33 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'routes.dart'; + +// ************************************************************************** +// GoRouterGenerator +// ************************************************************************** + +List get $appRoutes => [ + $filesAppRoute, + ]; + +RouteBase get $filesAppRoute => GoRouteData.$route( + path: '/apps/files', + name: 'files', + factory: $FilesAppRouteExtension._fromState, + ); + +extension $FilesAppRouteExtension on FilesAppRoute { + static FilesAppRoute _fromState(GoRouterState state) => const FilesAppRoute(); + + String get location => GoRouteData.$location( + '/apps/files', + ); + + 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_files/pubspec.yaml b/packages/neon/neon_files/pubspec.yaml index a2c729cb..f33d30f4 100644 --- a/packages/neon/neon_files/pubspec.yaml +++ b/packages/neon/neon_files/pubspec.yaml @@ -16,6 +16,7 @@ dependencies: filesize: ^2.0.1 flutter: sdk: flutter + go_router: ^8.0.3 image_picker: ^0.8.7+5 intersperse: ^2.0.0 material_design_icons_flutter: ^7.0.7296 @@ -35,6 +36,8 @@ dependencies: share_plus: ^7.0.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