mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-13 12:12:20 -06:00
Added open in system viewer, updated translations.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user