Files
pipelines/app/lib/features/artifacts/ui/artifact_selection_facts.dart
T
alan c553b7d90d feat(app): give the artifact gallery the web's compact layout
Put the page summary and the recorded capture notes on one scrolling
header, style Material section headings as muted titleSmall, and draw a
hairline between Material rows only. Share the selection-facts hierarchy
between the sheet and the viewer and order the sheet actions Close,
Copy link, Open on both hosts.

The header now rides inside the artifact list's scroll view, so many
partial visits or a large text scale scroll with the rows instead of
overflowing the page and collapsing the list.

Tests cover per-host headings, dividers, notes, sheet order, and the
constrained 2x large-text layouts.
2026-10-22 14:39:08 +01:00

98 lines
3.6 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/host.dart';
import '../../graph/domain/stage_visits.dart';
import '../domain/artifact_groups.dart';
import '../domain/artifact_record.dart';
import '../domain/artifact_summary.dart';
import '../domain/artifact_url.dart';
import 'artifact_visit_list.dart';
/// The key one recorded group maps to, used only to find its step.
String artifactGroupKey(String stageKey, int visit) => '$stageKey\u0000$visit';
/// Each recorded group's step, keyed by stage and display visit, so a selected
/// row can show its own visit's capture facts. Derives the same grouping the
/// gallery uses; an absent key yields null rather than a fabricated capture.
Map<String, JsonMap> recordedStepsByGroup(List<JsonMap> steps) {
final result = <String, JsonMap>{};
for (final entry in visitsByStage(steps).entries) {
for (var index = 0; index < entry.value.length; index += 1) {
final step = entry.value[index];
result[artifactGroupKey(entry.key, displayVisit(step, index))] = step;
}
}
return result;
}
/// The recorded facts of one selected artifact: name, MIME/size, its visit's
/// capture summary and notes, and the url state. Nothing is inferred.
///
/// The same block heads the selection sheet and the viewer, so both surfaces
/// read the same way: the artifact's name is the surface title, the recorded
/// type/size and visit are muted metadata, and the visit's capture summary and
/// notes sit below them. Typography is the host theme's own body and secondary
/// label styles; no size, colour or spacing scale is declared here.
class ArtifactSelectionFacts extends StatelessWidget {
const ArtifactSelectionFacts({
super.key,
required this.group,
required this.artifact,
required this.step,
required this.resolved,
});
final ArtifactGroup group;
final ArtifactRecord artifact;
final JsonMap? step;
final ResolvedArtifactUrl? resolved;
@override
Widget build(BuildContext context) {
final recordedStep = step;
final url = resolved;
final cupertino = usesCupertinoHost(context);
final primaryStyle = cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.bodyMedium ?? const TextStyle();
final secondaryStyle = primaryStyle.copyWith(
color: cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant,
);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(artifactFactsLabel(artifact), style: secondaryStyle),
const SizedBox(height: 6),
Text(artifactGroupLabel(group), style: secondaryStyle),
if (recordedStep != null) ...[
const SizedBox(height: 12),
Text(
artifactsSummary(recordedStep, count: group.recordedCount),
style: primaryStyle,
),
for (final note in artifactCaptureNotes(recordedStep))
Padding(
padding: const EdgeInsets.only(top: 2),
child: Text(note, style: secondaryStyle),
),
],
if (!artifact.hasUrl) ...[
const SizedBox(height: 12),
Text('No artifact URL recorded.', style: secondaryStyle),
] else if (url == null) ...[
const SizedBox(height: 12),
Text(
'The recorded artifact URL cannot be opened safely.',
style: secondaryStyle,
),
],
],
);
}
}