8d2ca95057
On a phone-width window the open run is its own page pushed on the app navigator, so RunDetailTabs was not a descendant of the shell's RunSearchSelectionScope (which wraps only the Runs tab body). The field or artifact selection was never seen and the run opened at its plain Summary. The previous widget tests injected the scope directly above RunDetailView at 900 px, where the detail is an inline pane, so they could not catch it. - RunsScreen relays the shell's search scope into the detail it builds, so the pushed page sees the selection too (also fixes field hits on phones). - An artifact hit now opens the run's Artifacts tab and the gallery opens that artifact exactly as a tap there does: selected, scrolled into view (ArtifactVisitReveal) and in the viewer. Back returns to the tab with the artifact highlighted. An unknown URL leaves the tab open with the existing "That artifact is no longer available." notice. - New test/application/search_artifact_open_test.dart drives the real Search tab -> typed query -> result tap -> run read -> viewer on a 390x844 phone, Material and Cupertino; it fails without the scope relay.
59 lines
2.1 KiB
Dart
59 lines
2.1 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);
|
|
onDone();
|
|
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();
|
|
}
|
|
}
|