Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove unnecessary generic type arguments #1599

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/neon/neon_dashboard/lib/src/blocs/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class _DashboardBloc extends InteractiveBloc implements DashboardBloc {
}
}

await Future.wait<void>([
await Future.wait([
if (v1WidgetIDs.isNotEmpty)
RequestManager.instance.wrapNextcloud(
account: account,
Expand Down Expand Up @@ -85,10 +85,10 @@ class _DashboardBloc extends InteractiveBloc implements DashboardBloc {
static const int maxItems = 7;

@override
final widgets = BehaviorSubject<Result<BuiltList<dashboard.Widget>>>();
final widgets = BehaviorSubject();

@override
final items = BehaviorSubject<Result<BuiltMap<String, dashboard.WidgetItems>>>();
final items = BehaviorSubject();

@override
void dispose() {
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_dashboard/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Widget wrapWidget(AccountsBloc accountsBloc, Widget child) => MaterialApp(
supportedLocales: DashboardLocalizations.supportedLocales,
home: Scaffold(
backgroundColor: Colors.transparent,
body: NeonProvider<AccountsBloc>.value(
body: NeonProvider.value(
value: accountsBloc,
child: child,
),
Expand Down
6 changes: 3 additions & 3 deletions packages/neon/neon_files/lib/src/blocs/browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ class _FilesBrowserBloc extends InteractiveBloc implements FilesBrowserBloc {
}

@override
BehaviorSubject<Result<List<WebDavFile>>> files = BehaviorSubject<Result<List<WebDavFile>>>();
final files = BehaviorSubject();

@override
BehaviorSubject<PathUri> uri = BehaviorSubject.seeded(PathUri.cwd());
final uri = BehaviorSubject.seeded(PathUri.cwd());

@override
Future<void> refresh() async {
await RequestManager.instance.wrapWebDav<List<WebDavFile>>(
await RequestManager.instance.wrapWebDav(
account: account,
cacheKey: 'files-${uri.value.path}',
subject: files,
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_files/lib/src/blocs/files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class _FilesBloc extends InteractiveBloc implements FilesBloc {
}

@override
BehaviorSubject<List<FilesTask>> tasks = BehaviorSubject<List<FilesTask>>.seeded([]);
final tasks = BehaviorSubject.seeded([]);

@override
void addFavorite(PathUri uri) {
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_files/lib/src/widgets/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class FileActions extends StatelessWidget {
}

@override
Widget build(BuildContext context) => PopupMenuButton<FilesFileAction>(
Widget build(BuildContext context) => PopupMenuButton(
itemBuilder: (context) => [
if (!details.isDirectory && NeonPlatform.instance.canUseSharing)
PopupMenuItem(
Expand Down
8 changes: 4 additions & 4 deletions packages/neon/neon_files/lib/src/widgets/browser_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
}

@override
Widget build(BuildContext context) => ResultBuilder<List<WebDavFile>>.behaviorSubject(
Widget build(BuildContext context) => ResultBuilder.behaviorSubject(
subject: widget.bloc.files,
builder: (context, filesSnapshot) => StreamBuilder<PathUri>(
builder: (context, filesSnapshot) => StreamBuilder(
stream: widget.bloc.uri,
builder: (context, uriSnapshot) => StreamBuilder<List<FilesTask>>(
builder: (context, uriSnapshot) => StreamBuilder(
stream: widget.filesBloc.tasks,
builder: (context, tasksSnapshot) {
if (!uriSnapshot.hasData || !tasksSnapshot.hasData) {
Expand All @@ -57,7 +57,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
}
return false;
},
child: SortBoxBuilder<FilesSortProperty, WebDavFile>(
child: SortBoxBuilder(
sortBox: filesSortBox,
sortProperty: widget.bloc.options.filesSortPropertyOption,
sortBoxOrder: widget.bloc.options.filesSortBoxOrderOption,
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_files/lib/src/widgets/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class FilesChooseFolderDialog extends StatelessWidget {
Widget build(BuildContext context) {
final dialogTheme = NeonDialogTheme.of(context);

return StreamBuilder<PathUri>(
return StreamBuilder(
stream: bloc.uri,
builder: (context, uriSnapshot) {
final actions = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class _FileIcon extends StatelessWidget {
Widget build(BuildContext context) {
Widget icon = Center(
child: details.hasTask
? StreamBuilder<double>(
? StreamBuilder(
stream: details.task!.progress,
builder: (context, progress) => Column(
children: [
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_files/lib/src/widgets/file_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class FilePreview extends StatelessWidget {
);
}

return ValueListenableBuilder<bool>(
return ValueListenableBuilder(
valueListenable: bloc.options.showPreviewsOption,
builder: (context, showPreviews, _) {
if (showPreviews && (details.hasPreview ?? false)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/neon/neon_news/lib/src/blocs/article.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class _NewsArticleBloc extends InteractiveBloc implements NewsArticleBloc {
}

@override
BehaviorSubject<bool> starred = BehaviorSubject<bool>();
final starred = BehaviorSubject();

@override
BehaviorSubject<bool> unread = BehaviorSubject<bool>();
final unread = BehaviorSubject();

@override
Future<void> refresh() async {}
Expand Down
6 changes: 3 additions & 3 deletions packages/neon/neon_news/lib/src/blocs/articles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ class _NewsArticlesBloc extends InteractiveBloc implements NewsArticlesBloc {
}

@override
BehaviorSubject<Result<BuiltList<news.Article>>> articles = BehaviorSubject<Result<BuiltList<news.Article>>>();
final articles = BehaviorSubject();

@override
BehaviorSubject<FilterType> filterType = BehaviorSubject<FilterType>();
final filterType = BehaviorSubject();

@override
Future<void> refresh() async {
Expand Down Expand Up @@ -145,7 +145,7 @@ class _NewsArticlesBloc extends InteractiveBloc implements NewsArticlesBloc {
}
}

await RequestManager.instance.wrapNextcloud<BuiltList<news.Article>, news.ListArticles, void>(
await RequestManager.instance.wrapNextcloud(
account: account,
cacheKey: 'news-articles-${type.index}-$id-$getRead',
subject: articles,
Expand Down
14 changes: 7 additions & 7 deletions packages/neon/neon_news/lib/src/blocs/news.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,31 @@ class _NewsBloc extends InteractiveBloc implements NewsBloc, NewsMainArticlesBlo
}

@override
BehaviorSubject<Result<BuiltList<news.Feed>>> feeds = BehaviorSubject<Result<BuiltList<news.Feed>>>();
final feeds = BehaviorSubject();

@override
BehaviorSubject<Result<BuiltList<news.Folder>>> folders = BehaviorSubject<Result<BuiltList<news.Folder>>>();
final folders = BehaviorSubject();

@override
BehaviorSubject<int> unreadCounter = BehaviorSubject<int>();
final unreadCounter = BehaviorSubject();

@override
late BehaviorSubject<Result<BuiltList<news.Article>>> articles = mainArticlesBloc.articles;
late final articles = mainArticlesBloc.articles;

@override
late BehaviorSubject<FilterType> filterType = mainArticlesBloc.filterType;
late final filterType = mainArticlesBloc.filterType;

@override
Future<void> refresh() async {
await Future.wait([
RequestManager.instance.wrapNextcloud<BuiltList<news.Folder>, news.ListFolders, void>(
RequestManager.instance.wrapNextcloud(
account: account,
cacheKey: 'news-folders',
subject: folders,
rawResponse: account.client.news.listFoldersRaw(),
unwrap: (response) => response.body.folders,
),
RequestManager.instance.wrapNextcloud<BuiltList<news.Feed>, news.ListFeeds, void>(
RequestManager.instance.wrapNextcloud(
account: account,
cacheKey: 'news-feeds',
subject: feeds,
Expand Down
4 changes: 2 additions & 2 deletions packages/neon/neon_news/lib/src/pages/article.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class _NewsArticlePageState extends State<NewsArticlePage> {
strokeWidth: 2,
),
),
StreamBuilder<bool>(
StreamBuilder(
stream: widget.bloc.starred,
builder: (context, starredSnapshot) {
final starred = starredSnapshot.data ?? false;
Expand All @@ -155,7 +155,7 @@ class _NewsArticlePageState extends State<NewsArticlePage> {
);
},
),
StreamBuilder<bool>(
StreamBuilder(
stream: widget.bloc.unread,
builder: (context, unreadSnapshot) {
final unread = unreadSnapshot.data ?? false;
Expand Down
13 changes: 6 additions & 7 deletions packages/neon/neon_news/lib/src/widgets/articles_view.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:built_collection/built_collection.dart';
import 'package:flutter/material.dart';
import 'package:html/dom.dart' as html_dom;
import 'package:html/parser.dart' as html_parser;
Expand Down Expand Up @@ -44,11 +43,11 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
}

@override
Widget build(BuildContext context) => ResultBuilder<BuiltList<news.Feed>>.behaviorSubject(
Widget build(BuildContext context) => ResultBuilder.behaviorSubject(
subject: widget.newsBloc.feeds,
builder: (context, feeds) => ResultBuilder<BuiltList<news.Article>>.behaviorSubject(
builder: (context, feeds) => ResultBuilder.behaviorSubject(
subject: widget.bloc.articles,
builder: (context, articles) => SortBoxBuilder<ArticlesSortProperty, news.Article>(
builder: (context, articles) => SortBoxBuilder(
sortBox: articlesSortBox,
sortProperty: widget.newsBloc.options.articlesSortPropertyOption,
sortBoxOrder: widget.newsBloc.options.articlesSortBoxOrderOption,
Expand All @@ -74,11 +73,11 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
);
},
topFixedChildren: [
StreamBuilder<FilterType>(
StreamBuilder(
stream: widget.bloc.filterType,
builder: (context, selectedFilterTypeSnapshot) => Container(
margin: const EdgeInsets.symmetric(horizontal: 15),
child: DropdownButton<FilterType>(
child: DropdownButton(
isExpanded: true,
value: selectedFilterTypeSnapshot.data,
items: [
Expand All @@ -87,7 +86,7 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
if (widget.bloc.listType == null) ...[
FilterType.starred,
],
].map<DropdownMenuItem<FilterType>>(
].map(
(a) {
late final String label;
switch (a) {
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_news/lib/src/widgets/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class _NewsAddFeedDialogState extends State<NewsAddFeedDialog> {
),
);

final folderSelector = ResultBuilder<BuiltList<news.Folder>>.behaviorSubject(
final folderSelector = ResultBuilder.behaviorSubject(
subject: widget.bloc.folders,
builder: (context, folders) {
if (folders.hasError) {
Expand Down
9 changes: 4 additions & 5 deletions packages/neon/neon_news/lib/src/widgets/feeds_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:neon_framework/utils.dart';
import 'package:neon_framework/widgets.dart';
import 'package:neon_news/l10n/localizations.dart';
import 'package:neon_news/src/blocs/news.dart';
import 'package:neon_news/src/options.dart';
import 'package:neon_news/src/pages/feed.dart';
import 'package:neon_news/src/sort/feeds.dart';
import 'package:neon_news/src/widgets/dialog.dart';
Expand All @@ -25,11 +24,11 @@ class NewsFeedsView extends StatelessWidget {
final int? folderID;

@override
Widget build(BuildContext context) => ResultBuilder<BuiltList<news.Folder>>.behaviorSubject(
Widget build(BuildContext context) => ResultBuilder.behaviorSubject(
subject: bloc.folders,
builder: (context, folders) => ResultBuilder<BuiltList<news.Feed>>.behaviorSubject(
builder: (context, folders) => ResultBuilder.behaviorSubject(
subject: bloc.feeds,
builder: (context, feeds) => SortBoxBuilder<FeedsSortProperty, news.Feed>(
builder: (context, feeds) => SortBoxBuilder(
sortBox: feedsSortBox,
sortProperty: bloc.options.feedsSortPropertyOption,
sortBoxOrder: bloc.options.feedsSortBoxOrderOption,
Expand Down Expand Up @@ -87,7 +86,7 @@ class NewsFeedsView extends StatelessWidget {
),
),
),
PopupMenuButton<NewsFeedAction>(
PopupMenuButton(
itemBuilder: (context) => [
PopupMenuItem(
value: NewsFeedAction.showURL,
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_news/lib/src/widgets/folder_select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class NewsFolderSelect extends StatelessWidget {
child: Text(NewsLocalizations.of(context).folderRoot),
),
...folders.map(
(f) => DropdownMenuItem<news.Folder>(
(f) => DropdownMenuItem(
value: f,
child: Text(f.name),
),
Expand Down
4 changes: 2 additions & 2 deletions packages/neon/neon_news/lib/src/widgets/folder_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class _NewsFolderViewState extends State<NewsFolderView> {
children: [
Container(
margin: const EdgeInsets.symmetric(horizontal: 15),
child: DropdownButton<DefaultFolderViewType>(
child: DropdownButton(
isExpanded: true,
value: _viewType,
items: option.values.keys
.map(
(key) => DropdownMenuItem<DefaultFolderViewType>(
(key) => DropdownMenuItem(
value: key,
child: Text(option.values[key]!(context)),
),
Expand Down
11 changes: 4 additions & 7 deletions packages/neon/neon_news/lib/src/widgets/folders_view.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import 'package:built_collection/built_collection.dart';
import 'package:flutter/material.dart';
import 'package:neon_framework/blocs.dart';
import 'package:neon_framework/sort_box.dart';
import 'package:neon_framework/theme.dart';
import 'package:neon_framework/widgets.dart';
import 'package:neon_news/l10n/localizations.dart';
import 'package:neon_news/src/blocs/news.dart';
import 'package:neon_news/src/options.dart';
import 'package:neon_news/src/pages/folder.dart';
import 'package:neon_news/src/sort/folders.dart';
import 'package:neon_news/utils/dialog.dart';
import 'package:nextcloud/news.dart' as news;

class NewsFoldersView extends StatelessWidget {
const NewsFoldersView({
Expand All @@ -21,11 +18,11 @@ class NewsFoldersView extends StatelessWidget {
final NewsBloc bloc;

@override
Widget build(BuildContext context) => ResultBuilder<BuiltList<news.Folder>>.behaviorSubject(
Widget build(BuildContext context) => ResultBuilder.behaviorSubject(
subject: bloc.folders,
builder: (context, folders) => ResultBuilder<BuiltList<news.Feed>>.behaviorSubject(
builder: (context, folders) => ResultBuilder.behaviorSubject(
subject: bloc.feeds,
builder: (context, feeds) => SortBoxBuilder<FoldersSortProperty, FolderFeedsWrapper>(
builder: (context, feeds) => SortBoxBuilder(
sortBox: foldersSortBox,
sortProperty: bloc.options.foldersSortPropertyOption,
sortBoxOrder: bloc.options.foldersSortBoxOrderOption,
Expand Down Expand Up @@ -86,7 +83,7 @@ class NewsFoldersView extends StatelessWidget {
],
),
),
trailing: PopupMenuButton<NewsFolderAction>(
trailing: PopupMenuButton(
itemBuilder: (context) => [
PopupMenuItem(
value: NewsFolderAction.delete,
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_notes/lib/src/blocs/note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class _NotesNoteBloc extends InteractiveBloc implements NotesNoteBloc {
}

@override
BehaviorSubject<String> category = BehaviorSubject<String>();
final category = BehaviorSubject();

@override
Future<void> refresh() async {}
Expand Down
4 changes: 2 additions & 2 deletions packages/neon/neon_notes/lib/src/blocs/notes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ class _NotesBloc extends InteractiveBloc implements NotesBloc {
}

@override
BehaviorSubject<Result<BuiltList<notes.Note>>> notesList = BehaviorSubject<Result<BuiltList<notes.Note>>>();
final notesList = BehaviorSubject();

@override
Future<void> refresh() async {
await RequestManager.instance.wrapNextcloud<BuiltList<notes.Note>, BuiltList<notes.Note>, void>(
await RequestManager.instance.wrapNextcloud(
account: account,
cacheKey: 'notes-notes',
subject: notesList,
Expand Down
Loading
Loading