Files
alan edc503b228 Remove Cupertino changes branches
Keep the Material-only changes feature while preserving public Cupertino parameters for callers. Remove Cupertino-only widgets, imports, hosts, and tests because the app never reaches that path.
2026-11-11 16:22:09 +00:00

188 lines
6.0 KiB
Dart

import 'package:flutter/material.dart';
import '../domain/change_capture.dart';
import '../domain/change_kind.dart';
import '../domain/change_wording.dart';
import '../domain/file_change.dart';
import 'change_style.dart';
/// One stage/visit capture: its honest status, scope, counters and diagnostic,
/// followed by the recorded file rows. Missing and unavailable captures are
/// shown as evidence gaps, never as an observed no-change.
class StageCaptureSection extends StatelessWidget {
const StageCaptureSection({
super.key,
required this.stage,
required this.query,
required this.onOpen,
});
final StageCapture stage;
final String query;
final ValueChanged<FileChange> onOpen;
@override
Widget build(BuildContext context) {
final capture = stage.capture;
final filtered = capture == null
? const <FileChange>[]
: filterFileChanges(capture.files, query);
// The aggregate trims and lowercases the status before testing it; do the
// same here so the section and the run header always agree.
final status = stage.stepStatus.trim().toLowerCase();
final pending =
capture == null && (status == 'running' || status == 'waiting');
final meta = [
'Visit ${stage.visit}',
if (stage.stepStatus.isNotEmpty) stage.stepStatus,
].join(' · ');
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(meta, style: Theme.of(context).textTheme.bodySmall),
if (capture != null) ...[
Text(
fileChangesSummary(capture),
style: Theme.of(context).textTheme.bodySmall,
),
if (capture.scope.isNotEmpty)
Text(
'Scope: ${capture.scope}',
style: Theme.of(context).textTheme.bodySmall,
),
],
],
),
),
const Divider(height: 1),
if (capture == null)
_CaptureNote(
icon: _noteIcon(pending ? _NoteKind.pending : _NoteKind.missing),
title: pending ? 'Capture pending' : 'Capture unavailable',
detail: pending ? pendingCaptureDetail : missingCaptureDetail,
)
else if (capture.unavailable)
_CaptureNote(
icon: _noteIcon(_NoteKind.unavailable),
title: 'Capture unavailable',
detail: capture.diagnostic.isEmpty
? unavailableCaptureDetail
: capture.diagnostic,
)
else if (capture.files.isEmpty)
_CaptureNote(
icon: _noteIcon(
capture.partial ? _NoteKind.partial : _NoteKind.empty,
),
title: capture.partial ? 'Partial capture' : 'No changes observed',
detail: capture.partial ? partialCaptureDetail : emptyCaptureDetail,
)
else if (filtered.isEmpty)
Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 16),
child: Text('No changed filenames match "$query".'),
)
else
for (final file in filtered)
ChangeFileRow(
key: ValueKey('change-${stage.sequence}-${file.path}'),
file: file,
onOpen: onOpen,
),
],
);
}
}
/// One changed file: its kind, path and line counts; tapping opens its diff.
class ChangeFileRow extends StatelessWidget {
const ChangeFileRow({super.key, required this.file, required this.onOpen});
final FileChange file;
final ValueChanged<FileChange> onOpen;
@override
Widget build(BuildContext context) {
final mono = nativeDiffText(DefaultTextStyle.of(context).style);
final leading = Icon(_kindIcon(file.kind));
final title = Text(file.path, style: mono);
final subtitle = ChangeStatText(changeFileMeta(file));
const trailing = Icon(Icons.chevron_right);
return Semantics(
container: true,
button: true,
// Announce the visible kind and meta too; the row's icon and subtitle are
// excluded from the semantic tree by [excludeSemantics].
label:
'Open diff for ${file.path}. '
'${changeKindTitle(file.kind)} · ${changeFileMeta(file)}',
excludeSemantics: true,
onTap: () => onOpen(file),
child: ListTile(
leading: leading,
title: title,
subtitle: subtitle,
trailing: trailing,
onTap: () => onOpen(file),
),
);
}
}
class _CaptureNote extends StatelessWidget {
const _CaptureNote({
required this.icon,
required this.title,
required this.detail,
});
final IconData icon;
final String title;
final String detail;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 16),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(icon),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: Theme.of(context).textTheme.titleSmall),
const SizedBox(height: 4),
Text(detail),
],
),
),
],
),
);
}
}
enum _NoteKind { missing, unavailable, empty, partial, pending }
IconData _noteIcon(_NoteKind kind) => switch (kind) {
_NoteKind.missing || _NoteKind.unavailable => Icons.warning_amber,
_NoteKind.empty => Icons.check_circle_outline,
_NoteKind.partial => Icons.info_outline,
_NoteKind.pending => Icons.schedule,
};
IconData _kindIcon(ChangeKind kind) => switch (kind) {
ChangeKind.added => Icons.add_circle_outline,
ChangeKind.deleted => Icons.delete_outline,
ChangeKind.modified => Icons.edit_outlined,
ChangeKind.other => Icons.description_outlined,
};