feat(app): run and stage artifacts share one gallery grid with image thumbnails and file-type icons
This commit is contained in:
@@ -1,13 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../artifacts/domain/artifact_groups.dart';
|
||||
import '../../artifacts/domain/artifact_record.dart';
|
||||
import '../../artifacts/domain/artifact_summary.dart';
|
||||
import '../../artifacts/ui/artifact_gallery_action.dart';
|
||||
import '../../artifacts/ui/artifact_visit_list.dart';
|
||||
import '../../artifacts/ui/artifact_gallery_page.dart';
|
||||
|
||||
/// The visit's recorded stage artifacts, in recorded order.
|
||||
///
|
||||
@@ -36,77 +30,16 @@ class RunVisitArtifacts extends StatelessWidget {
|
||||
final List<JsonMap> runSteps;
|
||||
final String configuredEndpoint;
|
||||
|
||||
/// The same gallery as the run's Artifacts tab, focused on this visit.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final artifacts = visitArtifacts(step, runSteps);
|
||||
final notes = artifactCaptureNotes(step);
|
||||
if (artifacts.isEmpty) {
|
||||
return ListView(
|
||||
key: const Key('run-visit-body-artifacts'),
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
Text(artifactsSummary(step, count: 0)),
|
||||
for (final note in notes)
|
||||
Padding(padding: const EdgeInsets.only(top: 4), child: Text(note)),
|
||||
],
|
||||
);
|
||||
}
|
||||
void open() => showArtifactGallery(
|
||||
context,
|
||||
Widget build(BuildContext context) => KeyedSubtree(
|
||||
key: const Key('run-visit-body-artifacts'),
|
||||
child: ArtifactGalleryPage(
|
||||
key: ValueKey('run-visit-artifacts-$visitIndex'),
|
||||
steps: runSteps.isEmpty ? <JsonMap>[step] : runSteps,
|
||||
focusIndex: runSteps.isEmpty ? 0 : visitIndex,
|
||||
configuredEndpoint: configuredEndpoint,
|
||||
);
|
||||
final noteRows = [
|
||||
for (final note in notes)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Text(note),
|
||||
),
|
||||
];
|
||||
if (usesCupertinoHost(context)) {
|
||||
return ListView(
|
||||
key: const Key('run-visit-body-artifacts'),
|
||||
children: [
|
||||
...noteRows,
|
||||
CupertinoListSection.insetGrouped(
|
||||
children: [
|
||||
for (final artifact in artifacts)
|
||||
_CupertinoArtifactRow(artifact: artifact, onTap: open),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return ListView(
|
||||
key: const Key('run-visit-body-artifacts'),
|
||||
children: [
|
||||
...noteRows,
|
||||
for (final artifact in artifacts)
|
||||
ListTile(
|
||||
title: Text(artifactDisplayName(artifact)),
|
||||
subtitle: Text(artifactFactsLabel(artifact)),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: open,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CupertinoArtifactRow extends StatelessWidget {
|
||||
const _CupertinoArtifactRow({required this.artifact, required this.onTap});
|
||||
|
||||
final ArtifactRecord artifact;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoListTile(
|
||||
title: Text(artifactDisplayName(artifact)),
|
||||
subtitle: Text(artifactFactsLabel(artifact)),
|
||||
trailing: const Icon(CupertinoIcons.chevron_forward),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
embedded: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user