From d97c9f80fac9fd829508f2d9751fc6eb52e21db5 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Tue, 29 Aug 2023 17:13:35 +0200 Subject: [PATCH] refactor(neon): generalize OptionsCollection Signed-off-by: Nikolas Rimikis --- packages/neon/neon/lib/settings.dart | 2 +- packages/neon/neon/lib/src/blocs/apps.dart | 2 +- .../lib/src/models/app_implementation.dart | 2 +- .../src/models/notifications_interface.dart | 2 +- .../settings/models/options_collection.dart | 48 +++++++++++++++++++ .../neon/lib/src/utils/account_options.dart | 21 ++------ .../neon/lib/src/utils/global_options.dart | 43 +++++++---------- .../lib/src/utils/settings_export_helper.dart | 2 +- 8 files changed, 76 insertions(+), 46 deletions(-) create mode 100644 packages/neon/neon/lib/src/settings/models/options_collection.dart diff --git a/packages/neon/neon/lib/settings.dart b/packages/neon/neon/lib/settings.dart index 13193417..08d29b5c 100644 --- a/packages/neon/neon/lib/settings.dart +++ b/packages/neon/neon/lib/settings.dart @@ -1,6 +1,6 @@ export 'package:neon/src/models/label_builder.dart'; -export 'package:neon/src/settings/models/nextcloud_app_options.dart'; export 'package:neon/src/settings/models/options_category.dart'; +export 'package:neon/src/settings/models/options_collection.dart'; export 'package:neon/src/settings/models/select_option.dart'; export 'package:neon/src/settings/models/storage.dart' show Storable; export 'package:neon/src/settings/models/toggle_option.dart'; diff --git a/packages/neon/neon/lib/src/blocs/apps.dart b/packages/neon/neon/lib/src/blocs/apps.dart index b0586b37..6f35a3ec 100644 --- a/packages/neon/neon/lib/src/blocs/apps.dart +++ b/packages/neon/neon/lib/src/blocs/apps.dart @@ -10,7 +10,7 @@ import 'package:neon/src/models/account.dart'; import 'package:neon/src/models/app_ids.dart'; import 'package:neon/src/models/app_implementation.dart'; import 'package:neon/src/models/notifications_interface.dart'; -import 'package:neon/src/settings/models/nextcloud_app_options.dart'; +import 'package:neon/src/settings/models/options_collection.dart'; import 'package:neon/src/utils/request_manager.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:provider/provider.dart'; diff --git a/packages/neon/neon/lib/src/models/app_implementation.dart b/packages/neon/neon/lib/src/models/app_implementation.dart index 1051a571..4c50508c 100644 --- a/packages/neon/neon/lib/src/models/app_implementation.dart +++ b/packages/neon/neon/lib/src/models/app_implementation.dart @@ -7,7 +7,7 @@ import 'package:neon/l10n/localizations.dart'; import 'package:neon/src/bloc/bloc.dart'; import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/models/account.dart'; -import 'package:neon/src/settings/models/nextcloud_app_options.dart'; +import 'package:neon/src/settings/models/options_collection.dart'; import 'package:neon/src/settings/models/storage.dart'; import 'package:neon/src/widgets/drawer_destination.dart'; import 'package:provider/provider.dart'; diff --git a/packages/neon/neon/lib/src/models/notifications_interface.dart b/packages/neon/neon/lib/src/models/notifications_interface.dart index 7164dc24..abcc1356 100644 --- a/packages/neon/neon/lib/src/models/notifications_interface.dart +++ b/packages/neon/neon/lib/src/models/notifications_interface.dart @@ -1,7 +1,7 @@ import 'package:meta/meta.dart'; import 'package:neon/src/bloc/bloc.dart'; import 'package:neon/src/models/app_implementation.dart'; -import 'package:neon/src/settings/models/nextcloud_app_options.dart'; +import 'package:neon/src/settings/models/options_collection.dart'; abstract interface class NotificationsAppInterface extends AppImplementation { diff --git a/packages/neon/neon/lib/src/settings/models/options_collection.dart b/packages/neon/neon/lib/src/settings/models/options_collection.dart new file mode 100644 index 00000000..a981ad31 --- /dev/null +++ b/packages/neon/neon/lib/src/settings/models/options_collection.dart @@ -0,0 +1,48 @@ +import 'package:meta/meta.dart'; +import 'package:neon/src/settings/models/option.dart'; +import 'package:neon/src/settings/models/options_category.dart'; +import 'package:neon/src/settings/models/storage.dart'; + +/// Collection of [Option]s. +abstract class OptionsCollection { + OptionsCollection(this.storage); + + /// Storage backend to use. + @protected + final SettingsStorage storage; + + /// Collection of options. + @protected + Iterable