Artifact viewer: full screen view; HTML scrolls, pans and zooms; links open safely

Full screen button in the viewer's bottom bar opens a root full-screen route
with the same bar and top bar; exit by the bar, Close, Escape or back. It
renders the already fetched bytes, never the system browser. The external
Open action is now labelled Open in browser.

Native web views claim their gestures (vertical drags inline, every pointer
in full screen) so the page swipe no longer starves them. On the web, full
screen adds zoom buttons that scale the live sandboxed frame. Links: in-page
anchors scroll, http(s)/mailto open outside, everything else is inert.

Capture kit: --touch, swipe=, pinch=, tabs=; html=1 fixture artifact.
This commit is contained in:
2026-11-03 18:50:41 +00:00
parent fa6c0864db
commit 4e0481fd8d
26 changed files with 1305 additions and 319 deletions
@@ -1,5 +1,6 @@
import 'package:flutter/widgets.dart';
import 'artifact_fullscreen.dart';
import 'artifact_html_view_native.dart'
if (dart.library.js_interop) 'artifact_html_view_web.dart'
as impl;
@@ -9,6 +10,12 @@ import 'artifact_html_view_native.dart'
typedef ArtifactHtmlBuilder =
Widget Function(BuildContext context, String html);
/// Whether the full-screen view offers zoom buttons for HTML: on the web the
/// sandboxed frame cannot be pinched (the page's viewport is not scalable and
/// a frame's document has no pinch zoom of its own), so the buttons scale the
/// live frame. The mobile web views pinch natively and offer none.
const bool artifactHtmlZoomButtons = impl.inertHtmlZoomButtons;
/// Renders a recorded HTML document inertly: on the web in an iframe whose
/// empty `sandbox` blocks scripts, forms, popups and navigation; on Android and
/// iOS in a web view with JavaScript disabled and navigation refused. The
@@ -18,13 +25,22 @@ typedef ArtifactHtmlBuilder =
/// the web the iframe is a platform view that takes every click over its
/// area, even where a bar is drawn on top, which left the viewer's actions
/// and pager unclickable.
///
/// Inside an [ArtifactFullscreenScope] the document takes every gesture over
/// it and follows the scope's zoom; inline it shares them with the viewer's
/// page swipe.
Widget defaultArtifactHtml(BuildContext context, String html) {
final padding = MediaQuery.paddingOf(context);
final fullscreen = ArtifactFullscreenScope.maybeOf(context);
return Padding(
padding: EdgeInsets.only(top: padding.top, bottom: padding.bottom),
child: SizedBox.expand(
key: const Key('artifact-html-preview'),
child: impl.InertHtmlView(html: html),
child: impl.InertHtmlView(
html: html,
interactive: fullscreen != null,
zoom: fullscreen?.htmlZoom,
),
),
);
}