From 3805c4ea1949d0bcd5ca5b6fcdf650006a6c3ec2 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Wed, 14 Dec 2022 08:35:20 +0100 Subject: [PATCH] neon: Move blocs to the library they belong to --- .../integration_test/screenshot_test.dart | 3 -- packages/neon/lib/main.dart | 2 -- packages/neon/lib/src/apps/files/app.dart | 9 +++--- .../lib/src/apps/files/blocs/browser.dart | 8 +---- .../neon/lib/src/apps/files/blocs/files.dart | 14 +-------- packages/neon/lib/src/apps/news/app.dart | 9 +++--- .../neon/lib/src/apps/news/blocs/article.dart | 7 +---- .../lib/src/apps/news/blocs/articles.dart | 31 +++++++------------ .../neon/lib/src/apps/news/blocs/news.dart | 13 +++----- packages/neon/lib/src/apps/notes/app.dart | 8 ++--- .../neon/lib/src/apps/notes/blocs/note.dart | 10 +----- .../neon/lib/src/apps/notes/blocs/notes.dart | 8 +---- .../neon/lib/src/apps/notifications/app.dart | 7 +++-- .../notifications/blocs/notifications.dart | 8 +---- packages/neon/lib/src/blocs/accounts.dart | 12 +------ packages/neon/lib/src/blocs/apps.dart | 10 +----- packages/neon/lib/src/blocs/capabilities.dart | 7 +---- packages/neon/lib/src/blocs/login.dart | 9 +----- .../lib/src/blocs/push_notifications.dart | 10 +----- packages/neon/lib/src/blocs/user_details.dart | 7 +---- packages/neon/lib/src/blocs/user_status.dart | 8 +---- packages/neon/lib/src/neon.dart | 15 ++++----- 22 files changed, 55 insertions(+), 160 deletions(-) diff --git a/packages/neon/integration_test/screenshot_test.dart b/packages/neon/integration_test/screenshot_test.dart index cb5fc122..4090701c 100644 --- a/packages/neon/integration_test/screenshot_test.dart +++ b/packages/neon/integration_test/screenshot_test.dart @@ -7,9 +7,6 @@ import 'package:integration_test/integration_test.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:neon/l10n/localizations.dart'; import 'package:neon/src/apps/files/app.dart'; -import 'package:neon/src/blocs/accounts.dart'; -import 'package:neon/src/blocs/capabilities.dart'; -import 'package:neon/src/blocs/push_notifications.dart'; import 'package:neon/src/models/account.dart'; import 'package:neon/src/neon.dart'; import 'package:package_info_plus/package_info_plus.dart'; diff --git a/packages/neon/lib/main.dart b/packages/neon/lib/main.dart index 074c5266..a32cf6ee 100644 --- a/packages/neon/lib/main.dart +++ b/packages/neon/lib/main.dart @@ -2,8 +2,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart'; -import 'package:neon/src/blocs/accounts.dart'; -import 'package:neon/src/blocs/push_notifications.dart'; import 'package:neon/src/neon.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:provider/provider.dart'; diff --git a/packages/neon/lib/src/apps/files/app.dart b/packages/neon/lib/src/apps/files/app.dart index c69ea276..5ecfcff8 100644 --- a/packages/neon/lib/src/apps/files/app.dart +++ b/packages/neon/lib/src/apps/files/app.dart @@ -14,17 +14,18 @@ import 'package:image_picker/image_picker.dart'; import 'package:intersperse/intersperse.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:neon/l10n/localizations.dart'; -import 'package:neon/src/apps/files/blocs/browser.dart'; -import 'package:neon/src/apps/files/blocs/files.dart'; -import 'package:neon/src/blocs/accounts.dart'; -import 'package:neon/src/blocs/apps.dart'; +import 'package:neon/src/models/account.dart'; import 'package:neon/src/neon.dart'; import 'package:nextcloud/nextcloud.dart'; +import 'package:open_file/open_file.dart'; import 'package:path/path.dart' as p; import 'package:provider/provider.dart'; +import 'package:queue/queue.dart'; import 'package:rxdart/rxdart.dart'; import 'package:settings/settings.dart'; +part 'blocs/browser.dart'; +part 'blocs/files.dart'; part 'dialogs/choose_create.dart'; part 'dialogs/choose_folder.dart'; part 'dialogs/create_folder.dart'; diff --git a/packages/neon/lib/src/apps/files/blocs/browser.dart b/packages/neon/lib/src/apps/files/blocs/browser.dart index 070f7308..00dce143 100644 --- a/packages/neon/lib/src/apps/files/blocs/browser.dart +++ b/packages/neon/lib/src/apps/files/blocs/browser.dart @@ -1,10 +1,4 @@ -import 'dart:async'; - -import 'package:flutter/foundation.dart'; -import 'package:neon/src/apps/files/app.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../app.dart'; abstract class FilesBrowserBlocEvents { void setPath(final List path); diff --git a/packages/neon/lib/src/apps/files/blocs/files.dart b/packages/neon/lib/src/apps/files/blocs/files.dart index 28b70412..fc471844 100644 --- a/packages/neon/lib/src/apps/files/blocs/files.dart +++ b/packages/neon/lib/src/apps/files/blocs/files.dart @@ -1,16 +1,4 @@ -import 'dart:async'; -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:neon/src/apps/files/app.dart'; -import 'package:neon/src/apps/files/blocs/browser.dart'; -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:open_file/open_file.dart'; -import 'package:path/path.dart' as p; -import 'package:queue/queue.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../app.dart'; abstract class FilesBlocEvents { void uploadFile(final List path, final String localPath); diff --git a/packages/neon/lib/src/apps/news/app.dart b/packages/neon/lib/src/apps/news/app.dart index 30512f78..d60ebb27 100644 --- a/packages/neon/lib/src/apps/news/app.dart +++ b/packages/neon/lib/src/apps/news/app.dart @@ -9,11 +9,7 @@ import 'package:html/dom.dart' as html_dom; import 'package:html/parser.dart' as html_parser; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:neon/l10n/localizations.dart'; -import 'package:neon/src/apps/news/blocs/article.dart'; -import 'package:neon/src/apps/news/blocs/articles.dart'; -import 'package:neon/src/apps/news/blocs/news.dart'; -import 'package:neon/src/blocs/accounts.dart'; -import 'package:neon/src/blocs/apps.dart'; +import 'package:neon/src/models/account.dart'; import 'package:neon/src/neon.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:provider/provider.dart'; @@ -25,6 +21,9 @@ import 'package:url_launcher/url_launcher_string.dart'; import 'package:wakelock/wakelock.dart'; import 'package:webview_flutter/webview_flutter.dart'; +part 'blocs/article.dart'; +part 'blocs/articles.dart'; +part 'blocs/news.dart'; part 'dialogs/add_feed.dart'; part 'dialogs/create_folder.dart'; part 'dialogs/feed_show_url.dart'; diff --git a/packages/neon/lib/src/apps/news/blocs/article.dart b/packages/neon/lib/src/apps/news/blocs/article.dart index ecbac619..7caca987 100644 --- a/packages/neon/lib/src/apps/news/blocs/article.dart +++ b/packages/neon/lib/src/apps/news/blocs/article.dart @@ -1,9 +1,4 @@ -import 'dart:async'; - -import 'package:neon/src/apps/news/blocs/articles.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../app.dart'; abstract class NewsArticleBlocEvents { void markArticleAsRead(); diff --git a/packages/neon/lib/src/apps/news/blocs/articles.dart b/packages/neon/lib/src/apps/news/blocs/articles.dart index a487bd6f..b676485f 100644 --- a/packages/neon/lib/src/apps/news/blocs/articles.dart +++ b/packages/neon/lib/src/apps/news/blocs/articles.dart @@ -1,11 +1,4 @@ -import 'dart:async'; - -import 'package:neon/src/apps/news/app.dart'; -import 'package:neon/src/apps/news/blocs/news.dart'; -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../app.dart'; enum FilterType { all, @@ -49,8 +42,8 @@ class NewsArticlesBloc extends InteractiveBloc implements NewsArticlesBlocEvents NewsArticlesBloc( this._newsBloc, this.options, - this._requestManager, - this._client, { + this.requestManager, + this.client, { this.id, this.listType, }) { @@ -66,8 +59,8 @@ class NewsArticlesBloc extends InteractiveBloc implements NewsArticlesBlocEvents final NewsBloc _newsBloc; final NewsAppSpecificOptions options; - final RequestManager _requestManager; - final NextcloudClient _client; + final RequestManager requestManager; + final NextcloudClient client; final int? id; final ListType? listType; @@ -132,11 +125,11 @@ class NewsArticlesBloc extends InteractiveBloc implements NewsArticlesBlocEvents break; } - await _requestManager.wrapNextcloud, NewsListArticles>( - _client.id, + await requestManager.wrapNextcloud, NewsListArticles>( + client.id, 'news-articles-${type.code}-$id-$getRead', articles, - () async => _client.news.listArticles( + () async => client.news.listArticles( type: type.code, id: id ?? 0, getRead: getRead ?? true ? 1 : 0, @@ -147,12 +140,12 @@ class NewsArticlesBloc extends InteractiveBloc implements NewsArticlesBlocEvents @override void markArticleAsRead(final NewsArticle article) { - wrapAction(() async => _client.news.markArticleAsRead(itemId: article.id)); + wrapAction(() async => client.news.markArticleAsRead(itemId: article.id)); } @override void markArticleAsUnread(final NewsArticle article) { - wrapAction(() async => _client.news.markArticleAsUnread(itemId: article.id)); + wrapAction(() async => client.news.markArticleAsUnread(itemId: article.id)); } @override @@ -162,11 +155,11 @@ class NewsArticlesBloc extends InteractiveBloc implements NewsArticlesBlocEvents @override void starArticle(final NewsArticle article) { - wrapAction(() async => _client.news.starArticle(itemId: article.id)); + wrapAction(() async => client.news.starArticle(itemId: article.id)); } @override void unstarArticle(final NewsArticle article) { - wrapAction(() async => _client.news.unstarArticle(itemId: article.id)); + wrapAction(() async => client.news.unstarArticle(itemId: article.id)); } } diff --git a/packages/neon/lib/src/apps/news/blocs/news.dart b/packages/neon/lib/src/apps/news/blocs/news.dart index 130ee71d..d2143138 100644 --- a/packages/neon/lib/src/apps/news/blocs/news.dart +++ b/packages/neon/lib/src/apps/news/blocs/news.dart @@ -1,11 +1,4 @@ -import 'dart:async'; - -import 'package:neon/src/apps/news/app.dart'; -import 'package:neon/src/apps/news/blocs/articles.dart'; -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../app.dart'; abstract class NewsBlocEvents { void addFeed(final String url, final int? folderId); @@ -51,9 +44,13 @@ class NewsBloc extends InteractiveBloc implements NewsBlocEvents, NewsBlocStates unawaited(mainArticlesBloc.refresh()); } + @override + NewsBloc get _newsBloc => this; @override final NewsAppSpecificOptions options; + @override final RequestManager requestManager; + @override final NextcloudClient client; late final mainArticlesBloc = NewsMainArticlesBloc( this, diff --git a/packages/neon/lib/src/apps/notes/app.dart b/packages/neon/lib/src/apps/notes/app.dart index 0432053e..6ba3fa6e 100644 --- a/packages/neon/lib/src/apps/notes/app.dart +++ b/packages/neon/lib/src/apps/notes/app.dart @@ -8,19 +8,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:neon/l10n/localizations.dart'; -import 'package:neon/src/apps/notes/blocs/note.dart'; -import 'package:neon/src/apps/notes/blocs/notes.dart'; -import 'package:neon/src/blocs/accounts.dart'; -import 'package:neon/src/blocs/apps.dart'; +import 'package:neon/src/models/account.dart'; import 'package:neon/src/neon.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:provider/provider.dart'; +import 'package:queue/queue.dart'; import 'package:rxdart/rxdart.dart'; import 'package:settings/settings.dart'; import 'package:sort_box/sort_box.dart'; import 'package:url_launcher/url_launcher_string.dart'; import 'package:wakelock/wakelock.dart'; +part 'blocs/note.dart'; +part 'blocs/notes.dart'; part 'dialogs/create_note.dart'; part 'dialogs/select_category.dart'; part 'options.dart'; diff --git a/packages/neon/lib/src/apps/notes/blocs/note.dart b/packages/neon/lib/src/apps/notes/blocs/note.dart index 0e7c3c26..2493dcd6 100644 --- a/packages/neon/lib/src/apps/notes/blocs/note.dart +++ b/packages/neon/lib/src/apps/notes/blocs/note.dart @@ -1,12 +1,4 @@ -import 'dart:async'; - -import 'package:flutter/cupertino.dart'; -import 'package:neon/src/apps/notes/app.dart'; -import 'package:neon/src/apps/notes/blocs/notes.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:queue/queue.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../app.dart'; abstract class NotesNoteBlocEvents { void updateContent(final String content); diff --git a/packages/neon/lib/src/apps/notes/blocs/notes.dart b/packages/neon/lib/src/apps/notes/blocs/notes.dart index 5ae07778..a71b70d6 100644 --- a/packages/neon/lib/src/apps/notes/blocs/notes.dart +++ b/packages/neon/lib/src/apps/notes/blocs/notes.dart @@ -1,10 +1,4 @@ -import 'dart:async'; - -import 'package:neon/src/apps/notes/app.dart'; -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../app.dart'; abstract class NotesBlocEvents { void createNote({ diff --git a/packages/neon/lib/src/apps/notifications/app.dart b/packages/neon/lib/src/apps/notifications/app.dart index 86a757d3..87f44a05 100644 --- a/packages/neon/lib/src/apps/notifications/app.dart +++ b/packages/neon/lib/src/apps/notifications/app.dart @@ -1,16 +1,17 @@ library notifications; +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:neon/l10n/localizations.dart'; -import 'package:neon/src/apps/notifications/blocs/notifications.dart'; -import 'package:neon/src/blocs/accounts.dart'; -import 'package:neon/src/blocs/apps.dart'; +import 'package:neon/src/models/account.dart'; import 'package:neon/src/neon.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:provider/provider.dart'; import 'package:rxdart/rxdart.dart'; +part 'blocs/notifications.dart'; part 'options.dart'; part 'pages/main.dart'; diff --git a/packages/neon/lib/src/apps/notifications/blocs/notifications.dart b/packages/neon/lib/src/apps/notifications/blocs/notifications.dart index 225bc408..68bd8857 100644 --- a/packages/neon/lib/src/apps/notifications/blocs/notifications.dart +++ b/packages/neon/lib/src/apps/notifications/blocs/notifications.dart @@ -1,10 +1,4 @@ -import 'dart:async'; - -import 'package:neon/src/apps/notifications/app.dart'; -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../app.dart'; abstract class NotificationsBlocEvents { void deleteNotification(final int id); diff --git a/packages/neon/lib/src/blocs/accounts.dart b/packages/neon/lib/src/blocs/accounts.dart index 605c88e6..bf494864 100644 --- a/packages/neon/lib/src/blocs/accounts.dart +++ b/packages/neon/lib/src/blocs/accounts.dart @@ -1,14 +1,4 @@ -import 'dart:async'; -import 'dart:convert'; - -import 'package:neon/src/blocs/apps.dart'; -import 'package:neon/src/blocs/capabilities.dart'; -import 'package:neon/src/blocs/user_details.dart'; -import 'package:neon/src/blocs/user_status.dart'; -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:rxdart/rxdart.dart'; -import 'package:shared_preferences/shared_preferences.dart'; +part of '../neon.dart'; abstract class AccountsBlocEvents { void addAccount(final Account account); diff --git a/packages/neon/lib/src/blocs/apps.dart b/packages/neon/lib/src/blocs/apps.dart index 3607506e..0f9bb6e1 100644 --- a/packages/neon/lib/src/blocs/apps.dart +++ b/packages/neon/lib/src/blocs/apps.dart @@ -1,12 +1,4 @@ -import 'dart:async'; - -import 'package:neon/src/apps/notifications/app.dart'; -import 'package:neon/src/blocs/accounts.dart'; -import 'package:neon/src/blocs/capabilities.dart'; -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../neon.dart'; typedef NextcloudApp = CoreNavigationApps_Ocs_Data; diff --git a/packages/neon/lib/src/blocs/capabilities.dart b/packages/neon/lib/src/blocs/capabilities.dart index 80db8116..6336142c 100644 --- a/packages/neon/lib/src/blocs/capabilities.dart +++ b/packages/neon/lib/src/blocs/capabilities.dart @@ -1,9 +1,4 @@ -import 'dart:async'; - -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../neon.dart'; typedef Capabilities = CoreServerCapabilities_Ocs_Data; typedef NextcloudTheme = CoreServerCapabilities_Ocs_Data_Capabilities_Theming; diff --git a/packages/neon/lib/src/blocs/login.dart b/packages/neon/lib/src/blocs/login.dart index ccce7bef..fff6b029 100644 --- a/packages/neon/lib/src/blocs/login.dart +++ b/packages/neon/lib/src/blocs/login.dart @@ -1,11 +1,4 @@ -import 'dart:async'; - -import 'package:flutter/foundation.dart'; -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:package_info_plus/package_info_plus.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../neon.dart'; abstract class LoginBlocEvents { void setServerURL(final String? url); diff --git a/packages/neon/lib/src/blocs/push_notifications.dart b/packages/neon/lib/src/blocs/push_notifications.dart index f459767a..e2022eca 100644 --- a/packages/neon/lib/src/blocs/push_notifications.dart +++ b/packages/neon/lib/src/blocs/push_notifications.dart @@ -1,12 +1,4 @@ -import 'dart:async'; - -import 'package:flutter/widgets.dart'; -import 'package:neon/src/blocs/accounts.dart'; -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:unifiedpush/unifiedpush.dart'; +part of '../neon.dart'; abstract class PushNotificationsBlocEvents {} diff --git a/packages/neon/lib/src/blocs/user_details.dart b/packages/neon/lib/src/blocs/user_details.dart index 17d560b5..6aef6282 100644 --- a/packages/neon/lib/src/blocs/user_details.dart +++ b/packages/neon/lib/src/blocs/user_details.dart @@ -1,9 +1,4 @@ -import 'dart:async'; - -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:rxdart/rxdart.dart'; +part of '../neon.dart'; abstract class UserDetailsBlocEvents {} diff --git a/packages/neon/lib/src/blocs/user_status.dart b/packages/neon/lib/src/blocs/user_status.dart index b53c0116..b1793b95 100644 --- a/packages/neon/lib/src/blocs/user_status.dart +++ b/packages/neon/lib/src/blocs/user_status.dart @@ -1,10 +1,4 @@ -import 'dart:async'; - -import 'package:neon/src/models/account.dart'; -import 'package:neon/src/neon.dart'; -import 'package:nextcloud/nextcloud.dart'; -import 'package:rxdart/rxdart.dart'; -import 'package:window_manager/window_manager.dart'; +part of '../neon.dart'; abstract class UserStatusBlocEvents {} diff --git a/packages/neon/lib/src/neon.dart b/packages/neon/lib/src/neon.dart index 49410301..b055d96c 100644 --- a/packages/neon/lib/src/neon.dart +++ b/packages/neon/lib/src/neon.dart @@ -24,13 +24,6 @@ import 'package:neon/src/apps/files/app.dart'; import 'package:neon/src/apps/news/app.dart'; import 'package:neon/src/apps/notes/app.dart'; import 'package:neon/src/apps/notifications/app.dart'; -import 'package:neon/src/apps/notifications/blocs/notifications.dart'; -import 'package:neon/src/blocs/accounts.dart'; -import 'package:neon/src/blocs/apps.dart'; -import 'package:neon/src/blocs/capabilities.dart'; -import 'package:neon/src/blocs/login.dart'; -import 'package:neon/src/blocs/user_details.dart'; -import 'package:neon/src/blocs/user_status.dart'; import 'package:neon/src/models/account.dart'; import 'package:neon/src/models/push_notification_with_account.dart'; import 'package:nextcloud/nextcloud.dart'; @@ -47,12 +40,20 @@ import 'package:sort_box/sort_box.dart'; import 'package:sqflite/sqflite.dart'; import 'package:sqflite_common_ffi/sqflite_ffi.dart'; import 'package:tray_manager/tray_manager.dart' as tray; +import 'package:unifiedpush/unifiedpush.dart'; import 'package:url_launcher/url_launcher_string.dart'; import 'package:webview_flutter/webview_flutter.dart'; import 'package:window_manager/window_manager.dart'; import 'package:xdg_directories/xdg_directories.dart' as xdg; part 'app.dart'; +part 'blocs/accounts.dart'; +part 'blocs/apps.dart'; +part 'blocs/capabilities.dart'; +part 'blocs/login.dart'; +part 'blocs/push_notifications.dart'; +part 'blocs/user_details.dart'; +part 'blocs/user_status.dart'; part 'pages/account_settings.dart'; part 'pages/home.dart'; part 'pages/login.dart';