add expanded file viewer
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:patient_manager/main.dart';
|
||||||
|
import 'package:syncfusion_flutter_core/theme.dart';
|
||||||
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
|
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
|
||||||
|
import "package:universal_html/html.dart" as html;
|
||||||
|
|
||||||
class BuildFileView extends StatefulWidget {
|
class BuildFileView extends StatefulWidget {
|
||||||
final String link;
|
final String link;
|
||||||
@@ -17,33 +20,259 @@ class BuildFileView extends StatefulWidget {
|
|||||||
class _BuildFileViewState extends State<BuildFileView> {
|
class _BuildFileViewState extends State<BuildFileView> {
|
||||||
late PdfViewerController pdfViewerController = PdfViewerController();
|
late PdfViewerController pdfViewerController = PdfViewerController();
|
||||||
|
|
||||||
String getExtType(String path) {
|
void expandFile(double width, double height) {
|
||||||
//print(pdfLink.split(".")[1]);
|
showDialog(
|
||||||
return path.split(".").last;
|
context: context,
|
||||||
}
|
builder: (context) {
|
||||||
|
return Stack(
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (getExtType(widget.path).toLowerCase() == "pdf") {
|
|
||||||
//print(widget.pdfLink);
|
|
||||||
return SizedBox(
|
|
||||||
width: 700,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.only(top: 20.0),
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
//borderRadius: BorderRadius.circular(25.0),
|
||||||
|
// border: Border.all(
|
||||||
|
// color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
|
// width: 5.0),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
getFileName(widget.path),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
child: SfPdfViewerTheme(
|
||||||
|
data: SfPdfViewerThemeData(
|
||||||
|
backgroundColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
),
|
||||||
child: SfPdfViewer.network(
|
child: SfPdfViewer.network(
|
||||||
widget.link,
|
widget.link,
|
||||||
controller: pdfViewerController,
|
controller: pdfViewerController,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 5,
|
||||||
|
left: 2,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
child: IconButton.filled(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.fullscreen_exit,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
size: 35,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 5,
|
||||||
|
right: 2,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
child: IconButton.filled(
|
||||||
|
onPressed: () {
|
||||||
|
html.window.open(
|
||||||
|
widget.link,
|
||||||
|
// '${AppEnviroment.baseFileUrl}/mih/$filePath',
|
||||||
|
'download');
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.download,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
size: 35,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
} else {
|
},
|
||||||
return InteractiveViewer(
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void expandImage(double width, double height) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.only(top: 20.0),
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
//borderRadius: BorderRadius.circular(25.0),
|
||||||
|
// border: Border.all(
|
||||||
|
// color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
|
// width: 5.0),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
getFileName(widget.path),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Expanded(
|
||||||
|
child: InteractiveViewer(
|
||||||
maxScale: 5.0,
|
maxScale: 5.0,
|
||||||
//minScale: 0.,
|
//minScale: 0.,
|
||||||
child: Image.network(widget.link),
|
child: Image.network(widget.link),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 5,
|
||||||
|
left: 2,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
child: IconButton.filled(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.fullscreen_exit,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
size: 35,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 5,
|
||||||
|
right: 2,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
child: IconButton.filled(
|
||||||
|
onPressed: () {
|
||||||
|
html.window.open(
|
||||||
|
widget.link,
|
||||||
|
// '${AppEnviroment.baseFileUrl}/mih/$filePath',
|
||||||
|
'download');
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.download,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
size: 35,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String getExtType(String path) {
|
||||||
|
//print(pdfLink.split(".")[1]);
|
||||||
|
return path.split(".").last;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getFileName(String path) {
|
||||||
|
//print(pdfLink.split(".")[1]);
|
||||||
|
return path.split("/").last;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
double width = MediaQuery.sizeOf(context).width;
|
||||||
|
double height = MediaQuery.sizeOf(context).height;
|
||||||
|
if (getExtType(widget.path).toLowerCase() == "pdf") {
|
||||||
|
//print(widget.pdfLink);
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SfPdfViewerTheme(
|
||||||
|
data: SfPdfViewerThemeData(
|
||||||
|
backgroundColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
),
|
||||||
|
child: SfPdfViewer.network(
|
||||||
|
widget.link,
|
||||||
|
controller: pdfViewerController,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 5,
|
||||||
|
right: 5,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
child: IconButton.filled(
|
||||||
|
onPressed: () {
|
||||||
|
expandFile(width, height);
|
||||||
|
//Navigator.pop(context);
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.fullscreen,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
size: 35,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: InteractiveViewer(
|
||||||
|
maxScale: 5.0,
|
||||||
|
//minScale: 0.,
|
||||||
|
child: Image.network(widget.link),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 5,
|
||||||
|
right: 5,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
child: IconButton.filled(
|
||||||
|
onPressed: () {
|
||||||
|
expandImage(width, height);
|
||||||
|
//Navigator.pop(context);
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.fullscreen,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
size: 35,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user