Files
pipelines/app/lib/features/runs/ui/run_detail_visit.dart
T

112 lines
3.7 KiB
Dart

import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/motion/fade_through_stack.dart';
import 'run_detail_content.dart';
import 'run_detail_visit_facts_view.dart';
import 'run_detail_visit_sections.dart';
/// The selected recorded visit's page body: its sections under floating
/// tabs. The page's bar carries the stage and its coordinates
/// ([runVisitSubtitle]); the Summary section leads with the visit's facts.
class RunVisitPane extends StatefulWidget {
const RunVisitPane({
super.key,
required this.run,
required this.visit,
required this.visitIndex,
required this.step,
required this.runSteps,
required this.gateway,
required this.onRunChanged,
required this.configuredEndpoint,
required this.cupertino,
required this.onClose,
});
final JsonMap run;
final DetailVisit visit;
/// The visit's index in [runSteps], so the artifacts section can open exactly
/// this visit's gallery group.
final int visitIndex;
final JsonMap step;
final List<JsonMap> runSteps;
/// The app's shared gateway and the accepted-detail fold for the session's
/// export-only repair. The visit never opens its own socket.
final ApiGateway gateway;
final ValueChanged<JsonMap> onRunChanged;
final String configuredEndpoint;
final bool cupertino;
final VoidCallback onClose;
@override
State<RunVisitPane> createState() => _RunVisitPaneState();
}
class _RunVisitPaneState extends State<RunVisitPane> {
RunVisitSection _section = RunVisitSection.summary;
@override
void didUpdateWidget(covariant RunVisitPane oldWidget) {
super.didUpdateWidget(oldWidget);
// A different visit starts at its first section, like a newly opened pane.
if (oldWidget.visit.sequence != widget.visit.sequence ||
oldWidget.visit.stage != widget.visit.stage) {
_section = RunVisitSection.summary;
}
}
@override
Widget build(BuildContext context) {
// The section fills the page and scrolls behind the page's top bar (which
// names the stage and its visit) and the floating tabs, padding its
// content clear of both at rest. Summary leads with the visit's facts.
return KeyedSubtree(
key: const Key('run-visit-pane'),
child: FloatingBarOverlay(
bar: RunVisitSectionStrip(
selected: _section,
onSelected: (section) => setState(() => _section = section),
),
// Every section fills the page, on a phone and an unfolded foldable.
child: FadeThroughStack(
index: shownVisitSections.indexOf(visitTabFor(_section)),
children: [
for (final section in shownVisitSections)
runVisitSectionBody(
section: section,
run: widget.run,
step: widget.step,
visitIndex: widget.visitIndex,
stageKey: widget.visit.stage,
runSteps: widget.runSteps,
gateway: widget.gateway,
onRunChanged: widget.onRunChanged,
configuredEndpoint: widget.configuredEndpoint,
cupertino: widget.cupertino,
facts: RunVisitFactsView(step: widget.step),
),
],
),
),
);
}
}
/// The page bar's subtitle for a recorded visit: its per-stage visit, then the run
/// it belongs to (`Visit 2 · Run 7 · Nightly report`).
String runVisitSubtitle(JsonMap run, DetailVisit visit) {
final runId = '${run['id'] ?? ''}'.trim();
final title = detailTitle(run);
return [
'Visit ${visit.visit}',
if (runId.isNotEmpty) 'Run $runId',
if (title.isNotEmpty && title != 'Run $runId') title,
].join(' · ');
}