diff --git a/packages/neon/neon/lib/src/bloc/bloc.dart b/packages/neon/neon/lib/src/bloc/bloc.dart index be6582f5..d3b94912 100644 --- a/packages/neon/neon/lib/src/bloc/bloc.dart +++ b/packages/neon/neon/lib/src/bloc/bloc.dart @@ -19,7 +19,7 @@ abstract class InteractiveBloc extends Bloc { final _errorsStreamController = StreamController(); late Stream errors = _errorsStreamController.stream.asBroadcastStream(); - Future refresh(); + FutureOr refresh(); void addError(final Object error) { _errorsStreamController.add(error); diff --git a/packages/neon/neon/lib/src/sort_box/sort_box_builder.dart b/packages/neon/neon/lib/src/sort_box/sort_box_builder.dart index 35803216..2a6e323f 100644 --- a/packages/neon/neon/lib/src/sort_box/sort_box_builder.dart +++ b/packages/neon/neon/lib/src/sort_box/sort_box_builder.dart @@ -1,5 +1,5 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; -import 'package:neon/src/settings/models/option.dart'; import 'package:sort_box/sort_box.dart'; /// Signature for a function that creates a widget for a given sorted list. @@ -11,19 +11,25 @@ typedef SortBoxWidgetBuilder = Widget Function(BuildContext context, List /// /// Used together with a [SortBox] to sort a given list. class SortBoxBuilder extends StatelessWidget { + /// Creates a new sort box builder. SortBoxBuilder({ required this.sortBox, - required this.sortPropertyOption, - required this.sortBoxOrderOption, + required this.sortProperty, + required this.sortBoxOrder, required final List? input, required this.builder, this.presort, super.key, }) : input = input ?? []; + /// The box containing all sorting properties. final SortBox sortBox; - final SelectOption sortPropertyOption; - final SelectOption sortBoxOrderOption; + + /// The property to sort on. + final ValueListenable sortProperty; + + /// The sorting order applied to the [sortProperty]. + final ValueListenable sortBoxOrder; /// Input list to sort. final List input; @@ -42,9 +48,9 @@ class SortBoxBuilder extends StatelessWidget { } return ValueListenableBuilder( - valueListenable: sortPropertyOption, + valueListenable: sortProperty, builder: (final context, final property, final _) => ValueListenableBuilder( - valueListenable: sortBoxOrderOption, + valueListenable: sortBoxOrder, builder: (final context, final order, final _) { final box = (property, order); diff --git a/packages/neon/neon/lib/src/sort_box/sort_box_order_option_values.dart b/packages/neon/neon/lib/src/sort_box/sort_box_order_option_values.dart index 2d69f581..a76b6ea2 100644 --- a/packages/neon/neon/lib/src/sort_box/sort_box_order_option_values.dart +++ b/packages/neon/neon/lib/src/sort_box/sort_box_order_option_values.dart @@ -2,6 +2,7 @@ import 'package:neon/l10n/localizations.dart'; import 'package:neon/src/models/label_builder.dart'; import 'package:sort_box/sort_box.dart'; +/// Sort box order labels used in an `SelectOption`. final sortBoxOrderOptionValues = { SortBoxOrder.ascending: (final context) => AppLocalizations.of(context).optionsSortOrderAscending, SortBoxOrder.descending: (final context) => AppLocalizations.of(context).optionsSortOrderDescending, diff --git a/packages/neon/neon/lib/src/utils/app_route.dart b/packages/neon/neon/lib/src/utils/app_route.dart index 544d6bfc..0985b9a7 100644 --- a/packages/neon/neon/lib/src/utils/app_route.dart +++ b/packages/neon/neon/lib/src/utils/app_route.dart @@ -4,9 +4,11 @@ import 'package:go_router/go_router.dart'; /// [RouteData] for the initial page of an app. /// /// Subclasses must override one of [build] or [redirect]. +/// Routes should be prefixed with [appsBaseRoutePrefix]. @immutable -abstract class NeonAppRoute extends GoRouteData { - const NeonAppRoute(); +abstract class NeonBaseAppRoute extends GoRouteData { + /// Creates a new app base route. + const NeonBaseAppRoute(); @override Page buildPage(final BuildContext context, final GoRouterState state) => NoTransitionPage( @@ -14,4 +16,5 @@ abstract class NeonAppRoute extends GoRouteData { ); } -const appsRoutePrefix = '/apps/'; +/// Prefix for [NeonBaseAppRoute]s. +const appsBaseRoutePrefix = '/apps/'; diff --git a/packages/neon/neon_files/lib/routes.dart b/packages/neon/neon_files/lib/routes.dart index 823bdc72..134ec818 100644 --- a/packages/neon/neon_files/lib/routes.dart +++ b/packages/neon/neon_files/lib/routes.dart @@ -7,11 +7,11 @@ import 'package:neon_files/neon_files.dart'; part 'routes.g.dart'; @TypedGoRoute( - path: '$appsRoutePrefix${AppIDs.files}', + path: '$appsBaseRoutePrefix${AppIDs.files}', name: AppIDs.files, ) @immutable -class FilesAppRoute extends NeonAppRoute { +class FilesAppRoute extends NeonBaseAppRoute { const FilesAppRoute(); @override diff --git a/packages/neon/neon_files/lib/widgets/browser_view.dart b/packages/neon/neon_files/lib/widgets/browser_view.dart index 435cc41b..67cc8564 100644 --- a/packages/neon/neon_files/lib/widgets/browser_view.dart +++ b/packages/neon/neon_files/lib/widgets/browser_view.dart @@ -60,8 +60,8 @@ class _FilesBrowserViewState extends State { }, child: SortBoxBuilder( sortBox: filesSortBox, - sortPropertyOption: widget.bloc.options.filesSortPropertyOption, - sortBoxOrderOption: widget.bloc.options.filesSortBoxOrderOption, + sortProperty: widget.bloc.options.filesSortPropertyOption, + sortBoxOrder: widget.bloc.options.filesSortBoxOrderOption, presort: const { (FilesSortProperty.isFolder, SortBoxOrder.ascending), }, diff --git a/packages/neon/neon_news/lib/blocs/article.dart b/packages/neon/neon_news/lib/blocs/article.dart index 7ccc7aed..3fdf5d19 100644 --- a/packages/neon/neon_news/lib/blocs/article.dart +++ b/packages/neon/neon_news/lib/blocs/article.dart @@ -44,7 +44,7 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents, BehaviorSubject unread = BehaviorSubject(); @override - Future refresh() async {} + void refresh() {} @override void markArticleAsRead() { diff --git a/packages/neon/neon_news/lib/routes.dart b/packages/neon/neon_news/lib/routes.dart index 359d2df5..14959c50 100644 --- a/packages/neon/neon_news/lib/routes.dart +++ b/packages/neon/neon_news/lib/routes.dart @@ -7,11 +7,11 @@ import 'package:neon_news/neon_news.dart'; part 'routes.g.dart'; @TypedGoRoute( - path: '$appsRoutePrefix${AppIDs.news}', + path: '$appsBaseRoutePrefix${AppIDs.news}', name: AppIDs.news, ) @immutable -class NewsAppRoute extends NeonAppRoute { +class NewsAppRoute extends NeonBaseAppRoute { const NewsAppRoute(); @override diff --git a/packages/neon/neon_news/lib/widgets/articles_view.dart b/packages/neon/neon_news/lib/widgets/articles_view.dart index 0c98cc77..88cb8563 100644 --- a/packages/neon/neon_news/lib/widgets/articles_view.dart +++ b/packages/neon/neon_news/lib/widgets/articles_view.dart @@ -31,8 +31,8 @@ class _NewsArticlesViewState extends State { stream: widget.bloc.articles, builder: (final context, final articles) => SortBoxBuilder( sortBox: articlesSortBox, - sortPropertyOption: widget.newsBloc.options.articlesSortPropertyOption, - sortBoxOrderOption: widget.newsBloc.options.articlesSortBoxOrderOption, + sortProperty: widget.newsBloc.options.articlesSortPropertyOption, + sortBoxOrder: widget.newsBloc.options.articlesSortBoxOrderOption, input: articles.data, builder: (final context, final sorted) => NeonListView( scrollKey: 'news-articles', diff --git a/packages/neon/neon_news/lib/widgets/feeds_view.dart b/packages/neon/neon_news/lib/widgets/feeds_view.dart index ae4e9a43..10002f8f 100644 --- a/packages/neon/neon_news/lib/widgets/feeds_view.dart +++ b/packages/neon/neon_news/lib/widgets/feeds_view.dart @@ -17,8 +17,8 @@ class NewsFeedsView extends StatelessWidget { stream: bloc.feeds, builder: (final context, final feeds) => SortBoxBuilder( sortBox: feedsSortBox, - sortPropertyOption: bloc.options.feedsSortPropertyOption, - sortBoxOrderOption: bloc.options.feedsSortBoxOrderOption, + sortProperty: bloc.options.feedsSortPropertyOption, + sortBoxOrder: bloc.options.feedsSortBoxOrderOption, input: folders.hasData ? feeds.data?.where((final f) => folderID == null || f.folderId == folderID).toList() : null, diff --git a/packages/neon/neon_news/lib/widgets/folders_view.dart b/packages/neon/neon_news/lib/widgets/folders_view.dart index fc3da967..2e7e45a0 100644 --- a/packages/neon/neon_news/lib/widgets/folders_view.dart +++ b/packages/neon/neon_news/lib/widgets/folders_view.dart @@ -15,8 +15,8 @@ class NewsFoldersView extends StatelessWidget { stream: bloc.feeds, builder: (final context, final feeds) => SortBoxBuilder( sortBox: foldersSortBox, - sortPropertyOption: bloc.options.foldersSortPropertyOption, - sortBoxOrderOption: bloc.options.foldersSortBoxOrderOption, + sortProperty: bloc.options.foldersSortPropertyOption, + sortBoxOrder: bloc.options.foldersSortBoxOrderOption, input: feeds.hasData ? folders.data?.map((final folder) { final feedsInFolder = feeds.requireData.where((final feed) => feed.folderId == folder.id); diff --git a/packages/neon/neon_notes/lib/blocs/note.dart b/packages/neon/neon_notes/lib/blocs/note.dart index 02e8b9aa..d090e4c7 100644 --- a/packages/neon/neon_notes/lib/blocs/note.dart +++ b/packages/neon/neon_notes/lib/blocs/note.dart @@ -62,7 +62,7 @@ class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, Note BehaviorSubject category = BehaviorSubject(); @override - Future refresh() async {} + void refresh() {} @override void updateCategory(final String category) { diff --git a/packages/neon/neon_notes/lib/routes.dart b/packages/neon/neon_notes/lib/routes.dart index 4bfc0d47..58444f0f 100644 --- a/packages/neon/neon_notes/lib/routes.dart +++ b/packages/neon/neon_notes/lib/routes.dart @@ -7,11 +7,11 @@ import 'package:neon_notes/neon_notes.dart'; part 'routes.g.dart'; @TypedGoRoute( - path: '$appsRoutePrefix${AppIDs.notes}', + path: '$appsBaseRoutePrefix${AppIDs.notes}', name: AppIDs.notes, ) @immutable -class NotesAppRoute extends NeonAppRoute { +class NotesAppRoute extends NeonBaseAppRoute { const NotesAppRoute(); @override diff --git a/packages/neon/neon_notes/lib/widgets/categories_view.dart b/packages/neon/neon_notes/lib/widgets/categories_view.dart index 794a2c4b..dd04001f 100644 --- a/packages/neon/neon_notes/lib/widgets/categories_view.dart +++ b/packages/neon/neon_notes/lib/widgets/categories_view.dart @@ -13,8 +13,8 @@ class NotesCategoriesView extends StatelessWidget { stream: bloc.notes, builder: (final context, final notes) => SortBoxBuilder( sortBox: categoriesSortBox, - sortPropertyOption: bloc.options.categoriesSortPropertyOption, - sortBoxOrderOption: bloc.options.categoriesSortBoxOrderOption, + sortProperty: bloc.options.categoriesSortPropertyOption, + sortBoxOrder: bloc.options.categoriesSortBoxOrderOption, input: notes.data ?.map((final note) => note.category) .toSet() diff --git a/packages/neon/neon_notes/lib/widgets/notes_view.dart b/packages/neon/neon_notes/lib/widgets/notes_view.dart index 07b8730c..e1fb7ac7 100644 --- a/packages/neon/neon_notes/lib/widgets/notes_view.dart +++ b/packages/neon/neon_notes/lib/widgets/notes_view.dart @@ -18,8 +18,8 @@ class NotesView extends StatelessWidget { presort: const { (NotesSortProperty.favorite, SortBoxOrder.ascending), }, - sortPropertyOption: bloc.options.notesSortPropertyOption, - sortBoxOrderOption: bloc.options.notesSortBoxOrderOption, + sortProperty: bloc.options.notesSortPropertyOption, + sortBoxOrder: bloc.options.notesSortBoxOrderOption, input: category != null ? notes.data?.where((final note) => note.category == category).toList() : notes.data, builder: (final context, final sorted) => NeonListView( scrollKey: 'notes-notes', diff --git a/packages/neon/neon_notifications/lib/routes.dart b/packages/neon/neon_notifications/lib/routes.dart index 233f8655..3a5a466c 100644 --- a/packages/neon/neon_notifications/lib/routes.dart +++ b/packages/neon/neon_notifications/lib/routes.dart @@ -7,11 +7,11 @@ import 'package:neon_notifications/neon_notifications.dart'; part 'routes.g.dart'; @TypedGoRoute( - path: '$appsRoutePrefix${AppIDs.notifications}', + path: '$appsBaseRoutePrefix${AppIDs.notifications}', name: AppIDs.notifications, ) @immutable -class NotificationsAppRoute extends NeonAppRoute { +class NotificationsAppRoute extends NeonBaseAppRoute { const NotificationsAppRoute(); @override