322f0a066f
The opened recorded-visit pane gains one native Changes action next to Back to timeline. It reuses showRunChanges with only that visit's step, so the pushed page shows that visit's own capture and no run-wide summary, and a visit without a capture reaches the honest missing-capture state. The run-level Changes action and its title are unchanged.
231 lines
7.0 KiB
Dart
231 lines
7.0 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../../ui/adaptive/host.dart';
|
|
import 'run_changes_action.dart';
|
|
import 'run_detail_content.dart';
|
|
import 'run_detail_visit_facts.dart';
|
|
import 'run_detail_visit_sections.dart';
|
|
|
|
/// The selected recorded visit inside the Timeline tab.
|
|
///
|
|
/// It leads with the visit's own headline facts, then native tabbed sections.
|
|
/// A fact the reply did not record is not drawn at all; a blank verdict or
|
|
/// diagnostic is not rendered as an empty decision.
|
|
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.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;
|
|
final String configuredEndpoint;
|
|
final bool cupertino;
|
|
final VoidCallback onClose;
|
|
|
|
@override
|
|
State<RunVisitPane> createState() => _RunVisitPaneState();
|
|
}
|
|
|
|
class _RunVisitPaneState extends State<RunVisitPane> {
|
|
RunVisitSection _section = RunVisitSection.input;
|
|
|
|
@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.input;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final style = _VisitStyle.of(context);
|
|
final facts = detailVisitFacts(widget.step);
|
|
final verdict = detailVisitVerdict(widget.step);
|
|
final diagnostic = detailVisitDiagnostic(widget.step);
|
|
return Column(
|
|
key: const Key('run-visit-pane'),
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Flexible(
|
|
flex: 3,
|
|
fit: FlexFit.loose,
|
|
child: SingleChildScrollView(
|
|
key: const Key('run-visit-facts'),
|
|
padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 8),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_bar(style),
|
|
for (final fact in facts) _FactRow(fact: fact, style: style),
|
|
if (verdict != null) ...[
|
|
const SizedBox(height: 8),
|
|
Text('Verdict', style: style.heading),
|
|
if (verdict.option != null) Text(verdict.option!),
|
|
if (verdict.reason != null)
|
|
Text(verdict.reason!, style: style.value),
|
|
],
|
|
if (diagnostic != null) ...[
|
|
const SizedBox(height: 8),
|
|
Text('Diagnostic', style: style.heading),
|
|
Text(diagnostic, style: style.value),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
RunVisitSectionStrip(
|
|
selected: _section,
|
|
onSelected: (section) => setState(() => _section = section),
|
|
),
|
|
Expanded(
|
|
flex: 2,
|
|
child: runVisitSectionBody(
|
|
section: _section,
|
|
run: widget.run,
|
|
step: widget.step,
|
|
visitIndex: widget.visitIndex,
|
|
stageKey: widget.visit.stage,
|
|
runSteps: widget.runSteps,
|
|
configuredEndpoint: widget.configuredEndpoint,
|
|
cupertino: widget.cupertino,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _bar(_VisitStyle style) {
|
|
final close = widget.cupertino
|
|
? CupertinoButton(
|
|
key: const Key('run-visit-back'),
|
|
padding: EdgeInsets.zero,
|
|
onPressed: widget.onClose,
|
|
child: const Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(CupertinoIcons.back),
|
|
SizedBox(width: 4),
|
|
Flexible(child: Text('Back to timeline')),
|
|
],
|
|
),
|
|
)
|
|
: TextButton.icon(
|
|
key: const Key('run-visit-back'),
|
|
onPressed: widget.onClose,
|
|
icon: const Icon(Icons.arrow_back),
|
|
label: const Text('Back to timeline'),
|
|
);
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// The close and change actions wrap instead of overflowing when the
|
|
// pane is narrow or the text is scaled.
|
|
Wrap(
|
|
spacing: 8,
|
|
runSpacing: 4,
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
children: [
|
|
close,
|
|
RunVisitChangesButton(
|
|
stage: widget.visit.stage,
|
|
sequence: widget.visit.sequence,
|
|
step: widget.step,
|
|
),
|
|
],
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(8, 0, 0, 0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
widget.visit.title,
|
|
key: const Key('run-visit-title'),
|
|
style: style.heading,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _FactRow extends StatelessWidget {
|
|
const _FactRow({required this.fact, required this.style});
|
|
|
|
final VisitFact fact;
|
|
final _VisitStyle style;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.only(top: 4),
|
|
child: Text.rich(
|
|
TextSpan(
|
|
children: [
|
|
TextSpan(text: '${fact.label}: ', style: style.muted),
|
|
TextSpan(text: fact.value, style: style.value),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Host text roles only: no palette, font family or explicit size.
|
|
class _VisitStyle {
|
|
const _VisitStyle({
|
|
required this.value,
|
|
required this.muted,
|
|
required this.heading,
|
|
});
|
|
|
|
factory _VisitStyle.of(BuildContext context) {
|
|
if (usesCupertinoHost(context)) {
|
|
final theme = CupertinoTheme.of(context);
|
|
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
|
|
return _VisitStyle(
|
|
value: theme.textTheme.textStyle,
|
|
muted: theme.textTheme.textStyle.copyWith(color: secondary),
|
|
heading: theme.textTheme.navTitleTextStyle,
|
|
);
|
|
}
|
|
final theme = Theme.of(context);
|
|
return _VisitStyle(
|
|
value: theme.textTheme.bodyMedium ?? const TextStyle(),
|
|
muted: (theme.textTheme.bodySmall ?? const TextStyle()).copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
heading: theme.textTheme.titleSmall ?? const TextStyle(),
|
|
);
|
|
}
|
|
|
|
final TextStyle value;
|
|
final TextStyle muted;
|
|
final TextStyle heading;
|
|
}
|