Files
pipelines/app/lib/features/artifacts/ui/artifact_controls_overlay.dart
T
alan 4e0481fd8d 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.
2026-11-03 18:50:41 +00:00

117 lines
3.2 KiB
Dart

import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
/// Open, Copy and the file actions float over the top of the content: shown
/// when the page opens and whenever the content is touched, hidden again after
/// a few seconds without use, so nothing needs scrolling to reach them.
class ArtifactControlsOverlay extends StatefulWidget {
const ArtifactControlsOverlay({
super.key,
required this.controls,
required this.child,
this.hideAfter = const Duration(seconds: 3),
});
final List<Widget> controls;
final Widget child;
final Duration hideAfter;
@override
State<ArtifactControlsOverlay> createState() =>
_ArtifactControlsOverlayState();
}
class _ArtifactControlsOverlayState extends State<ArtifactControlsOverlay> {
bool _shown = true;
Timer? _hide;
@override
void initState() {
super.initState();
_schedule();
}
@override
void dispose() {
_hide?.cancel();
super.dispose();
}
void _schedule() {
_hide?.cancel();
_hide = Timer(widget.hideAfter, () {
if (mounted) setState(() => _shown = false);
});
}
void _show() {
if (!_shown) setState(() => _shown = true);
_schedule();
}
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final surface = cupertino
? CupertinoColors.systemBackground
.resolveFrom(context)
.withValues(alpha: 0.92)
: Theme.of(
context,
).colorScheme.surfaceContainerHigh.withValues(alpha: 0.94);
return Stack(
children: [
// Any touch on the content brings the controls back.
Positioned.fill(
child: Listener(
behavior: HitTestBehavior.translucent,
onPointerDown: (_) => _show(),
child: widget.child,
),
),
Positioned(
left: 8,
right: 8,
top: 8,
child: IgnorePointer(
ignoring: !_shown,
child: AnimatedOpacity(
key: const Key('artifact-viewer-controls'),
opacity: _shown ? 1 : 0,
duration: const Duration(milliseconds: 200),
child: Listener(
// Using a control keeps the bar up.
onPointerDown: (_) => _schedule(),
child: DecoratedBox(
decoration: BoxDecoration(
color: surface,
borderRadius: BorderRadius.circular(12),
boxShadow: const [
BoxShadow(color: Color(0x22000000), blurRadius: 6),
],
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 4,
vertical: 2,
),
child: Wrap(
alignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
children: widget.controls,
),
),
),
),
),
),
),
],
);
}
}