137 lines
4.1 KiB
Dart
137 lines
4.1 KiB
Dart
import '../../../ui/theme/app_theme.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/adaptive/host.dart';
|
|
import '../domain/artifact_document.dart';
|
|
import '../domain/artifact_groups.dart';
|
|
import 'artifact_record_row.dart';
|
|
import 'artifact_row_labels.dart';
|
|
|
|
/// 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,
|
|
});
|
|
|
|
/// 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,
|
|
);
|
|
}
|
|
if (usesCupertinoHost(context)) {
|
|
return CupertinoListSection.insetGrouped(
|
|
backgroundColor: AppColors.groupedBackground,
|
|
header: Semantics(
|
|
container: true,
|
|
header: true,
|
|
child: const Text('Turn documents'),
|
|
),
|
|
hasLeading: false,
|
|
children: rows,
|
|
);
|
|
}
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 4),
|
|
child: Semantics(
|
|
container: true,
|
|
header: true,
|
|
child: const Text('Turn documents'),
|
|
),
|
|
),
|
|
...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) {
|
|
if (!usesCupertinoHost(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,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
final textTheme = CupertinoTheme.of(context).textTheme;
|
|
final absenceStyle = textTheme.textStyle.copyWith(
|
|
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
|
);
|
|
return Semantics(
|
|
container: true,
|
|
child: SizedBox(
|
|
width: double.infinity,
|
|
child: Padding(
|
|
padding: kCupertinoButtonPadding[CupertinoButtonSize.large]!,
|
|
child: DefaultTextStyle.merge(
|
|
style: textTheme.textStyle,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(document.name),
|
|
Text(document.absence, style: absenceStyle),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|