fa95c2fcae
Keep the running indicator and Needs you flow, but remove the failed-count badge and its tab count plumbing until unseen-state behavior is addressed. Preserve the unfinished seen-state work separately. Verify application, Runs, attention and shell regressions.
148 lines
4.1 KiB
Dart
148 lines
4.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../features/attention/domain/attention_models.dart';
|
|
import '../ui/motion/motion.dart';
|
|
|
|
/// A generic attention count, separate from the Runs tab's status counts.
|
|
///
|
|
/// The bell itself lives in the Runs heading, so without this the count would
|
|
/// be visible only on that destination; the web mirrors it on the rail and
|
|
/// dock tab. Material hosts use the framework [Badge]. Zero draws the bare
|
|
/// icon, and a count labels the item exactly like the bell:
|
|
/// `Notifications, {n} needing attention`.
|
|
class AttentionDestinationIcon extends StatelessWidget {
|
|
const AttentionDestinationIcon({
|
|
super.key,
|
|
required this.count,
|
|
required this.child,
|
|
});
|
|
|
|
final int count;
|
|
|
|
final Widget child;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final visible = count > 0;
|
|
final Widget icon = Badge(
|
|
label: visible
|
|
? MotionSwitcher(
|
|
scale: true,
|
|
child: Text('$count', key: ValueKey(count)),
|
|
)
|
|
: null,
|
|
isLabelVisible: visible,
|
|
child: child,
|
|
);
|
|
if (!visible) return icon;
|
|
// The number alone would read as a stray "3"; the item carries the bell's
|
|
// full label instead.
|
|
return Semantics(
|
|
label: attentionBadgeLabel(count),
|
|
child: ExcludeSemantics(child: icon),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// The Runs tab shows executing work only; its error counter is removed.
|
|
class RunsDestinationIcon extends StatelessWidget {
|
|
const RunsDestinationIcon({
|
|
super.key,
|
|
required this.running,
|
|
required this.child,
|
|
this.attention = 0,
|
|
});
|
|
|
|
final int running;
|
|
final int attention;
|
|
final Widget child;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final labels = [if (running > 0) '$running runs in progress'];
|
|
return Semantics(
|
|
label: labels.join(', '),
|
|
child: ExcludeSemantics(
|
|
child: Tooltip(
|
|
message: labels.isEmpty ? 'Runs' : 'Runs: ${labels.join(', ')}',
|
|
excludeFromSemantics: true,
|
|
child: ActivityBadge(
|
|
key: const ValueKey('shell.badge.runs.running'),
|
|
count: running,
|
|
label: 'runs in progress',
|
|
bottom: true,
|
|
child: child,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// A small primary-theme count on a tab icon for activity (runs in progress, unread
|
|
/// chats), so it reads apart from the red needs-you count.
|
|
class ActivityBadge extends StatelessWidget {
|
|
const ActivityBadge({
|
|
super.key,
|
|
required this.count,
|
|
required this.label,
|
|
required this.child,
|
|
this.bottom = false,
|
|
});
|
|
|
|
final int count;
|
|
final String label;
|
|
|
|
final bool bottom;
|
|
final Widget child;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final visible = count > 0;
|
|
final color = Theme.of(context).colorScheme.primary;
|
|
final text = Theme.of(context).colorScheme.onPrimary;
|
|
final stack = Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
child,
|
|
PositionedDirectional(
|
|
top: bottom ? null : -6,
|
|
bottom: bottom ? -6 : null,
|
|
end: -10,
|
|
child: AnimatedScale(
|
|
scale: visible ? 1 : 0,
|
|
duration: Motion.of(context, Motion.quick),
|
|
curve: Motion.curve,
|
|
child: DecoratedBox(
|
|
decoration: ShapeDecoration(
|
|
color: color,
|
|
shape: const StadiumBorder(),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
|
|
child: MotionSwitcher(
|
|
scale: true,
|
|
child: Text(
|
|
visible ? '$count' : '',
|
|
key: ValueKey(count),
|
|
style: TextStyle(
|
|
color: text,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
if (!visible) return stack;
|
|
return Semantics(
|
|
label: '$count $label',
|
|
child: ExcludeSemantics(child: stack),
|
|
);
|
|
}
|
|
}
|