Added open in system viewer, updated translations.

This commit is contained in:
Anton Stubenbord
2023-01-21 01:20:33 +01:00
parent 2e0730ce2f
commit 78aefb05eb
18 changed files with 201 additions and 89 deletions

View File

@@ -7,6 +7,7 @@ import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/service/file_service.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:open_filex/open_filex.dart';
part 'document_details_state.dart';
@@ -47,21 +48,14 @@ class DocumentDetailsCubit extends Cubit<DocumentDetailsState> {
}
}
Future<bool> openDocumentInSystemViewer() async {
Future<ResultType> openDocumentInSystemViewer() async {
final downloadDir = await FileService.temporaryDirectory;
final metaData = await _api.getMetaData(state.document);
final docBytes = await _api.download(state.document);
File f = File('${downloadDir.path}/${metaData.mediaFilename}');
f.writeAsBytes(docBytes);
final url = Uri(
scheme: "file",
path: f.path,
);
log(url.toString());
if (await canLaunchUrl(url)) {
return launchUrl(url);
}
return false;
return OpenFilex.open(f.path, type: "application/pdf")
.then((value) => value.type);
}
void replaceDocument(DocumentModel document) {