fix: Adapt to new provider strucutre

This commit is contained in:
Anton Stubenbord
2023-05-11 12:37:17 +02:00
parent d5c68e023c
commit f388f77d63
43 changed files with 540 additions and 1254 deletions

View File

@@ -1,26 +1,19 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/notifier/document_changed_notifier.dart';
import 'package:paperless_mobile/core/repository/label_repository.dart';
import 'package:paperless_mobile/features/document_details/cubit/document_details_cubit.dart';
import 'package:paperless_mobile/features/document_details/view/pages/document_details_page.dart';
import 'package:paperless_mobile/features/notifications/services/local_notification_service.dart';
import 'package:provider/provider.dart';
class DocumentDetailsRoute extends StatelessWidget {
final DocumentModel document;
final bool isLabelClickable;
final bool allowEdit;
final String? titleAndContentQueryString;
const DocumentDetailsRoute({
super.key,
required this.document,
this.isLabelClickable = true,
this.allowEdit = true,
this.titleAndContentQueryString,
});
@@ -36,7 +29,6 @@ class DocumentDetailsRoute extends StatelessWidget {
),
lazy: false,
child: DocumentDetailsPage(
allowEdit: allowEdit,
isLabelClickable: isLabelClickable,
titleAndContentQueryString: titleAndContentQueryString,
),
@@ -57,33 +49,3 @@ class DocumentDetailsRouteArguments {
this.titleAndContentQueryString,
});
}
Future<void> pushDocumentDetailsRoute(
BuildContext context, {
required DocumentModel document,
bool isLabelClickable = true,
bool allowEdit = true,
String? titleAndContentQueryString,
}) {
final LabelRepository labelRepository = context.read();
final DocumentChangedNotifier changeNotifier = context.read();
final PaperlessDocumentsApi documentsApi = context.read();
final LocalNotificationService notificationservice = context.read();
final CacheManager cacheManager = context.read();
return Navigator.of(context).push(MaterialPageRoute(
builder: (_) => MultiProvider(
providers: [
Provider.value(value: documentsApi),
Provider.value(value: labelRepository),
Provider.value(value: changeNotifier),
Provider.value(value: notificationservice),
Provider.value(value: cacheManager),
],
child: DocumentDetailsRoute(
document: document,
allowEdit: allowEdit,
isLabelClickable: isLabelClickable,
),
),
));
}