Browse Source

refactor(neon,neon_files,neon_news,neon_notes,neon_notifications): remove SharedPreferences reference

Signed-off-by: Nikolas Rimikis <rimikis.nikolas@gmail.com>
pull/654/head
Nikolas Rimikis 1 year ago
parent
commit
c323c707c8
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/app/integration_test/screenshot_test.dart
  2. 16
      packages/app/lib/apps.dart
  3. 2
      packages/app/lib/main.dart
  4. 12
      packages/app/pubspec.lock
  5. 3
      packages/app/pubspec.yaml
  6. 11
      packages/neon/neon/lib/neon.dart
  7. 5
      packages/neon/neon/lib/src/models/app_implementation.dart
  8. 2
      packages/neon/neon/lib/src/models/notifications_interface.dart
  9. 2
      packages/neon/neon_files/lib/neon_files.dart
  10. 2
      packages/neon/neon_news/lib/neon_news.dart
  11. 2
      packages/neon/neon_notes/lib/neon_notes.dart
  12. 2
      packages/neon/neon_notifications/lib/neon_notifications.dart

2
packages/app/integration_test/screenshot_test.dart

@ -20,7 +20,7 @@ Future runTestApp(
final Account? account,
}) async {
await runNeon(
getAppImplementations: getAppImplementations,
appImplementations: appImplementations,
theme: neonTheme,
bindingOverride: binding,
account: account,

16
packages/app/lib/apps.dart

@ -3,14 +3,10 @@ import 'package:neon_files/neon_files.dart';
import 'package:neon_news/neon_news.dart';
import 'package:neon_notes/neon_notes.dart';
import 'package:neon_notifications/neon_notifications.dart';
import 'package:shared_preferences/shared_preferences.dart';
List<AppImplementation> getAppImplementations(
final SharedPreferences sharedPreferences,
) =>
[
FilesApp(sharedPreferences),
NewsApp(sharedPreferences),
NotesApp(sharedPreferences),
NotificationsApp(sharedPreferences),
];
final List<AppImplementation> appImplementations = [
FilesApp(),
NewsApp(),
NotesApp(),
NotificationsApp(),
];

2
packages/app/lib/main.dart

@ -4,7 +4,7 @@ import 'package:neon/neon.dart';
Future main() async {
await runNeon(
getAppImplementations: getAppImplementations,
appImplementations: appImplementations,
theme: neonTheme,
);
}

12
packages/app/pubspec.lock

@ -349,10 +349,10 @@ packages:
dependency: transitive
description:
name: flutter_local_notifications
sha256: "3cc40fe8c50ab8383f3e053a499f00f975636622ecdc8e20a77418ece3b1e975"
sha256: "3002092e5b8ce2f86c3361422e52e6db6776c23ee21e0b2f71b892bf4259ef04"
url: "https://pub.dev"
source: hosted
version: "15.1.0+1"
version: "15.1.1"
flutter_local_notifications_linux:
dependency: transitive
description:
@ -383,7 +383,7 @@ packages:
source: hosted
version: "0.6.17+1"
flutter_native_splash:
dependency: "direct main"
dependency: transitive
description:
name: flutter_native_splash
sha256: ecff62b3b893f2f665de7e4ad3de89f738941fcfcaaba8ee601e749efafa4698
@ -1044,7 +1044,7 @@ packages:
source: hosted
version: "3.3.0"
shared_preferences:
dependency: "direct main"
dependency: "direct dev"
description:
name: shared_preferences
sha256: "0344316c947ffeb3a529eac929e1978fcd37c26be4e8468628bac399365a3ca1"
@ -1443,10 +1443,10 @@ packages:
dependency: transitive
description:
name: webview_flutter
sha256: "789d52bd789373cc1e100fb634af2127e86c99cf9abde09499743270c5de8d00"
sha256: "04a0782fb058b7c71f2048935583488f4d32e9147ca403abc4e58f1de9964629"
url: "https://pub.dev"
source: hosted
version: "4.2.2"
version: "4.2.3"
webview_flutter_android:
dependency: transitive
description:

3
packages/app/pubspec.yaml

@ -9,7 +9,6 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_native_splash: ^2.3.2
flutter_svg: ^2.0.7
neon:
git:
@ -31,7 +30,6 @@ dependencies:
git:
url: https://github.com/nextcloud/neon
path: packages/neon/neon_notifications
shared_preferences: ^2.2.0
dev_dependencies:
flutter_test:
@ -43,6 +41,7 @@ dev_dependencies:
git:
url: https://github.com/nextcloud/neon
path: packages/neon_lints
shared_preferences: ^2.2.0
flutter:
uses-material-design: true

11
packages/neon/neon/lib/neon.dart

@ -17,10 +17,9 @@ import 'package:neon/src/utils/request_manager.dart';
import 'package:neon/src/utils/user_agent.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
Future runNeon({
required final Iterable<AppImplementation> Function(SharedPreferences) getAppImplementations,
required final Iterable<AppImplementation> appImplementations,
required final NeonTheme theme,
@visibleForTesting final WidgetsBinding? bindingOverride,
@visibleForTesting final Account? account,
@ -30,14 +29,10 @@ Future runNeon({
final binding = bindingOverride ?? WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.preserve(widgetsBinding: binding);
final sharedPreferences = await SharedPreferences.getInstance();
await NeonPlatform.setup();
await RequestManager.instance.initCache();
await AppStorage.init();
final allAppImplementations = getAppImplementations(sharedPreferences);
final packageInfo = await PackageInfo.fromPlatform();
buildUserAgent(packageInfo);
@ -47,7 +42,7 @@ Future runNeon({
final accountsBloc = AccountsBloc(
globalOptions,
allAppImplementations,
appImplementations,
);
if (account != null) {
accountsBloc
@ -86,7 +81,7 @@ Future runNeon({
create: (final _) => nextPushBloc,
),
Provider<Iterable<AppImplementation>>(
create: (final _) => allAppImplementations,
create: (final _) => appImplementations,
),
Provider<PackageInfo>(
create: (final _) => packageInfo,

5
packages/neon/neon/lib/src/models/app_implementation.dart

@ -11,12 +11,9 @@ import 'package:neon/src/settings/models/storage.dart';
import 'package:neon/src/widgets/drawer_destination.dart';
import 'package:provider/provider.dart';
import 'package:rxdart/rxdart.dart';
import 'package:shared_preferences/shared_preferences.dart';
abstract class AppImplementation<T extends Bloc, R extends NextcloudAppOptions> {
AppImplementation(
final SharedPreferences sharedPreferences,
) {
AppImplementation() {
final storage = AppStorage('app-$id');
options = buildOptions(storage);
}

2
packages/neon/neon/lib/src/models/notifications_interface.dart

@ -4,7 +4,7 @@ import 'package:neon/src/settings/models/nextcloud_app_options.dart';
abstract interface class NotificationsAppInterface<T extends NotificationsBlocInterface,
R extends NotificationsOptionsInterface> extends AppImplementation<T, R> {
NotificationsAppInterface(super.sharedPreferences);
NotificationsAppInterface();
}
abstract interface class NotificationsBlocInterface extends InteractiveBloc {

2
packages/neon/neon_files/lib/neon_files.dart

@ -44,7 +44,7 @@ part 'widgets/browser_view.dart';
part 'widgets/file_preview.dart';
class FilesApp extends AppImplementation<FilesBloc, FilesAppSpecificOptions> {
FilesApp(super.sharedPreferences);
FilesApp();
@override
String id = AppIDs.files;

2
packages/neon/neon_news/lib/neon_news.dart

@ -52,7 +52,7 @@ part 'widgets/folder_view.dart';
part 'widgets/folders_view.dart';
class NewsApp extends AppImplementation<NewsBloc, NewsAppSpecificOptions> {
NewsApp(super.sharedPreferences);
NewsApp();
@override
String id = AppIDs.news;

2
packages/neon/neon_notes/lib/neon_notes.dart

@ -42,7 +42,7 @@ part 'widgets/notes_floating_action_button.dart';
part 'widgets/notes_view.dart';
class NotesApp extends AppImplementation<NotesBloc, NotesAppSpecificOptions> {
NotesApp(super.sharedPreferences);
NotesApp();
@override
String id = AppIDs.notes;

2
packages/neon/neon_notifications/lib/neon_notifications.dart

@ -22,7 +22,7 @@ part 'pages/main.dart';
class NotificationsApp extends AppImplementation<NotificationsBloc, NotificationsAppSpecificOptions>
implements NotificationsAppInterface<NotificationsBloc, NotificationsAppSpecificOptions> {
NotificationsApp(super.sharedPreferences);
NotificationsApp();
@override
String id = AppIDs.notifications;

Loading…
Cancel
Save