a6db4ba20e
- Run detail: on a wide window (>= 840, pane >= 600) the tabs are Material segments under the run header; phones keep the floating bottom bar. Artifacts is always a tab, badged with its count and disabled with 0 (its tooltip says why), so Changes never moves. - Pipelines list: 'Failed · last run 19 Oct' beside the status dot; facts on the next line; compact rows keep 'Failed · 19 Oct'. - Settings: Disconnect is outlined beside a tonal Reconnect. - Lists: one selection style (tonal fill plus one leading accent bar) for runs, pipelines and chats; chat's border, fill and pointer removed. - Transcript: overflowing blocks fade at the edge with a chevron instead of a 'Scroll horizontally' line (semantics hint kept); code blocks get a header strip with language and Copy; lighter light-mode code fill. - Runs list: rows under a day heading show only the time of day. - Artifact search reveal re-centres once the lazy list's extent settles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
2.5 KiB
Dart
67 lines
2.5 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
/// Scrolls one artifact of a lazy gallery into view.
|
|
///
|
|
/// The gallery builds only the rows on screen, so a requested artifact far
|
|
/// down a run may not exist yet. [reveal] scrolls by most of a viewport each
|
|
/// frame until the row keyed by [target] is built, then centres it. It stops
|
|
/// at the end of the list either way and always reports [onDone] exactly once.
|
|
class ArtifactVisitReveal {
|
|
/// Wraps the requested row so its position can be found once it is built.
|
|
final GlobalKey target = GlobalKey(debugLabel: 'artifact-reveal-target');
|
|
|
|
/// Any widget that is always built inside the gallery's scroll view.
|
|
final GlobalKey anchor = GlobalKey(debugLabel: 'artifact-reveal-anchor');
|
|
|
|
int _generation = 0;
|
|
|
|
/// Abandons a reveal in progress (a new request, or the list going away).
|
|
void cancel() => _generation++;
|
|
|
|
void reveal(VoidCallback onDone) {
|
|
final generation = ++_generation;
|
|
// Generous for any recorded run, yet bounded so a row that never builds
|
|
// cannot keep scheduling frames.
|
|
var remaining = 200;
|
|
void step() {
|
|
if (generation != _generation) return;
|
|
final row = target.currentContext;
|
|
if (row != null && row.mounted) {
|
|
Scrollable.ensureVisible(row, alignment: 0.5);
|
|
// The lazy list's extent is an estimate until the rows past the
|
|
// target are laid out; a row near the end, clamped to that estimate,
|
|
// is centred again once the next frame has measured them.
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
if (generation != _generation) return;
|
|
if (row.mounted) Scrollable.ensureVisible(row, alignment: 0.5);
|
|
onDone();
|
|
});
|
|
WidgetsBinding.instance.scheduleFrame();
|
|
return;
|
|
}
|
|
final anchorContext = anchor.currentContext;
|
|
final position = anchorContext == null
|
|
? null
|
|
: Scrollable.maybeOf(anchorContext)?.position;
|
|
if (position == null ||
|
|
!position.hasContentDimensions ||
|
|
position.pixels >= position.maxScrollExtent ||
|
|
--remaining <= 0) {
|
|
onDone();
|
|
return;
|
|
}
|
|
position.jumpTo(
|
|
(position.pixels + position.viewportDimension * 0.8).clamp(
|
|
position.minScrollExtent,
|
|
position.maxScrollExtent,
|
|
),
|
|
);
|
|
WidgetsBinding.instance.addPostFrameCallback((_) => step());
|
|
WidgetsBinding.instance.scheduleFrame();
|
|
}
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) => step());
|
|
WidgetsBinding.instance.scheduleFrame();
|
|
}
|
|
}
|