pdf, and png preview
This commit is contained in:
parent
8ae776c92f
commit
6beda384e1
@ -3,6 +3,7 @@ import "dart:typed_data";
|
||||
import "package:crab_ui/structs.dart";
|
||||
import "package:flutter/material.dart";
|
||||
import 'package:pdfrx/pdfrx.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
|
||||
class AttachmentWidget extends StatelessWidget {
|
||||
final AttachmentResponse attachment;
|
||||
@ -13,25 +14,24 @@ class AttachmentWidget extends StatelessWidget {
|
||||
.toString()
|
||||
.substring(att.name.toString().indexOf(".") + 1)
|
||||
.toLowerCase();
|
||||
if (extension == "jpg") {
|
||||
if (extension == "jpg" || extension == "png") {
|
||||
return Image.memory(att.data);
|
||||
} else if (extension == "pdf") {
|
||||
PdfViewer pdf = PdfViewer.data(
|
||||
Uint8List.fromList(att.data),
|
||||
sourceName: att.name,
|
||||
params: const PdfViewerParams(
|
||||
enableTextSelection: true,
|
||||
scrollByMouseWheel: 0.5,
|
||||
)
|
||||
);
|
||||
|
||||
return pdf;
|
||||
return PdfViewer.data(Uint8List.fromList(att.data),
|
||||
sourceName: att.name,
|
||||
params: PdfViewerParams(
|
||||
enableTextSelection: true,
|
||||
scrollByMouseWheel: 0.5,
|
||||
annotationRenderingMode:
|
||||
PdfAnnotationRenderingMode.annotationAndForms,
|
||||
));
|
||||
}
|
||||
return Text(
|
||||
return Center(
|
||||
child: Text(
|
||||
"Attachment not supported for preview, you'll need to download",
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 20, decoration: TextDecoration.none),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -20,10 +20,13 @@ dependencies:
|
||||
mime: ^1.0.3
|
||||
pointer_interceptor: ^0.10.1+2
|
||||
file_saver: ^0.2.14
|
||||
|
||||
|
||||
english_words: ^4.0.0
|
||||
provider: ^6.0.0
|
||||
intl: ^0.19.0
|
||||
pdfrx: ^1.0.94
|
||||
photo_view: ^0.15.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Loading…
Reference in New Issue
Block a user