HyM attachments resolve: #2 #3
@ -1,59 +1,62 @@
|
|||||||
import "package:crab_ui/structs.dart";
|
import "package:crab_ui/structs.dart";
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
|
import 'package:pdfrx/pdfrx.dart';
|
||||||
|
|
||||||
class AttachmentWidget extends StatelessWidget {
|
class AttachmentWidget extends StatelessWidget {
|
||||||
final AttachmentResponse attachment;
|
final AttachmentResponse attachment;
|
||||||
AttachmentWidget({required this.attachment});
|
AttachmentWidget({required this.attachment});
|
||||||
|
|
||||||
|
Widget attachmentViewer(AttachmentResponse att) {
|
||||||
|
String extension = att.name
|
||||||
|
.toString()
|
||||||
|
.substring(att.name.toString().indexOf(".") + 1)
|
||||||
|
.toLowerCase();
|
||||||
|
if (extension == "jpg") {
|
||||||
|
return Image.memory(att.data);
|
||||||
|
} else if (extension == "pdf") {
|
||||||
|
return PdfViewer.data(att.data, sourceName: att.name);
|
||||||
|
}
|
||||||
|
return Text(
|
||||||
|
"Attachment not supported for preview, you'll need to download",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.black, fontSize: 20, decoration: TextDecoration.none),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
color: Colors.black38,
|
color: Colors.black38,
|
||||||
child: Stack(
|
child: Stack(children: <Widget>[
|
||||||
// appBar: AppBar(title: Text('New Tab Content')),
|
|
||||||
children: <Widget> [
|
|
||||||
|
|
||||||
Container(
|
Container(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.fromLTRB(10, 20, 0, 10),
|
padding: EdgeInsets.fromLTRB(10, 20, 0, 10),
|
||||||
child: Row(
|
child: Column(
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
CloseButton(
|
Row(
|
||||||
onPressed: () => {
|
children: [
|
||||||
Navigator.pop(context)
|
CloseButton(onPressed: () => {Navigator.pop(context)}),
|
||||||
}
|
|
||||||
),
|
|
||||||
Text(
|
Text(
|
||||||
attachment.name.toString(), //its alr a string but incase ¯\(ツ)/¯
|
attachment.name
|
||||||
|
.toString(), //its alr a string but incase ¯\(ツ)/¯
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
decoration: TextDecoration.none
|
decoration:
|
||||||
), //TODO: personalize your fonts
|
TextDecoration.none), //TODO: personalize your fonts
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
Expanded(
|
||||||
Center(
|
|
||||||
child: Column(
|
child: attachmentViewer(attachment),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: 1000,
|
|
||||||
height: 600,
|
|
||||||
child: Image.memory(attachment.data),
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -309,7 +309,6 @@ class AugmentClasses {
|
|||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => AttachmentWidget(attachment: file)));
|
builder: (context) => AttachmentWidget(attachment: file)));
|
||||||
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
return listOfFiles;
|
return listOfFiles;
|
||||||
|
Loading…
Reference in New Issue
Block a user