TF-2764 Add PDFViewer to preview PDF attachment

This commit is contained in:
dab246
2024-05-17 02:19:00 +07:00
committed by Dat H. Pham
parent 89a489eb06
commit 7524a97bc8
25 changed files with 1018 additions and 111 deletions
+2 -1
View File
@@ -13,4 +13,5 @@ linter:
rules:
constant_identifier_names: false
non_constant_identifier_names: false
unnecessary_string_escapes: false
unnecessary_string_escapes: false
avoid_web_libraries_in_flutter: false
+2
View File
@@ -4,4 +4,6 @@ class Constant {
static const pdfMimeType = 'application/pdf';
static const textHtmlMimeType = 'text/html';
static const octetStreamMimeType = 'application/octet-stream';
static const pdfExtension = '.pdf';
static const imageType = 'image';
}
@@ -3,8 +3,6 @@ import 'package:core/domain/preview/supported_preview_file_types.dart';
import 'package:http_parser/http_parser.dart';
extension MediaTypeExtension on MediaType {
static const String imageType = 'image';
bool isAndroidSupportedPreview() => SupportedPreviewFileTypes.androidSupportedTypes.contains(mimeType);
bool isIOSSupportedPreview() => SupportedPreviewFileTypes.iOSSupportedTypes.containsKey(mimeType);
@@ -216,10 +216,6 @@ class ImagePaths {
return AssetsPaths.images + imageName;
}
String _getIconPath(String iconName) {
return AssetsPaths.icons + iconName;
}
String getConfigurationImagePath(String imageName) {
return AssetsPaths.configurationImages + imageName;
}
@@ -75,7 +75,7 @@ class _TextFieldFormBuilderState extends State<TextFormFieldBuilder> {
@override
Widget build(BuildContext context) {
return TextFormField(
return TextField(
key: widget.key,
controller: _controller,
cursorColor: widget.cursorColor,
@@ -105,7 +105,7 @@ class _TextFieldFormBuilderState extends State<TextFormFieldBuilder> {
}
}
},
onFieldSubmitted: widget.onTextSubmitted,
onSubmitted: widget.onTextSubmitted,
onTap: widget.onTap,
);
}
+9 -1
View File
@@ -1,5 +1,5 @@
import 'dart:async';
import 'dart:typed_data';
import 'package:core/data/model/print_attachment.dart';
import 'package:core/utils/app_logger.dart';
@@ -8,8 +8,16 @@ import 'package:core/utils/html/html_template.dart';
import 'package:core/utils/html/html_utils.dart';
import 'package:html/dom.dart';
import 'package:html/parser.dart';
import 'package:printing/printing.dart';
class PrintUtils {
Future<void> printPDFFile(Uint8List bytes, String fileName) async {
await Printing.layoutPdf(
name: fileName,
onLayout: (_) => bytes);
}
Element? _createUserInformationElement({
required String appName,
required String userName,
+72
View File
@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
sha256: ecf4273855368121b1caed0d10d4513c7241dfc813f7d3c8933b36622ae9b265
url: "https://pub.dev"
source: hosted
version: "3.5.1"
args:
dependency: transitive
description:
@@ -17,6 +25,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.11.0"
barcode:
dependency: transitive
description:
name: barcode
sha256: ab180ce22c6555d77d45f0178a523669db67f95856e3378259ef2ffeb43e6003
url: "https://pub.dev"
source: hosted
version: "2.2.8"
bidi:
dependency: transitive
description:
name: bidi
sha256: "1a7d0c696324b2089f72e7671fd1f1f64fef44c980f3cebc84e803967c597b63"
url: "https://pub.dev"
source: hosted
version: "2.0.10"
boolean_selector:
dependency: transitive
description:
@@ -73,6 +97,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.3.3+7"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
csslib:
dependency: transitive
description:
@@ -344,6 +376,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
image:
dependency: transitive
description:
name: image
sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e"
url: "https://pub.dev"
source: hosted
version: "4.1.7"
intl:
dependency: "direct main"
description:
@@ -464,6 +504,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.2.1"
pdf:
dependency: transitive
description:
name: pdf
sha256: "243f05342fc0bdf140eba5b069398985cdbdd3dbb1d776cf43d5ea29cc570ba6"
url: "https://pub.dev"
source: hosted
version: "3.10.8"
pdf_widget_wrapper:
dependency: transitive
description:
name: pdf_widget_wrapper
sha256: e9d31fd7782ce28ae346b127ea7d1cd748d799bddee379f31191693610e23749
url: "https://pub.dev"
source: hosted
version: "1.0.1"
petitparser:
dependency: transitive
description:
@@ -496,6 +552,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.9.1"
printing:
dependency: "direct main"
description:
name: printing
sha256: "1c99cab90ebcc1fff65831d264627d5b529359d563e53f33ab9b8117f2d280bc"
url: "https://pub.dev"
source: hosted
version: "5.12.0"
qr:
dependency: transitive
description:
name: qr
sha256: "64957a3930367bf97cc211a5af99551d630f2f4625e38af10edd6b19131b64b3"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
sky_engine:
dependency: transitive
description: flutter
+2
View File
@@ -73,6 +73,8 @@ dependencies:
linkify: 5.0.0
printing: 5.12.0
dev_dependencies:
flutter_test:
sdk: flutter