f46b82e207
Keep the Material implementation while preserving public parameters needed by callers. Remove Cupertino-only tests and variants because the app runs exclusively under MaterialApp.
92 lines
3.3 KiB
Dart
92 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.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 primaryStyle =
|
|
Theme.of(context).textTheme.bodyMedium ?? const TextStyle();
|
|
final secondaryStyle = primaryStyle.copyWith(
|
|
color: 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,
|
|
),
|
|
],
|
|
],
|
|
);
|
|
}
|
|
}
|