Page through a folder's files in the file viewer

Opening a file from the Files panel now passes the folder's previewable
files in their shown order, so the arrows, swipes and Previous/Next step
through them and Escape closes the viewer. Download follows the file on
screen.
This commit is contained in:
2026-11-10 00:14:18 +00:00
parent ec70bee12e
commit 339cce0424
4 changed files with 84 additions and 15 deletions
@@ -63,6 +63,10 @@ class ArtifactViewerPage extends StatefulWidget {
final bool includeExternalDocuments;
final String configuredEndpoint;
/// Where Download fetches the shown file. An artifact whose `raw` carries
/// `download_url` (the Files panel's per-file links) overrides it, so paging
/// through a folder downloads the file on screen.
final String? downloadUrl;
/// The preview rule; the Files panel passes its own (every HTML previews).
@@ -235,9 +239,13 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage>
Widget buildFrame(BuildContext context, {required bool fullscreen}) {
final page = _page;
final plan = _plan;
final downloadResolved = widget.downloadUrl == null
final pageDownload = page?.artifact.raw['download_url'];
final download = pageDownload is String && pageDownload.isNotEmpty
? pageDownload
: widget.downloadUrl;
final downloadResolved = download == null
? null
: resolveArtifactUrl(widget.configuredEndpoint, widget.downloadUrl!);
: resolveArtifactUrl(widget.configuredEndpoint, download);
final title = page == null
? artifactViewerTitle
: artifactDisplayName(page.artifact);