mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-07 01:15:50 -06:00
feat: extract snippets into widgets, code cleanup document details
This commit is contained in:
@@ -7,6 +7,8 @@ import 'package:open_filex/open_filex.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/notifier/document_changed_notifier.dart';
|
||||
import 'package:paperless_mobile/core/service/file_service.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
part 'document_details_state.dart';
|
||||
|
||||
@@ -73,6 +75,24 @@ class DocumentDetailsCubit extends Cubit<DocumentDetailsState> {
|
||||
emit(state.copyWith(document: document));
|
||||
}
|
||||
|
||||
Future<void> shareDocument() async {
|
||||
final documentBytes = await _api.download(state.document);
|
||||
final dir = await getTemporaryDirectory();
|
||||
final String path = "${dir.path}/${state.document.originalFileName}";
|
||||
await File(path).writeAsBytes(documentBytes);
|
||||
Share.shareXFiles(
|
||||
[
|
||||
XFile(
|
||||
path,
|
||||
name: state.document.originalFileName,
|
||||
mimeType: "application/pdf",
|
||||
lastModified: state.document.modified,
|
||||
),
|
||||
],
|
||||
subject: state.document.title,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() {
|
||||
for (final element in _subscriptions) {
|
||||
|
||||
Reference in New Issue
Block a user