feat: enhance receipt import functionality with category selection and PDF opening support

This commit is contained in:
Nils-Johan Gynther
2026-05-01 22:46:58 +02:00
parent 5c263a14df
commit 4cbd658fa0
7 changed files with 440 additions and 68 deletions
+6
View File
@@ -0,0 +1,6 @@
import 'dart:typed_data';
import 'pdf_opener_stub.dart'
if (dart.library.js_interop) 'pdf_opener_web.dart' as impl;
Future<bool> openPdfBytes(Uint8List bytes) => impl.openPdfBytes(bytes);
@@ -0,0 +1,3 @@
import 'dart:typed_data';
Future<bool> openPdfBytes(Uint8List bytes) async => false;
@@ -0,0 +1,19 @@
import 'dart:js_interop';
import 'dart:typed_data';
import 'package:web/web.dart' as web;
Future<bool> openPdfBytes(Uint8List bytes) async {
final blob = web.Blob(
[bytes.toJS].toJS,
web.BlobPropertyBag(type: 'application/pdf'),
);
final url = web.URL.createObjectURL(blob);
final openedWindow = web.window.open(url, '_blank', 'noopener,noreferrer');
if (openedWindow == null) {
web.URL.revokeObjectURL(url);
return false;
}
web.URL.revokeObjectURL(url);
return true;
}