Files
pipelines/app/lib/features/attention/ui/needs_you_copy.dart
T

37 lines
1.4 KiB
Dart

import '../domain/attention_models.dart';
/// The sheet's title and actions, matching the browser's `Needs you` surface.
const attentionSheetTitle = 'Needs you';
const attentionEmptyCopy = 'Nothing needs you right now.';
const attentionClearAllCopy = 'Clear all';
const attentionCloseCopy = 'Close';
/// One row's dismissal name.
///
/// The browser names every destructive control by the row it removes
/// (`Dismiss {label}`), so a sheet with two rows never exposes two identical
/// `Dismiss` actions to VoiceOver, TalkBack or voice control. A repeated label
/// also carries the run id, because the label alone would still be ambiguous.
String attentionDismissLabel(AttentionEntry entry, {bool repeated = false}) {
final label = 'Dismiss ${entry.label}';
return repeated ? '$label (run ${entry.runId})' : label;
}
/// The dismissal names for the rows of one open sheet, keyed by entry identity.
///
/// Only repeated labels get the run id, so the common case stays short and
/// readable, exactly as the browser's `labelCounts` decides.
Map<String, String> attentionDismissLabels(Iterable<AttentionEntry> entries) {
final counts = <String, int>{};
for (final entry in entries) {
counts.update(entry.label, (count) => count + 1, ifAbsent: () => 1);
}
return {
for (final entry in entries)
entry.key: attentionDismissLabel(
entry,
repeated: (counts[entry.label] ?? 0) > 1,
),
};
}