improve pdf full screen viewer
This commit is contained in:
@@ -64,7 +64,7 @@ class _BuildFileViewState extends State<BuildFileView> {
|
|||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 5,
|
top: 5,
|
||||||
left: 5,
|
right: 5,
|
||||||
width: 50,
|
width: 50,
|
||||||
height: 50,
|
height: 50,
|
||||||
child: IconButton.filled(
|
child: IconButton.filled(
|
||||||
@@ -102,7 +102,7 @@ class _BuildFileViewState extends State<BuildFileView> {
|
|||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 5,
|
top: 5,
|
||||||
left: 5,
|
right: 5,
|
||||||
width: 50,
|
width: 50,
|
||||||
height: 50,
|
height: 50,
|
||||||
child: IconButton.filled(
|
child: IconButton.filled(
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class _FullScreenFileViewerState extends State<FullScreenFileViewer> {
|
|||||||
int currentPageCount = 0;
|
int currentPageCount = 0;
|
||||||
int currentPage = 0;
|
int currentPage = 0;
|
||||||
double startZoomLevel = 1.0;
|
double startZoomLevel = 1.0;
|
||||||
|
double zoomOut = 0;
|
||||||
|
|
||||||
String getExtType(String path) {
|
String getExtType(String path) {
|
||||||
//print(pdfLink.split(".")[1]);
|
//print(pdfLink.split(".")[1]);
|
||||||
@@ -52,29 +53,29 @@ class _FullScreenFileViewerState extends State<FullScreenFileViewer> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final Size size = MediaQuery.sizeOf(context);
|
||||||
|
double width = size.width;
|
||||||
|
double height = size.height;
|
||||||
|
|
||||||
if (getExtType(widget.arguments.path).toLowerCase() == "pdf") {
|
if (getExtType(widget.arguments.path).toLowerCase() == "pdf") {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
width: width,
|
||||||
padding: const EdgeInsets.only(top: 20.0),
|
padding: const EdgeInsets.only(top: 20.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Center(
|
const SizedBox(height: 50),
|
||||||
child: Text(
|
SizedBox(
|
||||||
getFileName(widget.arguments.path),
|
width: width - zoomOut,
|
||||||
style: const TextStyle(
|
height: height - 70,
|
||||||
fontSize: 15,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Expanded(
|
|
||||||
child: SfPdfViewerTheme(
|
child: SfPdfViewerTheme(
|
||||||
data: SfPdfViewerThemeData(
|
data: SfPdfViewerThemeData(
|
||||||
backgroundColor: MzanziInnovationHub.of(context)!
|
backgroundColor: MzanziInnovationHub.of(context)!
|
||||||
@@ -123,7 +124,7 @@ class _FullScreenFileViewerState extends State<FullScreenFileViewer> {
|
|||||||
//width: 50,
|
//width: 50,
|
||||||
height: 50,
|
height: 50,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@@ -178,10 +179,16 @@ class _FullScreenFileViewerState extends State<FullScreenFileViewer> {
|
|||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
if (zoomOut > 0) {
|
||||||
pdfViewerController.zoomLevel = startZoomLevel + 0.25;
|
setState(() {
|
||||||
startZoomLevel = pdfViewerController.zoomLevel;
|
zoomOut = zoomOut - 100;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
pdfViewerController.zoomLevel = startZoomLevel + 0.25;
|
||||||
|
startZoomLevel = pdfViewerController.zoomLevel;
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.zoom_in,
|
Icons.zoom_in,
|
||||||
@@ -193,10 +200,16 @@ class _FullScreenFileViewerState extends State<FullScreenFileViewer> {
|
|||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
if (pdfViewerController.zoomLevel > 1) {
|
||||||
pdfViewerController.zoomLevel = startZoomLevel - 0.25;
|
setState(() {
|
||||||
startZoomLevel = pdfViewerController.zoomLevel;
|
pdfViewerController.zoomLevel = startZoomLevel - 0.25;
|
||||||
});
|
startZoomLevel = pdfViewerController.zoomLevel;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
zoomOut = zoomOut + 100;
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.zoom_out,
|
Icons.zoom_out,
|
||||||
@@ -232,8 +245,8 @@ class _FullScreenFileViewerState extends State<FullScreenFileViewer> {
|
|||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.only(top: 20.0),
|
padding: const EdgeInsets.only(top: 50.0),
|
||||||
// width: width,
|
width: width,
|
||||||
// height: height,
|
// height: height,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
@@ -245,15 +258,6 @@ class _FullScreenFileViewerState extends State<FullScreenFileViewer> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
Center(
|
|
||||||
child: Text(
|
|
||||||
getFileName(widget.arguments.path),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: InteractiveViewer(
|
child: InteractiveViewer(
|
||||||
|
|||||||
Reference in New Issue
Block a user