Files
pipelines/app/lib/features/chat/conversation/chat_task_spinner.dart
T
alan 26bb583f10 Refine Settings destination shell integration
Keep Settings navigation independent while preserving shell actions and destination-specific state. Add the reviewed chat, run-entry, layout, and regression-test updates needed by the destination behavior.
2026-11-12 11:21:26 +00:00

51 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
/// Background-task glyph for the composer. While [running] is above zero it
/// shows a thin Material progress ring around the count; with reduced motion
/// the ring holds one static quarter segment instead of spinning. With no
/// running task it is the plain layers icon, with no ring. Always [size] square
/// so the button keeps the same dimensions in every state.
class ChatTaskSpinner extends StatelessWidget {
const ChatTaskSpinner({super.key, required this.running, this.size = 16});
final int running;
final double size;
/// Fraction of the ring drawn while reduced motion holds it still.
static const double reducedSegment = 0.25;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final reduced = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
final content = running > 0
? Stack(
alignment: Alignment.center,
children: [
SizedBox.square(
dimension: size,
child: CircularProgressIndicator(
strokeWidth: 2,
color: theme.colorScheme.primary,
value: reduced ? reducedSegment : null,
),
),
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
'$running',
key: const Key('chat-background-tasks-count'),
style: theme.textTheme.labelSmall,
),
),
],
)
: Icon(Icons.layers_outlined, size: size);
return SizedBox.square(
key: const Key('chat-background-tasks-spinner'),
dimension: size,
child: content,
);
}
}