Files
pipelines/app/lib/features/artifacts/ui/artifact_document_section.dart
alan f46b82e207 Remove Cupertino branches from artifact features
Keep the Material implementation while preserving public parameters needed by callers. Remove Cupertino-only tests and variants because the app runs exclusively under MaterialApp.
2026-11-11 04:36:57 +00:00

102 lines
3.3 KiB
Dart

import 'package:flutter/material.dart';
import '../domain/artifact_document.dart';
import '../domain/artifact_groups.dart';
import 'artifact_record_row.dart';
import 'artifact_row_labels.dart';
/// The gallery's label for a visit's runner-internal files (turn documents,
/// history.md, private/ scratch, session exports), shown only while Debug is on.
const String debuggingFilesTitle = 'Debugging files';
/// One visit's turn documents, shown below its stage artifacts.
///
/// A recorded document is a normal gallery row with its recorded name, MIME and
/// size. A document the visit did not record is a non-actionable row carrying
/// the exact absence wording. The section never synthesizes a missing document
/// from another field and never offers an action for it.
class ArtifactDocumentSection extends StatelessWidget {
const ArtifactDocumentSection({
super.key,
required this.group,
this.selectedIdentity,
this.onSelected,
this.showHeader = true,
this.title = 'Turn documents',
});
/// The section label: the Session page names the turn documents; the gallery
/// names every runner-internal file it lists as debugging files.
final String title;
/// False when a collapsible title above already names the section.
final bool showHeader;
final ArtifactGroup group;
final String? selectedIdentity;
final ArtifactSelected? onSelected;
@override
Widget build(BuildContext context) {
final rows = <Widget>[
for (final document in group.documents) _row(document),
];
if (!showHeader) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: rows,
);
}
// Flat rows under a quiet label: the section sits inside the visit's
// Session page, which is itself flat.
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 4),
child: Semantics(container: true, header: true, child: Text(title)),
),
...rows,
],
);
}
Widget _row(ArtifactDocument document) {
final record = document.record;
if (record == null) return _AbsentDocumentRow(document: document);
final key = ValueKey<String>(
'${artifactVisitIdentity(group, record)}\u0000document',
);
return ArtifactRecordRow(
key: key,
group: group,
artifact: record,
selected: selectedIdentity == artifactVisitIdentity(group, record),
onSelected: onSelected,
);
}
}
/// A document the visit did not record: the recorded name and its exact absence
/// wording, with no tap target.
class _AbsentDocumentRow extends StatelessWidget {
const _AbsentDocumentRow({required this.document});
final ArtifactDocument document;
@override
Widget build(BuildContext context) {
// The absence line is informational product content, so it keeps the
// theme's normal secondary label colour. A disabled tile would paint both
// lines at the disabled colour (about 2.7:1 in light mode); no `onTap`
// keeps the row non-actionable without dimming it.
return ListTile(
title: Text(document.name),
subtitle: Text(
document.absence,
style: TextStyle(color: Theme.of(context).colorScheme.onSurfaceVariant),
),
);
}
}