fde086cc4a
Review findings F12, F13, F25 and F1 for viewers: the artifact viewer's actions/pager and the Changes pager float as glass pills over content, file facts move to the top bar, graph overlay controls are one glass pill (duplicate fullscreen glyph removed), the image viewer is immersive, and diff/artifact/graph views let content pass behind the bar. Implemented by pipeline run #204 (Terra); its Review stopped after three rejections, the last being an empty glass bar for a single unresolved artifact, which the manager fixed here with a regression test.
217 lines
7.2 KiB
Dart
217 lines
7.2 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/adaptive/segmented_bar.dart';
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../../ui/adaptive/host.dart';
|
|
import '../../changes/changes.dart';
|
|
|
|
/// The run detail's action and page label. The viewer itself owns the
|
|
/// recorded summary and capture wording, so this bar stays neutral.
|
|
const runChangesLabel = 'Changes';
|
|
const runChangesButtonKey = ValueKey<String>('run-detail-changes');
|
|
const runVisitChangesButtonKey = ValueKey<String>('run-visit-changes');
|
|
|
|
/// The detail's `steps` exactly as returned by the server. The pushed page
|
|
/// snapshots the returned list once, so it never re-derives on each rebuild.
|
|
List<JsonMap> runDetailChangeSteps(JsonMap run) {
|
|
final steps = run['steps'];
|
|
if (steps is List<JsonMap>) return steps;
|
|
if (steps is List) return steps.cast<JsonMap>();
|
|
return const <JsonMap>[];
|
|
}
|
|
|
|
const _executingStatuses = {'queued', 'running', 'waiting'};
|
|
|
|
/// Whether the run detail offers the action at all. The opened page is a
|
|
/// snapshot of the recorded steps, so it is offered only once nothing is
|
|
/// executing: the server's own `executing` flag (which can stay true on a
|
|
/// failed run whose step is still active) or a queued/running/waiting status
|
|
/// would otherwise show a page that silently goes stale.
|
|
bool showRunChangesAction(JsonMap run) =>
|
|
run['executing'] != true &&
|
|
!_executingStatuses.contains('${run['status'] ?? ''}'.trim().toLowerCase());
|
|
|
|
/// A standard native button for the run detail body. It opens the recorded
|
|
/// changes in a platform page whose single navigation bar is the only chrome.
|
|
class RunChangesButton extends StatelessWidget {
|
|
const RunChangesButton({super.key, required this.run});
|
|
|
|
final JsonMap run;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final steps = runDetailChangeSteps(run);
|
|
// The web client shows the run-wide aggregate only for a succeeded run; a
|
|
// failed run still keeps each visit's own recorded capture.
|
|
final summary = showRunChangesSummary(run['status']);
|
|
void open() => showRunChanges(context, steps: steps, showSummary: summary);
|
|
if (usesCupertinoHost(context)) {
|
|
return CupertinoButton.tinted(
|
|
key: runChangesButtonKey,
|
|
onPressed: open,
|
|
// The label keeps its intrinsic size until scaled text no longer fits
|
|
// the detail's narrowest pane; then it wraps inside the native button
|
|
// instead of overflowing the header row.
|
|
child: const Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(CupertinoIcons.doc_text),
|
|
SizedBox(width: 6),
|
|
Flexible(child: Text(runChangesLabel)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
return OutlinedButton.icon(
|
|
key: runChangesButtonKey,
|
|
onPressed: open,
|
|
icon: const Icon(Icons.difference_outlined),
|
|
label: const Text(runChangesLabel),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Opens the already-landed [ChangesViewer] for [steps] on a native page.
|
|
/// The bar is the one title bar; the viewer's own summary and capture facts
|
|
/// are passed through untouched, except for the caller's [showSummary] gate.
|
|
///
|
|
/// [title] names the evidence the page shows. The run-level action keeps the
|
|
/// neutral [runChangesLabel]; a visit passes [visitChangesTitle] so the pushed
|
|
/// page cannot be mistaken for the run-wide aggregate.
|
|
Future<void> showRunChanges(
|
|
BuildContext context, {
|
|
required List<JsonMap> steps,
|
|
required bool showSummary,
|
|
String title = runChangesLabel,
|
|
}) {
|
|
final cupertino = usesCupertinoHost(context);
|
|
return Navigator.of(context).push<void>(
|
|
cupertino
|
|
? CupertinoPageRoute<void>(
|
|
builder: (_) => _CupertinoChangesPage(
|
|
steps: steps,
|
|
showSummary: showSummary,
|
|
title: title,
|
|
),
|
|
)
|
|
: MaterialPageRoute<void>(
|
|
builder: (_) => _MaterialChangesPage(
|
|
steps: steps,
|
|
showSummary: showSummary,
|
|
title: title,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// The page identity for exactly one recorded visit: the stage and visit the
|
|
/// timeline row shows, so the page names its evidence rather than the run.
|
|
String visitChangesTitle(String stage, int? sequence) {
|
|
final name = stage.trim();
|
|
final visit = sequence == null ? 'visit unavailable' : 'visit $sequence';
|
|
return name.isEmpty
|
|
? '$runChangesLabel · $visit'
|
|
: '$runChangesLabel · $name · $visit';
|
|
}
|
|
|
|
/// Opens the Changes viewer for exactly one visit's recorded [step].
|
|
///
|
|
/// The page shows that step's own capture only - never the run's other visits -
|
|
/// and no run-wide final-state header, which belongs to the run-level action.
|
|
Future<void> showVisitChanges(
|
|
BuildContext context, {
|
|
required String stage,
|
|
required int? sequence,
|
|
required JsonMap step,
|
|
}) => showRunChanges(
|
|
context,
|
|
steps: <JsonMap>[step],
|
|
showSummary: false,
|
|
title: visitChangesTitle(stage, sequence),
|
|
);
|
|
|
|
/// The opened visit pane's own native action. It passes only the visit's step,
|
|
/// so the viewer's per-stage section is its single evidence entry.
|
|
class RunVisitChangesButton extends StatelessWidget {
|
|
const RunVisitChangesButton({
|
|
super.key,
|
|
required this.stage,
|
|
required this.sequence,
|
|
required this.step,
|
|
});
|
|
|
|
final String stage;
|
|
final int? sequence;
|
|
final JsonMap step;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
void open() =>
|
|
showVisitChanges(context, stage: stage, sequence: sequence, step: step);
|
|
if (usesCupertinoHost(context)) {
|
|
return CupertinoButton(
|
|
key: runVisitChangesButtonKey,
|
|
padding: EdgeInsets.zero,
|
|
onPressed: open,
|
|
child: const Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(CupertinoIcons.doc_text),
|
|
SizedBox(width: 6),
|
|
Flexible(child: Text(runChangesLabel)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
return TextButton.icon(
|
|
key: runVisitChangesButtonKey,
|
|
onPressed: open,
|
|
icon: const Icon(Icons.difference_outlined),
|
|
label: const Text(runChangesLabel),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _MaterialChangesPage extends StatelessWidget {
|
|
const _MaterialChangesPage({
|
|
required this.steps,
|
|
required this.showSummary,
|
|
required this.title,
|
|
});
|
|
|
|
final List<JsonMap> steps;
|
|
final bool showSummary;
|
|
final String title;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: SegmentedBar(cupertino: false, title: title),
|
|
body: ChangesViewer(steps: steps, showSummary: showSummary),
|
|
);
|
|
}
|
|
|
|
class _CupertinoChangesPage extends StatelessWidget {
|
|
const _CupertinoChangesPage({
|
|
required this.steps,
|
|
required this.showSummary,
|
|
required this.title,
|
|
});
|
|
|
|
final List<JsonMap> steps;
|
|
final bool showSummary;
|
|
final String title;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => CupertinoPageScaffold(
|
|
navigationBar: SegmentedBar(cupertino: true, title: title),
|
|
child: Theme(
|
|
// A CupertinoApp supplies no Material theme; follow the host brightness
|
|
// so the viewer's Material-derived section text stays readable.
|
|
data: hostTextTheme(context),
|
|
child: ChangesViewer(steps: steps, showSummary: showSummary),
|
|
),
|
|
);
|
|
}
|