diff --git a/lib/popups/files_popup.dart b/lib/popups/files_popup.dart index 27ef986..695bdab 100644 --- a/lib/popups/files_popup.dart +++ b/lib/popups/files_popup.dart @@ -86,21 +86,35 @@ class _FileListItemState extends State<_FileListItem> { try { if (widget.file.isPdf) { - Navigator.of(context).pop(); // Close the files dialog - - // Navigate to PDF viewer - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => PdfViewerPage( - pdfUrl: widget.file.url, - title: widget.file.name, - ), - ), + // Show PDF in a dialog on top of the files dialog + await showDialog( + context: context, + builder: (BuildContext context) { + return Dialog( + insetPadding: const EdgeInsets.all(8), + child: Column( + children: [ + AppBar( + title: Text(widget.file.name), + leading: IconButton( + icon: const Icon(Icons.close), + onPressed: () => Navigator.of(context).pop(), + ), + automaticallyImplyLeading: false, + ), + Expanded( + child: PdfViewerPage( + pdfUrl: widget.file.url, + title: widget.file.name, + ), + ), + ], + ), + ); + }, ); } else if (widget.file.isImage) { - Navigator.of(context).pop(); // Close the files dialog - - // Show image in a dialog + // Show image in a dialog on top of the files dialog await showDialog( context: context, builder: (BuildContext context) {